File Coverage

blib/lib/Bb/Collaborate/Ultra/Session.pm
Criterion Covered Total %
statement 25 36 69.4
branch 1 2 50.0
condition 0 6 0.0
subroutine 7 9 77.7
pod 2 2 100.0
total 35 55 63.6


line stmt bran cond sub pod time code
1             package Bb::Collaborate::Ultra::Session;
2 3     3   51803 use warnings; use strict;
  3     3   4  
  3         82  
  3         802  
  3         4  
  3         56  
3 3     3   1172 use Mouse;
  3         59138  
  3         12  
4             extends 'Bb::Collaborate::Ultra::DAO';
5              
6 3     3   2419 use Bb::Collaborate::Ultra::Session::Occurrence;
  3         6  
  3         93  
7 3     3   1291 use Bb::Collaborate::Ultra::Session::RecurrenceRule;
  3         7  
  3         89  
8 3     3   16 use Mouse::Util::TypeConstraints;
  3         3  
  3         14  
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   486 my $self = shift;
95 2         4 my $data = shift;
96 2         13 my $thawed = $self->SUPER::_thaw($data, @_);
97 2         4 my $occurrences = $data->{occurrences};
98 2 50       9 $thawed->{occurrences} = [ map { Bb::Collaborate::Ultra::Session::Occurrence->_thaw($_) } (@$occurrences) ]
  2         14  
99             if $occurrences;
100 2         5 $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 enrollments
115              
116             Return a list of users, of type L.
117              
118             my @enrollments = $session->enrollments;
119             for my $enrolment (@enrollments) {
120             say "user @{[$enrolment->userId]} is enrolled as a @{[$enrollment->launchingRole]}";
121             }
122              
123             =cut
124              
125             sub enrollments {
126 0     0 1   my $self = shift;
127 0           my $data = shift;
128 0   0       my $connection = shift || $self->connection;
129 0           my $path = $self->path.'/enrollments';
130 0           require Bb::Collaborate::Ultra::Session::Enrollment;
131 0           Bb::Collaborate::Ultra::Session::Enrollment->get($connection => {}, path => $path, parent => $self);
132             }
133              
134             =head2 logs
135              
136             Returns logging information for completed sessions
137              
138             =cut
139              
140             sub logs {
141 0     0 1   my $self = shift;
142 0   0       my $connection = shift || $self->connection;
143 0           my $path = $self->path.'/instances';
144 0           require Bb::Collaborate::Ultra::Session::Log;
145 0           Bb::Collaborate::Ultra::Session::Log->get($connection => {}, path => $path, parent => $self);
146             }
147              
148             1;
149             # downloaded from https://xx-csa.bbcollab.com/documentation
150             __DATA__