| 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 | sub _thaw { | ||||||||||||||||||||
| 94 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_thaw: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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 enrollments | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | Return a list of users, of type L<Bb::Collaborate::Ultra::Session::Enrollment>. | ||||||||||||||||||||
| 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 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
enrollments: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 127 | 0 | my $data = shift; | |||||||||||||||||||
| 128 | 0 | ▶ | my $connection = shift || $self->connection; | ||||||||||||||||||
|
Condition0%0/3
shift() || $self->connection
MC/DC0%0/2
shift() || $self->connection
shift()
$self->connection
Truth table0%0/3
A || B
A= shift()B= $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 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
logs: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 142 | 0 | ▶ | my $connection = shift || $self->connection; | ||||||||||||||||||
|
Condition0%0/3
shift() || $self->connection
MC/DC0%0/2
shift() || $self->connection
shift()
$self->connection
Truth table0%0/3
A || B
A= shift()B= $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 | 4 | 1; | |||||||||||||||||||
| 149 | # downloaded from https://xx-csa.bbcollab.com/documentation | ||||||||||||||||||||
| 150 | __DATA__ | ||||||||||||||||||||