MDL-45712 mod_scorm: add results column to interactions report.
authorHagey, Nathanial <NHagey@vscat.com>
Wed, 21 Oct 2015 20:04:38 +0000 (16:04 -0400)
committerDan Marsden <dan@danmarsden.com>
Wed, 16 Dec 2015 00:30:50 +0000 (13:30 +1300)
mod/scorm/report/interactions/classes/report.php
mod/scorm/report/interactions/lang/en/scormreport_interactions.php
mod/scorm/report/interactions/responsessettings_form.php
mod/scorm/report/interactions/version.php

index 2aee588..7af4050 100644 (file)
@@ -59,15 +59,18 @@ class report extends \mod_scorm\report {
             $includeqtext = $fromform->qtext;
             $includeresp = $fromform->resp;
             $includeright = $fromform->right;
+            $includeresult = $fromform->result;
             set_user_preference('scorm_report_pagesize', $pagesize);
             set_user_preference('scorm_report_interactions_qtext', $includeqtext);
             set_user_preference('scorm_report_interactions_resp', $includeresp);
             set_user_preference('scorm_report_interactions_right', $includeright);
+            set_user_preference('scorm_report_interactions_result', $includeresult);
         } else {
             $pagesize = get_user_preferences('scorm_report_pagesize', 0);
             $includeqtext = get_user_preferences('scorm_report_interactions_qtext', 0);
             $includeresp = get_user_preferences('scorm_report_interactions_resp', 1);
             $includeright = get_user_preferences('scorm_report_interactions_right', 0);
+            $includeresult = get_user_preferences('scorm_report_interactions_result', 0);
         }
         if ($pagesize < 1) {
             $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
@@ -79,6 +82,7 @@ class report extends \mod_scorm\report {
         $displayoptions['qtext'] = $includeqtext;
         $displayoptions['resp'] = $includeresp;
         $displayoptions['right'] = $includeright;
+        $displayoptions['result'] = $includeresult;
 
         $mform->set_data($displayoptions + array('pagesize' => $pagesize));
         if ($groupmode = groups_get_activity_groupmode($cm)) {   // Groups are being used.
@@ -204,6 +208,10 @@ class report extends \mod_scorm\report {
                     $columns[] = 'right' . $id;
                     $headers[] = get_string('rightanswerx', 'scormreport_interactions', $id);
                 }
+                if ($displayoptions['result']) {
+                    $columns[] = 'result' . $id;
+                    $headers[] = get_string('resultx', 'scormreport_interactions', $id);
+                }
             }
 
             if (!$download) {
@@ -239,6 +247,9 @@ class report extends \mod_scorm\report {
                     if ($displayoptions['right']) {
                         $table->no_sorting('right'.$id);
                     }
+                    if ($displayoptions['result']) {
+                        $table->no_sorting('result'.$id);
+                    }
                 }
 
                 foreach ($scoes as $sco) {
@@ -526,6 +537,14 @@ class report extends \mod_scorm\report {
                                             $row[] = '&nbsp;';
                                         }
                                     }
+                                    if ($displayoptions['result']) {
+                                        $element = 'cmi.interactions_'.$i.'.result';
+                                        if (isset($trackdata->$element)) {
+                                            $row[] = s($trackdata->$element);
+                                        } else {
+                                            $row[] = '&nbsp;';
+                                        }
+                                    }
                                 }
                                 // End of interaction data.
                             } else {
index eb3d7ff..ed66f59 100644 (file)
@@ -29,7 +29,9 @@ $string['pluginname'] = 'Interactions report';
 $string['questionx'] = 'Question {$a}';
 $string['responsex'] = 'Response {$a}';
 $string['rightanswerx'] = 'Right answer {$a}';
+$string['resultx'] = 'Result {$a}';
 $string['summaryofquestiontext'] = 'Summary of question';
 $string['summaryofresponse'] = 'Summary of responses';
 $string['summaryofrightanswer'] = 'Summary of right answer';
+$string['summaryofresult'] = 'Summary of result';
 
index 1c145b4..0bc319b 100644 (file)
@@ -43,6 +43,7 @@ class mod_scorm_report_interactions_settings extends moodleform {
         $mform->addElement('advcheckbox', 'qtext', '', get_string('summaryofquestiontext', 'scormreport_interactions'));
         $mform->addElement('advcheckbox', 'resp', '', get_string('summaryofresponse', 'scormreport_interactions'));
         $mform->addElement('advcheckbox', 'right', '', get_string('summaryofrightanswer', 'scormreport_interactions'));
+        $mform->addElement('advcheckbox', 'result', '', get_string('summaryofresult', 'scormreport_interactions'));
 
         // -------------------------------------------------------------------------------
         $mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'scorm'));
index 945570a..f5691ca 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2015111600;                 // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2015121600;                 // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2015111000;                 // Requires this Moodle version.
 $plugin->component = 'scormreport_interactions'; // Full name of the plugin (used for diagnostics).