lib/Bb/Collaborate/Ultra/Session.pm

filter: Statementstmt 72.0% 36 / 50 Branchbran 50.0% 1 / 2 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.0% 8 / 10 Podpod 100% 2 / 2 totaltotal 58.7% 47 / 80 CC 6 SCAR 17.1
CC
6
Cov
60%
get_enrollments
12.0
get_logs
12.0
_thaw
2.0
CRAP 5.5
« lib/Bb/Collaborate/Ultra/LaunchContext.pm ↑ Summary lib/Bb/Collaborate/Ultra/Recording.pm »
1 package Bb::Collaborate::Ultra::Session;
2 4 ▶use warnings; use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 extends 'Bb::Collaborate::Ultra::DAO';
5  
6 4 ▶use Bb::Collaborate::Ultra::Session::Occurrence;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Bb::Collaborate::Ultra::Session::RecurrenceRule;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Mouse::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 subtype 'ArrayOfOccurrences',
11 as 'ArrayRef[Bb::Collaborate::Ultra::Session::Occurrence]';
12  
13 coerce 'ArrayOfOccurrences',
14 from 'ArrayRef[HashRef]',
15 3 ▶ via { [ map {Bb::Collaborate::Ultra::Session::Occurrence->new($_)} (@$_) ] };
Subroutine __ANON__: called CC=1 SCAR=0.0
16  
17 4 has 'occurrences' => (isa => 'ArrayOfOccurrences', is => 'rw', coerce => 1);
18 4 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<Bb::Collaborate::Ultra::LaunchContext>
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<Bb::Collaborate::Ultra::LaunchContext>
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<https://xx-csa.bbcollab.com/documentation#Session>
90  
91 =cut
92  
93 2 ▶sub _thaw {
Subroutine _thaw: called CC=2 SCAR=7.0
94 2 my $self = shift;
95 2 my $data = shift;
96 2 my $thawed = $self->SUPER::_thaw($data, @_);
97 2 my $occurrences = $data->{occurrences};
98 2 ▶ $thawed->{occurrences} = [ map { Bb::Collaborate::Ultra::Session::Occurrence->_thaw($_) } (@$occurrences) ]
Branch: 1 branch
BranchTrueFalseTotal
if $occurrences 2 0 2
99 if $occurrences;
100 2 $thawed;
101 }
102  
103 4 __PACKAGE__->resource('sessions');
104 4 __PACKAGE__->load_schema(<DATA>);
105 4 __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<Bb::Collaborate::Ultra::Session::Enrollment>.
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 0 ▶sub get_enrollments {
Subroutine get_enrollments: not called CC=3 SCAR=24.8
Pod documented
126 0 my $self = shift;
127 0 ▶ my $query = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
128 0 my %opt = @_;
129 0 ▶ my $connection = $opt{connection} || $self->connection;
Condition0%0/3
$opt{'connection'} || $self->connection
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt{'connection'} || $self->connection
$opt{'connection'} $self->connection
Truth table0%0/3
A || B
A= $opt{'connection'}B= $self->connection
ABresult
1X1
011
000
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 0 ▶sub get_logs {
Subroutine get_logs: not called CC=3 SCAR=24.8
Pod documented
142 0 my $self = shift;
143 0 ▶ my $query = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
144 0 my %opt = @_;
145 0 ▶ my $connection = $opt{connection} || $self->connection;
Condition0%0/3
$opt{'connection'} || $self->connection
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt{'connection'} || $self->connection
$opt{'connection'} $self->connection
Truth table0%0/3
A || B
A= $opt{'connection'}B= $self->connection
ABresult
1X1
011
000
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 4 1;
152 # downloaded from https://xx-csa.bbcollab.com/documentation
153 __DATA__
« lib/Bb/Collaborate/Ultra/LaunchContext.pm ↑ Summary lib/Bb/Collaborate/Ultra/Recording.pm »