Skip to content

Commit

Permalink
added highet month to usage report
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhunt committed Mar 24, 2022
1 parent 709c428 commit f4cbc2a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change List
=========
Version 3.1.52 (Build 2022032400)
- added custom course fields to filter variables
- added highest month to usage report

Version 3.1.51 (Build 2021122200)
- added some more modern diagnostics
- moved recorder order and some player settings from general to legacy
Expand Down
47 changes: 44 additions & 3 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,36 @@ public function display_usage_report($usagedata){
$ninety_puser = 0;
$thirty_puser = 0;

//monthlymax
$monthusertotals=[0,0,0,0,0,0,0,0,0,0,0,0];
$monthpusers=['','','','','','','','','','','',''];
$monthminutetotals=[0,0,0,0,0,0,0,0,0,0,0,0];
$monthrecordtotals=[0,0,0,0,0,0,0,0,0,0,0,0];
$monthaudiototals=[0,0,0,0,0,0,0,0,0,0,0,0];
$monthvideototals=[0,0,0,0,0,0,0,0,0,0,0,0];

$plugin_types_arr = "[";

if($usagedata->usersubs_details) {
foreach ($usagedata->usersubs_details as $subdatadetails) {

$timecreated = $subdatadetails->timecreated;


for($x=0;$x<12;$x++){
$upperdays=-1 * $x * 30 . ' days';
$lowerdays=-1 * ($x+1) * 30 . ' days';
if (($timecreated <= strtotime($upperdays)) && ($timecreated > strtotime($lowerdays) )) {
$monthminutetotals[$x] = $monthminutetotals[$x] + ($subdatadetails->audio_min + $subdatadetails->video_min);
$monthaudiototals[$x] = $monthaudiototals[$x] + $subdatadetails->audio_file_count;
$monthvideototals[$x] = $monthvideototals[$x] + $subdatadetails->video_file_count;
$monthrecordtotals[$x] = $monthrecordtotals[$x] + $subdatadetails->video_file_count + $subdatadetails->audio_file_count;
$monthvideototals[$x] = $monthvideototals[$x] + $subdatadetails->video_min;
$monthpusers[$x] = $monthpusers[$x] .= $subdatadetails->pusers;

}
}

//if(($timecreated > strtotime('-180 days'))&&($timecreated <= strtotime('-365 days'))) {
if (($timecreated >= strtotime('-365 days'))) {
$threesixtyfive_recordtype_video += $subdatadetails->video_file_count;
Expand Down Expand Up @@ -119,34 +142,52 @@ public function display_usage_report($usagedata){
}//end of for loop
}//end of if usagedata

//calc max month totals
$maxmonth_pusers = 0;
$maxmonth_minutes = 0;
$maxmonth_audio = 0;
$maxmonth_video = 0;
$maxmonth_recordings = 0;
for($x=0;$x<12;$x++){
$monthusertotals[$x]=$this->count_pusers($monthpusers[$x]);
if($maxmonth_pusers<$monthusertotals[$x]){$maxmonth_pusers=$monthusertotals[$x];}
if($maxmonth_minutes<$monthminutetotals[$x]){$maxmonth_minutes=$monthminutetotals[$x];}
if($maxmonth_audio<$monthaudiototals[$x]){$maxmonth_audio=$monthaudiototals[$x];}
if($maxmonth_video<$monthvideototals[$x]){$maxmonth_video=$monthvideototals[$x];}
if($maxmonth_recordings<$monthrecordtotals[$x]){$maxmonth_recordings=$monthrecordtotals[$x];}
}

//calculate report summaries
$reportdata['pusers']=array_values(array(
array('name'=>'30','value'=>$this->count_pusers($thirty_puser)),
array('name'=>'90','value'=>$this->count_pusers($ninety_puser)),
array('name'=>'180','value'=>$this->count_pusers($oneeighty_puser)),
array('name'=>'365','value'=>$this->count_pusers($threesixtyfive_puser))
array('name'=>'365','value'=>$this->count_pusers($threesixtyfive_puser)),
array('name'=>'maxmonth','value'=>$maxmonth_pusers)
));

$reportdata['record']=array_values(array(
array('name'=>'30','value'=>$thirty_record),
array('name'=>'90','value'=>$ninety_record),
array('name'=>'180','value'=>$oneeighty_record),
array('name'=>'365','value'=>$threesixtyfive_record)
array('name'=>'365','value'=>$threesixtyfive_record),
array('name'=>'maxmonth','value'=>$maxmonth_recordings)
));

$reportdata['recordmin']=array_values(array(
array('name'=>'30','value'=>$thirty_recordmin),
array('name'=>'90','value'=>$ninety_recordmin),
array('name'=>'180','value'=>$oneeighty_recordmin),
array('name'=>'365','value'=>$threesixtyfive_recordmin)
array('name'=>'365','value'=>$threesixtyfive_recordmin),
array('name'=>'maxmonth','value'=>$maxmonth_minutes)
));

$reportdata['recordtype']=array_values(array(
array('name'=>'30','video'=>$thirty_recordtype_video,'audio'=>$thirty_recordtype_audio),
array('name'=>'90','video'=>$ninety_recordtype_video,'audio'=>$ninety_recordtype_audio),
array('name'=>'180','video'=>$oneeighty_recordtype_video,'audio'=>$oneeighty_recordtype_audio),
array('name'=>'365','video'=>$threesixtyfive_recordtype_video,'audio'=>$threesixtyfive_recordtype_audio),
array('name'=>'maxmonth','video'=>$maxmonth_video,'audio'=>$maxmonth_audio),
));

$plugin_types_arr = [];
Expand Down
12 changes: 12 additions & 0 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,18 @@ function filter_poodll_process(array $link, $ext = false) {
if (strpos($poodlltemplate . ' ' . $dataset_vars . ' ' . $alternate_content . ' ' . $js_custom_script, '@@COURSE:') !==
false) {
$coursevars = get_object_vars($COURSE);
//custom fields
if(class_exists('\core_customfield\handler')) {
$handler = \core_customfield\handler::get_handler('core_course', 'course');
$customfields = $handler->get_instance_data($filterprops['courseid']);
foreach ($customfields as $customfield) {
if (empty($customfield->get_value())) {
continue;
}
$shortname = $customfield->get_field()->get('shortname');
$coursevars[$shortname] = $customfield->get_value();
}
}
$coursepropstubs = explode('@@COURSE:', $poodlltemplate);
$d_stubs = explode('@@COURSE:', $dataset_vars);
if ($d_stubs) {
Expand Down
1 change: 1 addition & 0 deletions lang/en/filter_poodll.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,4 @@
$string['memberdashboard'] = "Member Dashboard";
$string['memberdashboard_desc'] = "";
$string['fillcredentials']="Set API user and secret with existing credentials";
$string['maxmonth']="Highest Month";
5 changes: 3 additions & 2 deletions templates/mysubscriptionreport.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<tr>
<th scope="col">{{#str}}subscription,filter_poodll{{/str}}</th>
<th scope="col" colspan=2>{{#str}}start,filter_poodll{{/str}}</th>
<th scope="col" colspan=2>{{#str}}end,filter_poodll{{/str}}</th>
<th scope="col" colspan=3>{{#str}}end,filter_poodll{{/str}}</th>
</tr>
</thead>
<tbody>
{{#subscriptions}}
<tr>
<td>{{name}}</td>
<td colspan=2>{{start_date}}</td>
<td colspan=2>{{end_date}}</td>
<td colspan=3>{{end_date}}</td>
</tr>
{{/subscriptions}}

Expand All @@ -22,6 +22,7 @@
<th scope="col">{{#str}}ninety_days,filter_poodll{{/str}}</th>
<th scope="col">{{#str}}oneeighty_days,filter_poodll{{/str}}</th>
<th scope="col">{{#str}}threehundredsixtyfive_days,filter_poodll{{/str}}</th>
<th scope="col">{{#str}}maxmonth,filter_poodll{{/str}}</th>
</tr>

<tr>
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021122200;
$plugin->version = 2022032400;
$plugin->requires = 2016052300;//moodle 3.1.0
$plugin->component = 'filter_poodll';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '3.1.51 (Build 2021122200)';
$plugin->release = '3.1.52 (Build 2022032400)';

0 comments on commit f4cbc2a

Please sign in to comment.