diff --git a/CHANGES.txt b/CHANGES.txt index 026a1dc0..46273919 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 2967f045..2d518af8 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -74,6 +74,14 @@ 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) { @@ -81,6 +89,21 @@ public function display_usage_report($usagedata){ $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; @@ -119,27 +142,44 @@ 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( @@ -147,6 +187,7 @@ public function display_usage_report($usagedata){ 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 = []; diff --git a/filter.php b/filter.php index 82a1d242..d97f848f 100644 --- a/filter.php +++ b/filter.php @@ -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) { diff --git a/lang/en/filter_poodll.php b/lang/en/filter_poodll.php index b9b8bf42..71d0d16e 100644 --- a/lang/en/filter_poodll.php +++ b/lang/en/filter_poodll.php @@ -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"; diff --git a/templates/mysubscriptionreport.mustache b/templates/mysubscriptionreport.mustache index c6a4fecd..7be99e76 100644 --- a/templates/mysubscriptionreport.mustache +++ b/templates/mysubscriptionreport.mustache @@ -4,7 +4,7 @@ {{#str}}subscription,filter_poodll{{/str}} {{#str}}start,filter_poodll{{/str}} - {{#str}}end,filter_poodll{{/str}} + {{#str}}end,filter_poodll{{/str}} @@ -12,7 +12,7 @@ {{name}} {{start_date}} - {{end_date}} + {{end_date}} {{/subscriptions}} @@ -22,6 +22,7 @@ {{#str}}ninety_days,filter_poodll{{/str}} {{#str}}oneeighty_days,filter_poodll{{/str}} {{#str}}threehundredsixtyfive_days,filter_poodll{{/str}} + {{#str}}maxmonth,filter_poodll{{/str}} diff --git a/version.php b/version.php index f9741213..88021fa9 100644 --- a/version.php +++ b/version.php @@ -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)';