File Coverage

blib/lib/Bb/Collaborate/Ultra/Session.pm
Criterion Covered Total %
statement 25 39 64.1
branch 1 2 50.0
condition 0 10 0.0
subroutine 7 9 77.7
pod 2 2 100.0
total 35 62 56.4


line stmt bran cond sub pod time code
1             package Bb::Collaborate::Ultra::Session;
2 3     3   47401 use warnings; use strict;
  3     3   4  
  3         74  
  3         612  
  3         3  
  3         49  
3 3     3   1182 use Mouse;
  3         58809  
  3         11  
4             extends 'Bb::Collaborate::Ultra::DAO';
5              
6 3     3   2060 use Bb::Collaborate::Ultra::Session::Occurrence;
  3         7  
  3         82  
7 3     3   1077 use Bb::Collaborate::Ultra::Session::RecurrenceRule;
  3         6  
  3         77  
8 3     3   14 use Mouse::Util::TypeConstraints;
  3         2  
  3         13  
9              
10             subtype 'ArrayOfOccurrences',
11             as 'ArrayRef[Bb::Collaborate::Ultra::Session::Occurrence]';
12              
13             coerce 'ArrayOfOccurrences',
14             from 'ArrayRef[HashRef]',
15             via { [ map {Bb::Collaborate::Ultra::Session::Occurrence->new($_)} (@$_) ] };
16              
17             has 'occurrences' => (isa => 'ArrayOfOccurrences', is => 'rw', coerce => 1);
18             has 'recurrenceRule' => (isa => 'Bb::Collaborate::Ultra::Session::RecurrenceRule', is => 'rw', coerce => 1);
19              
20             =head1 NAME
21              
22             Bb::Collaborate::Ultra::Session
23              
24             =head1 DESCRIPTION
25              
26             This class is used to manage Sessions (Virtual Classrooms).
27              
28             use Bb::Collaborate::Ultra::Session;
29             my $start = time() + 60;
30             my $end = $start + 900;
31              
32             my $session;
33             my $session = Bb::Collaborate::Ultra::Session->post($connection, {
34             name => 'Test Session',
35             startTime => $start,
36             endTime => $end,
37             },
38             );
39              
40             =head2 Enrolling User in Sessions
41              
42             AFAIK, there are two classes and two different modes for enrolling user to sessions:
43              
44             =over 4
45              
46             =item (*) Ad-hoc users via L
47              
48             my $user = Bb::Collaborate::Ultra::User->new({
49             extId => 'testLaunchUser',
50             displayName => 'David Warring',
51             email => 'david.warring@gmail.com',
52             firstName => 'David',
53             lastName => 'Warring',
54             });
55              
56             my $launch_context = Bb::Collaborate::Ultra::LaunchContext->new({ launchingRole => 'moderator',
57             editingPermission => 'writer',
58             user => $user,
59             });
60              
61             my $join_url = $launch_context->join_session($session);
62              
63             =item (*) Permanently managed users via L
64              
65             Each user is created once.
66              
67             my $ultra_user = Bb::Collaborate::Ultra::User->create($connection, {
68             extId => 'testLaunchUser',
69             displayName => 'David Warring',
70             email => 'david.warring@gmail.com',
71             firstName => 'David',
72             lastName => 'Warring',
73             });
74             my $ultra_user_id = $ultra_user->id;
75             # somehow save the user id permanently...
76              
77             The saved user-id may then be used to multiple times to join sessions:
78              
79             my $enrollment = Bb::Collaborate::Ultra::Session::Enrollment->new({ launchingRole => 'moderator',
80             editingPermission => 'writer',
81             userId => $user2->id,
82             });
83             my $join_url = $enrolment->enrol($session)->permanentUrl;
84              
85             =back
86              
87             =head1 METHODS
88              
89             This class supports the `get`, `post`, `patch` and `del` methods as described in L
90              
91             =cut
92              
93             sub _thaw {
94 2     2   656 my $self = shift;
95 2         3 my $data = shift;
96 2         8 my $thawed = $self->SUPER::_thaw($data, @_);
97 2         3 my $occurrences = $data->{occurrences};
98 2 50       6 $thawed->{occurrences} = [ map { Bb::Collaborate::Ultra::Session::Occurrence->_thaw($_) } (@$occurrences) ]
  2         10  
99             if $occurrences;
100 2         4 $thawed;
101             }
102              
103             __PACKAGE__->resource('sessions');
104             __PACKAGE__->load_schema();
105             __PACKAGE__->query_params(
106             name => 'Str',
107             userId => 'Str',
108             contextId => 'Str',
109             startTime => 'Date',
110             endTime => 'Date',
111             sessionCategory => 'Str',
112             );
113              
114             =head2 get_enrollments
115              
116             Return a list of users, of type L.
117              
118             my @enrollments = $session->get_enrollments;
119             for my $enrolment (@enrollments) {
120             say "user @{[$enrolment->userId]} is enrolled as a @{[$enrollment->launchingRole]}";
121             }
122              
123             =cut
124              
125             sub get_enrollments {
126 0     0 1   my $self = shift;
127 0   0       my $query = shift || {};
128 0           my %opt = @_;
129 0   0       my $connection = $opt{connection} || $self->connection;
130 0           my $path = $self->path.'/enrollments';
131 0           require Bb::Collaborate::Ultra::Session::Enrollment;
132 0           Bb::Collaborate::Ultra::Session::Enrollment->get($connection, $query, path => $path, parent => $self);
133             }
134              
135             =head2 get_logs
136              
137             Returns logging (session-instance) information for completed sessions
138              
139             =cut
140              
141             sub get_logs {
142 0     0 1   my $self = shift;
143 0   0       my $query = shift || {};
144 0           my %opt = @_;
145 0   0       my $connection = $opt{connection} || $self->connection;
146 0           my $path = $self->path.'/instances';
147 0           require Bb::Collaborate::Ultra::Session::Log;
148 0           Bb::Collaborate::Ultra::Session::Log->get($connection, $query, path => $path, parent => $self);
149             }
150              
151             1;
152             # downloaded from https://xx-csa.bbcollab.com/documentation
153             __DATA__