script/bb-collab-session-log.pl untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 105 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use 5.10.1;
2 use warnings; use strict;
3 use Bb::Collaborate::Ultra;
4 use Bb::Collaborate::Ultra::Connection;
5 use Bb::Collaborate::Ultra::Session;
6 use Getopt::Long;
7 use Pod::Usage;
8  
9 =head1 NAME
10  
11 bb-collab-session-log - session log report for Blackboard Collaborate Ultra
12  
13 =head1 SYNOPSIS
14  
15 bb-collab-session-log --host=URL --issuer=USER --secret=PASS [query-opts]
16  
17 =head2 Authentication Options
18  
19 -h --host=<url> # hostname or web address
20 -u --issuer=<username> # issuer/username
21 -p --secret=<password> # secret/password
22  
23 =head2 Query Options
24  
25 --name=<session-name> # filter by session name
26 --session-id=<Id> # filter by session ID
27 --context-id=<Id> # filter by context ID
28 --user-id=<Id> # filter by user ID (select only
29 # sessions attended by this user_/
30  
31 =head2 Information
32  
33 -? --help # print this help
34 -v --version # print version and exit
35 --dump=yaml # output created sessions as YAML
36 --debug # enable debugging
37  
38 =head1 DESCRIPTION
39  
40 Creates meetings on an Elluminate I<Live!> Manager (ELM) server.
41  
42 =head1 SEE ALSO
43  
44 perldoc Bb::Collaborate::Ultra
45  
46 https://metacpan.org/release/Bb-Collaborate-Ultra
47  
48  
49 =cut
50  
51 my %opt;
52 my $ok = GetOptions(
53 \%opt,
54 'host|h=s',
55 'issuer|username|u=s',
56 'secret|password|p=s',
57 'contextId|context-id=s',
58 'sessionId|session-id=s',
59 'userId|user-id=s',
60 'name=s',
61 'debug|d',
62 'help|h|?',
63 'version|v',
64 );
65  
66 my $host = delete $opt{host};
67 my $issuer = delete $opt{issuer};
68 my $secret = delete $opt{secret};
69 my $debug = delete $opt{debug};
70 my $help = delete $opt{help};
71 my $version = delete $opt{version};
72  
73 pod2usage(0) if $help;
74  
75 if ($version) {
76 print "Bb::Collaborate::Ultra v${Bb::Collaborate::Ultra::VERSION} (c) 2017\n";
77 exit(0);
78 };
79  
80 pod2usage(2)
81 unless $ok && $host && $issuer && $secret;
82  
83 my $connection = Bb::Collaborate::Ultra::Connection->new({
84 host => $host, issuer => $issuer, secret => $secret,
85 });
86  
87 $connection->debug(1) if $debug;
88  
89 my $context_id = "6812E6A3EA4072D1425FA583BF59C5CD";
90 my @sessions = Bb::Collaborate::Ultra::Session->get($connection, \%opt);
91 for my $session (@sessions) {
92 my @logs = $session->logs;
93 if (@logs) {
94 say "Session: ". $session->name;
95 }
96 for my $log (@logs) {
97 say "\tOpened: " .(scalar localtime $log->opened);
98 for my $attendee ($log->attendees) {
99 my $first_join;
100 my $elapsed = 0;
101 for my $attendance (@{$attendee->attendance}) {
102 my $joined = $attendance->joined;
103 $first_join = $joined
104 if !$first_join || $first_join > $joined;
105 $elapsed += $attendance->left - $joined;
106 }
107 my $user_id = $attendee->externalUserId || $attendee->userId;
108 say sprintf("\tUser %s (%s) joined at %s, stayed %d minutes", $user_id, $attendee->displayName, (scalar localtime $first_join), $elapsed / 60);
109 if ($elapsed) {
110 }
111 }
112 say "\tClosed: " .(scalar localtime $log->closed);
113 }
114 }