MDL-33822 SCORM Interactions report - fix formatting of empty cells.
authorGilles-Philippe Leblanc <gilles-philippe.leblanc@umontreal.ca>
Thu, 5 Jul 2012 21:41:19 +0000 (09:41 +1200)
committerSam Hemelryk <sam@moodle.com>
Mon, 9 Jul 2012 05:24:29 +0000 (17:24 +1200)
mod/scorm/report/interactions/report.php

index 99204d1..d9152d1 100644 (file)
@@ -185,6 +185,7 @@ class scorm_interactions_report extends scorm_default_report {
             $countsql .= $from.$where;
             $attempts = $DB->get_records_sql($select.$from.$where, $params);
             $questioncount = get_scorm_question_count($scorm->id);
+            $nbmaincolumns = count($columns);
             for($id = 0; $id < $questioncount; $id++) {
                 if ($displayoptions['qtext']) {
                     $columns[] = 'question' . $id;
@@ -476,9 +477,7 @@ class scorm_interactions_report extends scorm_default_report {
                                     $row[] = $score;
                                 }
                                 // interaction data
-                                $i=0;
-                                $element='cmi.interactions_'.$i.'.id';
-                                while(isset($trackdata->$element)) {
+                                for ($i=0; $i < $questioncount; $i++) {
                                     if ($displayoptions['qtext']) {
                                         $element='cmi.interactions_'.$i.'.id';
                                         if (isset($trackdata->$element)) {
@@ -513,8 +512,6 @@ class scorm_interactions_report extends scorm_default_report {
                                             $row[] = '&nbsp;';
                                         }
                                     }
-                                    $i++;
-                                    $element = 'cmi.interactions_'.$i.'.id';
                                 }
                             //---end of interaction data*/
                             } else {
@@ -525,6 +522,10 @@ class scorm_interactions_report extends scorm_default_report {
                                 } else {
                                     $row[] = $strstatus;
                                 }
+                                // complete the empty cells
+                                for ($i=0; $i < count($columns) - $nbmaincolumns; $i++) {
+                                    $row[] = '&nbsp;';
+                                }
                             }
                         }
                     }