Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

*** empty log message ***

  • Loading branch information...
commit 21e98e21c93c89dfaedc612e2c643ba90c55641a 1 parent 2185622
authored November 21, 2003

Showing 1 changed file with 408 additions and 386 deletions. Show diff stats Hide diff stats

  1. 794  mod/quiz/report/fullstat/report.php
794  mod/quiz/report/fullstat/report.php
@@ -9,10 +9,35 @@ class quiz_report extends quiz_default_report {
9 9
     function display($quiz, $cm, $course) {     /// This function just displays the report
10 10
 
11 11
     global $CFG;
12  
-    global $download, $quests,$qtally,$table_colcount,$max_choices, $analysis,$qs_in_order,$total_user_count,$match_number,$thismin,$thismax,$myxls,$match_qs,$formatbc,$workbook;
  12
+    global $download, $quests,$qtally,$table_colcount,$max_choices, $analysis,$qs_in_order,$total_user_count,$match_number, $thismin,$thismax,$myxls,$match_qs,$formatbc,$workbook,$strquestion;
13 13
     optional_variable($download, "");
14 14
 //$debug = 1;
15 15
 
  16
+/*
  17
+//These definitions must be in the lang/en/quiz.php file
  18
+$string['qr_indivresp'] = "Responses of Individuals to Each Item";
  19
+$string['qr_name'] = "Name";
  20
+$string['qr_grade'] = "Grade";
  21
+$string['qr_itemanal'] = "Item Response Analysis";
  22
+$string['qr_corrresp'] = "Correct Response";
  23
+$string['qr_noresponse'] = "No Response";
  24
+$string['qr_percentcorrect'] = "Percent Correct";
  25
+$string['qr_listitems'] = "Listing of Items in This Quiz";
  26
+$string['qr_question'] = "Question";
  27
+$string[''] = "";
  28
+*/
  29
+
  30
+        $strindivresp = get_string("qr_indivresp", "quiz");
  31
+        $strname = get_string("qr_name", "quiz");
  32
+        $strgrade = get_string("qr_grade", "quiz");
  33
+        $stritemanal = get_string("qr_itemanal", "quiz");
  34
+        $strcorrresp = get_string("qr_corrresp", "quiz");
  35
+        $strnoresponse = get_string("qr_noresponse", "quiz");
  36
+        $strpercentcorrect = get_string("qr_percentcorrect", "quiz");
  37
+        $strlistitems = get_string("qr_listitems", "quiz");
  38
+        $strquestion = get_string("qr_question", "quiz");
  39
+//        $str = get_string("qr_", "quiz");
  40
+
16 41
     //Get the question ids
17 42
     $thisquizid = $quiz->id;
18 43
     $qs_in_order =qr_getqs($thisquizid);
@@ -27,7 +52,7 @@ function display($quiz, $cm, $course) {     /// This function just displays the
27 52
             $quests[$qid]["qtype"] =  $thiskey;
28 53
             $quests[$qid]["qtext"] =  $question_data[$thiskey]->questiontext;
29 54
         }
30  
-        if($quests[$qid][qtype] == 5){
  55
+        if($quests[$qid]['qtype'] == 5){
31 56
             //for MATCH items we need to know how many items there are
32 57
             $thismatch = get_record("quiz_match","question","$qid");
33 58
             $temparray = explode(",",$thismatch->subquestions);
@@ -36,14 +61,14 @@ function display($quiz, $cm, $course) {     /// This function just displays the
36 61
             $table_colcount = $table_colcount + $match_number[$qid] - 1;
37 62
         }
38 63
         $choice_data = get_records_select("quiz_answers",$select="question='$qid'","","id as cid,answer,fraction");
39  
-        if($quests[$qid][qtype] == 8){
  64
+        if($quests[$qid]['qtype'] == 8){
40 65
               $thismin[$qid] = get_field("quiz_numerical","min","question","$qid");
41 66
               $thismax[$qid] = get_field("quiz_numerical","max","question","$qid");
42 67
               $quests[$qid]["correct"] = $thismin[$qid] ."< $choice_data->answer >" .  $thismax[$qid];
43 68
         }
44  
-        if($quests[$qid][qtype] >3) {continue;}
  69
+        if($quests[$qid]['qtype'] >3) {continue;}
45 70
         //only get choices here if type is SHORTANSWER,TRUEFALSE or MULTICHOICE
46  
-        //Get the choices for each question and add to object[choice] each choicd ID and text
  71
+        //Get the choices for each question and add to object['choice'] each choicd ID and text
47 72
         $choice_count=0;
48 73
         foreach($choice_data as $thiscid=>$thischoice){
49 74
             $choice_count++;
@@ -55,7 +80,7 @@ function display($quiz, $cm, $course) {     /// This function just displays the
55 80
                 if($quests[$qid]["correct"]){
56 81
                     $quests[$qid]["correct"] .= "," . $thischoice->answer;
57 82
                 } else {
58  
-                    if($quests[$qid][qtype] == 3) {
  83
+                    if($quests[$qid]['qtype'] == 3) {
59 84
                         $quests[$qid]["correct"] = $choice_count;
60 85
                     } else {
61 86
                         $quests[$qid]["correct"] = $thischoice->answer;
@@ -64,37 +89,37 @@ function display($quiz, $cm, $course) {     /// This function just displays the
64 89
             }
65 90
          }
66 91
     }
67  
-if($debug and !$download){
68  
-print("<h3>Quests</h3>");
69  
-print_object($quests);
70  
-}
  92
+    if($debug and !$download){
  93
+        print("<h3>Quests</h3>");
  94
+        print_object($quests);
  95
+    }
71 96
     $user_resps = qr_quiz_responses($thisquizid);
72 97
 //    //print_object($user_resps);
73 98
     foreach($user_resps as $thiskey => $thisresp){
74 99
         $userdata[$thisresp->userid][$thisresp->attemptno]['response'][$thisresp->question]=$thisresp->answer;
75 100
         $userdata[$thisresp->userid][$thisresp->attemptno]['grade']=$thisresp->sumgrades;
76 101
         $userdata[$thisresp->userid][$thisresp->attemptno]['name']=$thisresp->lastname .  ", " . $thisresp->firstname;
77  
-        $userdata[$thisresp->userid][$thisresp->attemptno][attemptid]=$thisresp->aid;
  102
+        $userdata[$thisresp->userid][$thisresp->attemptno]['attemptid']=$thisresp->aid;
  103
+    }
  104
+    if($debug and !$download){
  105
+    print("<h3>User Data</h3>");
  106
+    print_object($userdata);
78 107
     }
79  
-if($debug and !$download){
80  
-print("<h3>User Data</h3>");
81  
-print_object($userdata);
82  
-}
83 108
     //now go through $userdata and create tally by user, attempt, question storing both response and if correct
84 109
     $reportline = 0;
85 110
     foreach($userdata as $thisuser){
86 111
         foreach($thisuser as $thiskey=>$thisattempt){
87 112
 //            //print_object($thisattempt);
88 113
             $reportline++;
89  
-            $data_tally[$reportline][$thisattempt[attemptid]][] = $thisattempt[name];
90  
-            $data_tally[$reportline][$thisattempt[attemptid]][] = $thisattempt[grade]; //raw grade needs to be divided by total grades possible
  114
+            $data_tally[$reportline][$thisattempt['attemptid']][] = $thisattempt['name'];
  115
+            $data_tally[$reportline][$thisattempt['attemptid']][] =round(($thisattempt['grade']/$quiz->sumgrades)*100,0); 
91 116
             //now for each question, record response as it should be printed and whether right, wrong or skipped
92 117
             //SHORTASNSWER the answer as in $userdata; TF or MULTI need response looked by from cid from $quests
93 118
             //MATCH needs elaborate processing
94 119
             //We need to go through the responses in the order Qs presented thus the use of $qs_in_order not just $thisattempt
95 120
             foreach ($qs_in_order as $qid){
96  
-                $thisanswer = $thisattempt[response][$qid];
97  
-                if($quests[$qid][qtype]==5) {
  121
+                $thisanswer = $thisattempt['response'][$qid];
  122
+                if($quests[$qid]['qtype']==5) {
98 123
                     //for MATCH processing.  Treat each match couplet as an item for $data_tally
99 124
                     //builds an array of all questions and answers for match questions
100 125
                     $quiz_matches = qr_match_array($qid);
@@ -112,39 +137,39 @@ function display($quiz, $cm, $course) {     /// This function just displays the
112 137
                         $match_answers[$qid][$nowpair[0]] = $phrasepair[1];
113 138
                         $match_qs[$qid][$nowpair[0]] = $phrasepair[0];
114 139
                         $rid = $nowpair[1];
115  
-                        $qtally[$qid][$nowpair[0]][$nowpair[1]][tally]++;
116  
-                        $qtally[$qid][$nowpair[0]][$nowpair[1]][answer] = $phrasepair[1];
  140
+                        $qtally[$qid][$nowpair[0]][$nowpair[1]]['tally']++;
  141
+                        $qtally[$qid][$nowpair[0]][$nowpair[1]]['answer'] = $phrasepair[1];
117 142
                         if ($quiz_matches[$nowpair[0]] == $quiz_matches[$nowpair[1]]) {
118  
-                            $pairdata[score] = 1;
119  
-                            $qtally[$qid][$nowpair[0]][correct]++;
  143
+                            $pairdata['score'] = 1;
  144
+                            $qtally[$qid][$nowpair[0]]['correct']++;
120 145
                         } else {
121  
-                            $pairdata[score] = 0;
  146
+                            $pairdata['score'] = 0;
122 147
                         }
123  
-                        $pairdata[data] = $phrasepair;
124  
-                        $pairdata[qtype] = 5;
125  
-                        $pairdata[qid] = $qid;
126  
-                        $data_tally[$reportline][$thisattempt[attemptid]][] = $pairdata;
  148
+                        $pairdata['data'] = $phrasepair;
  149
+                        $pairdata['qtype'] = 5;
  150
+                        $pairdata['qid'] = $qid;
  151
+                        $data_tally[$reportline][$thisattempt['attemptid']][] = $pairdata;
127 152
                      }
128  
-                } elseif ($quests[$qid][qtype]==8) {
  153
+                } elseif ($quests[$qid]['qtype']==8) {
129 154
                     $thisdata = qr_answer_lookup($qid,$thisanswer);
130  
-                    $data_tally[$reportline][$thisattempt[attemptid]][] = $thisdata;
  155
+                    $data_tally[$reportline][$thisattempt['attemptid']][] = $thisdata;
131 156
                 } else {
132 157
                     $thisdata = qr_answer_lookup($qid,$thisanswer);
133 158
                     //$thisdata returns couplet of display string and right/wrong
134  
-                    if(!$thisdata[data]) {$thisdata[data] = "--";}
  159
+                    if(!$thisdata['data']) {$thisdata['data'] = "--";}
135 160
                     if($thisdata) {
136  
-                        $data_tally[$reportline][$thisattempt[attemptid]][] = $thisdata;
  161
+                        $data_tally[$reportline][$thisattempt['attemptid']][] = $thisdata;
137 162
                     }
138 163
                 }
139 164
             }
140 165
         }
141 166
     }
142  
-$total_user_count = $reportline;
  167
+    $total_user_count = $reportline;
143 168
     //prepare headers (must do now because $table_colcount calculated here
144  
-if($debug and !$download){
145  
-print("<h3>Data Tally</h3>");
146  
-print_object($data_tally);
147  
-}
  169
+    if($debug and !$download){
  170
+    print("<h3>Data Tally</h3>");
  171
+    print_object($data_tally);
  172
+    }
148 173
     //Create here an array with the response analysis data for use with both screen display & Excel
149 174
     //  2 dimensional array has as many cells across as items + title, as many down as $max_choices
150 175
     // plus one row [0] for correct items
@@ -157,11 +182,11 @@ function display($quiz, $cm, $course) {     /// This function just displays the
157 182
 
158 183
     $pct_correct = qr_make_footers();
159 184
 
160  
-if($debug and !$download){
161  
-print("<h3>Footers</h3>");
162  
-print_object($pct_correct);
163  
-}
164  
-//
  185
+    if($debug and !$download){
  186
+    print("<h3>Footers</h3>");
  187
+    print_object($pct_correct);
  188
+    }
  189
+
165 190
     //display a row for each possible multiple choice with $max_choices being highest row
166 191
     for ($i = 1; $i<= $max_choices;$i++){
167 192
         //prepare answer tallies
@@ -169,7 +194,7 @@ function display($quiz, $cm, $course) {     /// This function just displays the
169 194
         $current_column = 0;
170 195
         foreach ($qs_in_order as $qid){
171 196
             $current_column++;
172  
-            switch ($quests[$qid][qtype]) {
  197
+            switch ($quests[$qid]['qtype']) {
173 198
                 case 1:
174 199
                     if(!$sa_tally[$qid]){
175 200
                         $sa_tally[$qid] = qr_make_satally($qid,$current_column);
@@ -200,8 +225,8 @@ function display($quiz, $cm, $course) {     /// This function just displays the
200 225
                     for ($j = $match_start[$qid];$j <= $match_end;$j++){
201 226
                         $colcounter++;
202 227
                         if($match_tally[$qid][$i][$colcounter]) {
203  
-                            $tallytext = $match_tally[$qid][$i][$colcounter][answer];
204  
-                            $tallycount = $match_tally[$qid][$i][$colcounter][tally];
  228
+                            $tallytext = $match_tally[$qid][$i][$colcounter]['answer'];
  229
+                            $tallycount = $match_tally[$qid][$i][$colcounter]['tally'];
205 230
                             //Two slashes used to represent location of a break since one slash might appear in data
206 231
                             $analysis[$i][$current_column + $colcounter-1] = $tallytext . "//" . $tallycount ;
207 232
                         }
@@ -215,320 +240,317 @@ function display($quiz, $cm, $course) {     /// This function just displays the
215 240
         }
216 241
     }
217 242
 
218  
-if($debug and !$download){
219  
-print("<h3>Analysis</h3>");
220  
-print_object($analysis);
221  
-}
  243
+    if($debug and !$download){
  244
+    print("<h3>Analysis</h3>");
  245
+    print_object($analysis);
  246
+    }
222 247
     /// If spreadsheet is wanted, produce one
223  
-        if ($download == "xls") {
224  
-            require_once("$CFG->libdir/excel/Worksheet.php");
225  
-            require_once("$CFG->libdir/excel/Workbook.php");
226  
-
227  
-            header("Content-type: application/vnd.ms-excel");
228  
-            header("Content-Disposition: attachment; filename=$course->shortname ".$quiz->name.".xls");
229  
-            header("Expires: 0");
230  
-            header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
231  
-            header("Pragma: public");
232  
-            $workbook = new Workbook("-");
233  
-            // Creating the first worksheet
234  
-            $myxls = &$workbook->add_worksheet('Responses for each student');
235  
-
  248
+    if ($download == "xls") {
  249
+        require_once("$CFG->libdir/excel/Worksheet.php");
  250
+        require_once("$CFG->libdir/excel/Workbook.php");
  251
+        header("Content-type: application/vnd.ms-excel");
  252
+        header("Content-Disposition: attachment; filename=$course->shortname ".$quiz->name.".xls");
  253
+        header("Expires: 0");
  254
+        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
  255
+        header("Pragma: public");
  256
+        $workbook = new Workbook("-");
  257
+        // Creating the first worksheet
  258
+        $myxls = &$workbook->add_worksheet('Responses for each student');
236 259
 
237 260
         /// format types
238  
-            $format =& $workbook->add_format();
239  
-            $format->set_bold(0);
240  
-            $formaty =& $workbook->add_format();
241  
-            $formaty->set_bg_color('yellow'); 
242  
-            $formatyc =& $workbook->add_format();
243  
-            $formatyc->set_bg_color('yellow'); //bold text on yellow bg
244  
-            $formatyc->set_bold(1);
245  
-            $formatyc->set_align('center');
246  
-            $formatc =& $workbook->add_format();
247  
-            $formatc->set_align('center');
248  
-            $formatb =& $workbook->add_format();
249  
-            $formatb->set_bold(1);
250  
-            $formatbc =& $workbook->add_format();
251  
-            $formatbc->set_bold(1);
252  
-            $formatbc->set_align('center');
253  
-            $formatbrt =& $workbook->add_format();
254  
-            $formatbrt->set_bold(1);
255  
-            $formatbrt->set_align('right');
256  
-            $formatred =& $workbook->add_format();
257  
-            $formatred->set_bold(1);
258  
-            $formatred->set_color('red');
259  
-            $formatred->set_align('center');
260  
-            $formatblue =& $workbook->add_format();
261  
-            $formatblue->set_bold(1);
262  
-            $formatblue->set_color('blue');
263  
-            $formatblue->set_align('center');
264  
-            $myxls->write_string(0,0,$quiz->name);
265  
-            $myxls->set_column(0,0,25);
266  
-            $row=2;
267  
-            $qcount=0;
268  
-//            $myxls->write_string(0,2,$choiceMax,$formatyc);
269  
-            //You might expect the headers to be written at this point, but we are saving it till last
270  
-            $highest_Q_no = 0;
271  
-            $totcolcount = $table_colcount+2;
272  
-            $myxls->write_string(0,2,"Responses of Individuals to Each Item",$formatyc);
273  
-//            qr_xls_headers("Name","Grade");
274  
-//This should have been a function but there is an 'incurable' error:
275  
-//  "Call to a member function on a non-object"  It is repeated below for the 2nd worksheet with
276  
-//  only minor variations
277  
-            $nm = "Name";$Item="Grade";
278  
-            $row = 1;
279  
-            $col = 0;
280  
-            $qcount = 0;
281  
-                $myxls->write_string($row,$col,$nm,$formatbc);
282  
-            if($Item == "Grade") {
283  
-                $col++;
284  
-                $myxls->write_string($row,$col,$Item,$formatbc);
285  
-            }
286  
-            foreach($qs_in_order as $qid){
287  
-                $qcount++;
288  
-                $col++;
289  
-                if($quests[$qid][qtype] == 5) {
290  
-                    $i = 0;
291  
-                    foreach ($match_qs[$qid] as $nowq){
292  
-                        $i++;
293  
-                        $qm = "Q-$qcount M-$i";
294  
-                        $myxls->write_string($row,$col,$qm,$formatbc);
295  
-                        $myxls->write_string(2,$col,$nowq,$formatyc);
296  
-                        $col++;
297  
-                    }
298  
-                    $col--;
299  
-                } else {
300  
-                    $myxls->write_string($row,$col,"Q-$qcount",$formatbc);
  261
+        $format =& $workbook->add_format();
  262
+        $format->set_bold(0);
  263
+        $formaty =& $workbook->add_format();
  264
+        $formaty->set_bg_color('yellow'); 
  265
+        $formatyc =& $workbook->add_format();
  266
+        $formatyc->set_bg_color('yellow'); //bold text on yellow bg
  267
+        $formatyc->set_bold(1);
  268
+        $formatyc->set_align('center');
  269
+        $formatc =& $workbook->add_format();
  270
+        $formatc->set_align('center');
  271
+        $formatb =& $workbook->add_format();
  272
+        $formatb->set_bold(1);
  273
+        $formatbc =& $workbook->add_format();
  274
+        $formatbc->set_bold(1);
  275
+        $formatbc->set_align('center');
  276
+        $formatbrt =& $workbook->add_format();
  277
+        $formatbrt->set_bold(1);
  278
+        $formatbrt->set_align('right');
  279
+        $formatred =& $workbook->add_format();
  280
+        $formatred->set_bold(1);
  281
+        $formatred->set_color('red');
  282
+        $formatred->set_align('center');
  283
+        $formatblue =& $workbook->add_format();
  284
+        $formatblue->set_bold(1);
  285
+        $formatblue->set_color('blue');
  286
+        $formatblue->set_align('center');
  287
+        $myxls->write_string(0,0,$quiz->name);
  288
+        $myxls->set_column(0,0,25);
  289
+        $row=2;
  290
+        $qcount=0;
  291
+//        $myxls->write_string(0,2,$choiceMax,$formatyc);
  292
+        //You might expect the headers to be written at this point, but we are saving it till last
  293
+        $highest_Q_no = 0;
  294
+        $totcolcount = $table_colcount+2;
  295
+        $myxls->write_string(0,2,"Responses of Individuals to Each Item",$formatyc);
  296
+//        qr_xls_headers("Name","Grade");
  297
+        //This should have been a function but there is an 'incurable' error:
  298
+        //  "Call to a member function on a non-object"  It is repeated below for the 2nd worksheet with
  299
+        //  only minor variations
  300
+        $nm = "Name";$Item="Grade";
  301
+        $row = 1;
  302
+        $col = 0;
  303
+        $qcount = 0;
  304
+        $myxls->write_string($row,$col,$nm,$formatbc);
  305
+        if($Item == "Grade") {
  306
+            $col++;
  307
+            $myxls->write_string($row,$col,$Item,$formatbc);
  308
+        }
  309
+        foreach($qs_in_order as $qid){
  310
+            $qcount++;
  311
+            $col++;
  312
+            if($quests[$qid]['qtype'] == 5) {
  313
+                $i = 0;
  314
+                foreach ($match_qs[$qid] as $nowq){
  315
+                    $i++;
  316
+                    $qm = "Q-$qcount M-$i";
  317
+                    $myxls->write_string($row,$col,$qm,$formatbc);
  318
+                    $myxls->write_string(2,$col,$nowq,$formatyc);
  319
+                    $col++;
301 320
                 }
  321
+                $col--;
  322
+            } else {
  323
+                $myxls->write_string($row,$col,"Q-$qcount",$formatbc);
302 324
             }
  325
+        }
303 326
 
304  
-    //now print the lines of answers
305  
-            
306  
-            $row = 2;
307  
-            foreach ($data_tally as $thisuserno=>$thisuser){
308  
-                foreach($thisuser as $thisattemptno=>$thisattempt){
309  
-                    $row++;
310  
-                    foreach($thisattempt as $thisitemkey=>$thisitem) {
  327
+        //now print the lines of answers
  328
+        
  329
+        $row = 2;
  330
+        foreach ($data_tally as $thisuserno=>$thisuser){
  331
+            foreach($thisuser as $thisattemptno=>$thisattempt){
  332
+                $row++;
  333
+                foreach($thisattempt as $thisitemkey=>$thisitem) {
311 334
                     //$thisitemkeys 1 & 2 are name and total score
312 335
                     //There needs to be a 3-way branch, keys0 & 1 just print $thisitem
313  
-                    //else if $thisitem[qtype] = 5, then processing for MATCH is needed
314  
-                    //else the data to be printed is in $thisitem[data] and 
315  
-                    //$thisitem[score] == 1 shows that the item was correct
316  
-                        if ($thisitem[score] < 1) {$thiscolor = $formatred;} else {$thiscolor = $formatblue;}
317  
-                        $col++;
318  
-                        if ($thisitemkey == 0){
319  
-                            $col = 0;
320  
-                            $myxls->write_string($row,$col,$thisitem,$formatb);
321  
-                        } elseif ($thisitemkey == 1){
322  
-                            $myxls->write_number($row,$col,$thisitem,$formatb);
323  
-                        } elseif ($thisitemkey[qtype] == 2){
324  
-                            $myxls->write_string($row,$col,$thisitem[data][answer],$thiscolor);
325  
-                        } elseif ($thisitem[qtype] == 5) {
326  
-                            if ($thisitem[score] == 1) {$thiscolor = $formatblue;} else {$thiscolor = $formatred;}
327  
-                            if(!$thisitem[data][1]){$thisitem[data][1]="(No Response)";}
328  
-//                            $myxls->write_string(2,$col,$thisitem[data][0],$formatb);
329  
-                            $myxls->write_string($row,$col,$thisitem[data][1],$thiscolor);
330  
-                        } else {
331  
-                            $myxls->write_string($row,$col,$thisitem[data],$thiscolor);
332  
-                        }
  336
+                    //else if $thisitem['qtype'] = 5, then processing for MATCH is needed
  337
+                    //else the data to be printed is in $thisitem['data'] and 
  338
+                    //$thisitem['score'] == 1 shows that the item was correct
  339
+                    if ($thisitem['score'] < 1) {$thiscolor = $formatred;} else {$thiscolor = $formatblue;}
  340
+                    $col++;
  341
+                    if ($thisitemkey == 0){
  342
+                        $col = 0;
  343
+                        $myxls->write_string($row,$col,$thisitem,$formatb);
  344
+                    } elseif ($thisitemkey == 1){
  345
+                        $myxls->write_number($row,$col,$thisitem,$formatb);
  346
+                    } elseif ($thisitemkey['qtype'] == 2){
  347
+                        $myxls->write_string($row,$col,$thisitem['data']['answer'],$thiscolor);
  348
+                    } elseif ($thisitem['qtype'] == 5) {
  349
+                        if ($thisitem['score'] == 1) {$thiscolor = $formatblue;} else {$thiscolor = $formatred;}
  350
+                        if(!$thisitem['data'][1]){$thisitem['data'][1]="(No Response)";}
  351
+                        $myxls->write_string($row,$col,$thisitem['data'][1],$thiscolor);
  352
+                    } else {
  353
+                        $myxls->write_string($row,$col,$thisitem['data'],$thiscolor);
333 354
                     }
334 355
                 }
335 356
             }
336  
-//        }
337  
-            $myxls = &$workbook->add_worksheet('Item Response Analysis');
338  
-            $sheettitle = "Item Response Analysis";
339  
-            $myxls->write_string(0,0,$sheettitle,$formatb);
340  
-            $itemcount = 0;
341  
-            $nm = "Question";
342  
-            $row = 1;
343  
-            $col = 0;
344  
-            $qcount = 0;
345  
-            $myxls->write_string($row,$col,$nm,$formatbc);
346  
-            foreach($qs_in_order as $qid){
347  
-                $qcount++;
  357
+        }
  358
+
  359
+        $myxls = &$workbook->add_worksheet('Item Response Analysis');
  360
+        $sheettitle = "Item Response Analysis";
  361
+        $myxls->write_string(0,0,$sheettitle,$formatb);
  362
+        $itemcount = 0;
  363
+        $nm = "Question";
  364
+        $row = 1;
  365
+        $col = 0;
  366
+        $qcount = 0;
  367
+        $myxls->write_string($row,$col,$nm,$formatbc);
  368
+        foreach($qs_in_order as $qid){
  369
+            $qcount++;
  370
+            $col++;
  371
+            if($quests[$qid]['qtype'] == 5) {
  372
+                $i = 0;
  373
+                foreach ($match_qs[$qid] as $nowq){
  374
+                $i++;
  375
+                $qm = "Q-$qcount M-$i";
  376
+                $myxls->write_string($row,$col,$qm,$formatbc);
  377
+                $myxls->write_string($row+1,$col,$nowq,$formatbc);
348 378
                 $col++;
349  
-                if($quests[$qid][qtype] == 5) {
350  
-                    $i = 0;
351  
-                    foreach ($match_qs[$qid] as $nowq){
352  
-                        $i++;
353  
-                        $qm = "Q-$qcount M-$i";
354  
-                        $myxls->write_string($row,$col,$qm,$formatbc);
355  
-                        $myxls->write_string($row+1,$col,$nowq,$formatbc);
356  
-                        $col++;
357  
-                    }
358  
-                    $col--;
359  
-                } else {
360  
-                    $myxls->write_string($row,$col,"Q-$qcount",$formatbc);
361 379
                 }
  380
+                $col--;
  381
+            } else {
  382
+                $myxls->write_string($row,$col,"Q-$qcount",$formatbc);
362 383
             }
  384
+        }
363 385
 
364 386
 //           Now write tally data
365  
-            $row = $row+2;
366  
-            $myxls->write_string($row,1,"Correct Response:",$formatbc);
367  
-            $col=1;
368  
-            foreach ($qs_in_order as $qid){
  387
+        $row = $row+2;
  388
+        $myxls->write_string($row,1,"Correct Response:",$formatbc);
  389
+        $col=1;
  390
+        foreach ($qs_in_order as $qid){
  391
+            $col++;
  392
+            if ($quests[$qid]['qtype'] == 5) {
  393
+                foreach($match_answers[$qid] as $thisans){
  394
+                $myxls->write_string($row,1,$thisans,$formatbc);
369 395
                 $col++;
370  
-                if ($quests[$qid][qtype] == 5) {
371  
-                    foreach($match_answers[$qid] as $thisans){
372  
-                        $myxls->write_string($row,1,$thisans,$formatbc);
373  
-                        $col++;
374  
-                    }
375  
-                    $col--;
376  
-                } else {
377  
-                    $myxls->write_string($row,1,$quests[$qid][correct],$formatbc);
378 396
                 }
  397
+                $col--;
  398
+            } else {
  399
+                $myxls->write_string($row,1,$quests[$qid]['correct'],$formatbc);
379 400
             }
380  
-            //display a row for each possible multiple choice with $max_choices being highest row,$table_colcount is the width
381  
-            for ($i = 1; $i<= $max_choices;$i++){
382  
-                $label="M/C #$i";
383  
-                $myxls->write_string($row,0,$label,$formatbrt);
384  
-                //display answer tallies
385  
-                for ($j = 1; $j <= $table_colcount; $j++){
386  
-                    //substitute "<br>" for a "//"
387  
-                    $nowdata = $analysis[$i][$j];
388  
-                    if($slashpos = strpos($nowdata,"//")){
389  
-                        $text = substr($nowdata,0,$slashpos);
390  
-                        $value = substr($nowdata,$slashpos+2);
391  
-                        $myxls->write_string($row,$j,$text,$formatc);
392  
-                        $myxls->write_string($row+1,$j,$value,$formatbc);
393  
-                    } else {
394  
-                        $myxls->write_string($row,$j,$nowdata,$formatc);
395  
-                    }
  401
+        }
  402
+        //display a row for each possible multiple choice with $max_choices being highest row,$table_colcount is the width
  403
+        for ($i = 1; $i<= $max_choices;$i++){
  404
+            $label="M/C #$i";
  405
+            $myxls->write_string($row,0,$label,$formatbrt);
  406
+            //display answer tallies
  407
+            for ($j = 1; $j <= $table_colcount; $j++){
  408
+                //substitute "<br>" for a "//"
  409
+                $nowdata = $analysis[$i][$j];
  410
+                if($slashpos = strpos($nowdata,"//")){
  411
+                $text = substr($nowdata,0,$slashpos);
  412
+                $value = substr($nowdata,$slashpos+2);
  413
+                $myxls->write_string($row,$j,$text,$formatc);
  414
+                $myxls->write_string($row+1,$j,$value,$formatbc);
  415
+                } else {
  416
+                $myxls->write_string($row,$j,$nowdata,$formatc);
396 417
                 }
397  
-                $row = $row+2;
398 418
             }
  419
+            $row = $row+2;
  420
+        }
399 421
 
400  
-            //Finally output the total percent correct
401  
-            $row++;
402  
-            $myxls->write_string($row,1,"Percent Correct:",$formatbrt);
403  
-            for ($i = 1; $i<= $table_colcount;$i++){
404  
-                $myxls->write_string($row,$i,$pct_correct[$i],$formatbc);
405  
-            }
  422
+        //Finally output the total percent correct
  423
+        $row++;
  424
+        $myxls->write_string($row,1,"Percent Correct:",$formatbrt);
  425
+        for ($i = 1; $i<= $table_colcount;$i++){
  426
+            $myxls->write_string($row,$i,$pct_correct[$i],$formatbc);
  427
+        }
406 428
 
407 429
            //Print the questions with responses on a new worksheet
408  
-            $myxls = &$workbook->add_worksheet('Questions and Responses');
409  
-            $sheettitle = "Questions and Responses";
410  
-            $myxls->write_string(0,0,$sheettitle,$formatb);
  430
+        $myxls = &$workbook->add_worksheet('Questions and Responses');
  431
+        $sheettitle = "Questions and Responses";
  432
+        $myxls->write_string(0,0,$sheettitle,$formatb);
  433
+        $itemcount = 0;
  434
+        //Now printout the questions (and M/C answers if $containsMC
  435
+
  436
+        $qcount = 0;
  437
+        $row = 1;
  438
+        foreach ($qs_in_order as $qid){
  439
+            $row++;
  440
+            $qcount++;
  441
+            $label = "Q-$qcount";
  442
+            $myxls->write_string($row,0,$label,$formatb);
  443
+            $myxls->write_string($row,1,$quests[$qid]['qtext'],$formatb);
411 444
             $itemcount = 0;
412  
-    //Now printout the questions (and M/C answers if $containsMC
413  
-
414  
-            $qcount = 0;
415  
-            $row = 1;
416  
-            foreach ($qs_in_order as $qid){
  445
+            if($quests[$qid]['qtype']==3){
  446
+                $nowchoices = $quests[$qid]['choice'];
  447
+                foreach($nowchoices as $thischoice){
417 448
                 $row++;
418  
-                $qcount++;
419  
-                $label = "Q-$qcount";
420  
-                $myxls->write_string($row,0,$label,$formatb);
421  
-                $myxls->write_string($row,1,$quests[$qid][qtext],$formatb);
422  
-                $itemcount = 0;
423  
-                if($quests[$qid][qtype]==3){
424  
-                    $nowchoices = $quests[$qid][choice];
425  
-                    foreach($nowchoices as $thischoice){
426  
-                    $row++;
427  
-                        $label = "A-$thischoice[choiceno]";
428  
-                        $myxls->write_string($row,2,$label,$formatb);
429  
-                        $myxls->write_string($row,3,$thischoice[answer],$formatb);
430  
-                    }
  449
+                $label = "A-$thischoice[choiceno]";
  450
+                $myxls->write_string($row,2,$label,$formatb);
  451
+                $myxls->write_string($row,3,$thischoice[answer],$formatb);
431 452
                 }
432 453
             }
433  
-
434  
-            $workbook->close();
435  
-            exit;
436 454
         }
437 455
 
438  
-////////---------------------------
  456
+        $workbook->close();
  457
+        exit;
  458
+    }
  459
+
  460
+        ////////---------------------------
439 461
         /// If a text file is wanted, produce one
440 462
         if ($download == "txt") {
441 463
         /// Print header to force download
442 464
 
443  
-            header("Content-Type: application/download\n"); 
444  
-            header("Content-Disposition: attachment; filename=\"$course->shortname $quiz->name.txt\"");
445  
-            header("Expires: 0");
446  
-            header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
447  
-            header("Pragma: public");
  465
+        header("Content-Type: application/download\n"); 
  466
+        header("Content-Disposition: attachment; filename=\"$course->shortname $quiz->name.txt\"");
  467
+        header("Expires: 0");
  468
+        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
  469
+        header("Pragma: public");
448 470
 
449 471
         /// Print names of all the fields
450 472
 
451  
-            echo "$quiz->name";
452  
-            echo "\n";
  473
+        echo "$quiz->name";
  474
+        echo "\n";
453 475
         
454 476
         /// Print all the user data
455  
-            $colcount = count($question_ids);
456  
-            foreach ($data_tally as $thisuserno=>$thisuser){
457  
-                foreach($thisuser as $thisattemptno=>$thisattempt){
458  
-                    foreach($thisattempt as $thisitemkey=>$thisitem) {
459  
-                        if ($thisitem[score] < 1) {$mark = "";} else {$mark = "*";}
460  
-                        //First two items are name & grade
461  
-                        if ($thisitemkey < 2){
462  
-                            echo $thisitem . "\t";
463  
-                        } elseif ($thisitemkey[qtype] == 2){
464  
-                           echo $thisitem[data][answer] . "\t";
465  
-                        } elseif ($thisitem[qtype] == 5) {
466  
-                            if ($thisitem[score] == 1) {$mark = "*";} else {$mark="";}
467  
-                            if(!$thisitem[data][1]){$thisitem[data][1]="(No Response)";}
468  
-                            echo "{$thisitem[data][0]} -- $mark{$thisitem[data][1]}\t";
469  
-                        } else {
470  
-                            echo "$mark{$thisitem[data]}\t";
471  
-                        }
472  
-                    }
  477
+        $colcount = count($question_ids);
  478
+        foreach ($data_tally as $thisuserno=>$thisuser){
  479
+            foreach($thisuser as $thisattemptno=>$thisattempt){
  480
+                foreach($thisattempt as $thisitemkey=>$thisitem) {
  481
+                if ($thisitem['score'] < 1) {$mark = "";} else {$mark = "*";}
  482
+                //First two items are name & grade
  483
+                if ($thisitemkey < 2){
  484
+                    echo $thisitem . "\t";
  485
+                } elseif ($thisitemkey['qtype'] == 2){
  486
+                   echo $thisitem['data']['answer'] . "\t";
  487
+                } elseif ($thisitem['qtype'] == 5) {
  488
+                    if ($thisitem['score'] == 1) {$mark = "*";} else {$mark="";}
  489
+                    if(!$thisitem['data'][1]){$thisitem['data'][1]="(No Response)";}
  490
+                    echo "{$thisitem['data'][0]} -- $mark{$thisitem['data'][1]}\t";
  491
+                } else {
  492
+                    echo "$mark{$thisitem['data']}\t";
  493
+                }
473 494
                 }
474  
-                echo " \n";
475  
-            }
476  
-            echo " \n";
477  
-            echo "* Asterisk indicates correct response";
478  
-            echo " \n";
479  
-            //Question numbers
480  
-            for  ($i = 1;$i <= $colcount;$i++) {
481  
-                echo  "Q-$i\t";
482 495
             }
483 496
             echo " \n";
484  
-            //Q numbers
485  
-            foreach($qs_in_order as $qid){
486  
-                $qcount++;
487  
-                if($quests[$qid][qtype] == 5) {
488  
-                    $i = 0;
489  
-                    foreach ($match_qs[$qid] as $nowq){
490  
-                        $i++;
491  
-                        echo  "Q-$qcount M-$i\t";
492  
-                    }
493  
-                } else {
494  
-                    echo  "Q-$qcount\t";
  497
+        }
  498
+        echo " \n";
  499
+        echo "* Asterisk indicates correct response";
  500
+        echo " \n";
  501
+        //Question numbers
  502
+        for  ($i = 1;$i <= $colcount;$i++) {
  503
+            echo  "Q-$i\t";
  504
+        }
  505
+        echo " \n";
  506
+        //Q numbers
  507
+        foreach($qs_in_order as $qid){
  508
+            $qcount++;
  509
+            if($quests[$qid]['qtype'] == 5) {
  510
+                $i = 0;
  511
+                foreach ($match_qs[$qid] as $nowq){
  512
+                $i++;
  513
+                echo  "Q-$qcount M-$i\t";
495 514
                 }
  515
+            } else {
  516
+                echo  "Q-$qcount\t";
496 517
             }
497  
-            echo  " \n";
498  
-            //Repeat for q answers
499  
-            foreach($qs_in_order as $qid){
500  
-                $qcount++;
501  
-                if($quests[$qid][qtype] == 5) {
502  
-                    foreach ($match_qs[$qid] as $nowq){
503  
-                        echo $nowq . "\t";
504  
-                    }
505  
-                } else {
506  
-                    echo  "\t";
  518
+        }
  519
+        echo  " \n";
  520
+        //Repeat for q answers
  521
+        foreach($qs_in_order as $qid){
  522
+            $qcount++;
  523
+            if($quests[$qid]['qtype'] == 5) {
  524
+                foreach ($match_qs[$qid] as $nowq){
  525
+                echo $nowq . "\t";
507 526
                 }
  527
+            } else {
  528
+                echo  "\t";
508 529
             }
509  
-            echo  " \n";
510  
-
511  
-            for ($i = 1; $i<= $max_choices;$i++){
512  
-                echo  "M/C #$i\t";
513  
-                //display answer tallies
514  
-                for ($j = 1; $j <= $table_colcount; $j++){
515  
-                    //substitute "<br>" for a "//"
516  
-                    $nowdata = $analysis[$i][$j];
517  
-                    if (strpos($nowdata,"//")>0) {
518  
-                        $nowdata = str_replace("//"," : ",$nowdata);
519  
-                    }
520  
-                    echo $nowdata . "\t";
  530
+        }
  531
+        echo  " \n";
  532
+
  533
+        for ($i = 1; $i<= $max_choices;$i++){
  534
+            echo  "M/C #$i\t";
  535
+            //display answer tallies
  536
+            for ($j = 1; $j <= $table_colcount; $j++){
  537
+                //substitute "<br>" for a "//"
  538
+                $nowdata = $analysis[$i][$j];
  539
+                if (strpos($nowdata,"//")>0) {
  540
+                $nowdata = str_replace("//"," : ",$nowdata);
521 541
                 }
522  
-                echo  " \n";
  542
+                echo $nowdata . "\t";
523 543
             }
524  
-            exit;
  544
+            echo  " \n";
  545
+        }
  546
+        exit;
525 547
         }
526  
-////////--------------------------- If it falls through both of the $download choices, print on screen
  548
+        ////////--------------------------- If it falls through both of the $download choices, print on screen
527 549
     //Print user responses
528 550
     print ("<table border=1 align=center width=95% cellpadding=2 cellspacing=0>\n");
529 551
     $totcolcount = $table_colcount+2;
530  
-    print("<tr><th colspan=$totcolcount>Responses of Individuals to Each Item</th></tr>");
531  
-    qr_print_headers($data_tally,"Name","Grade");
  552
+    print("<tr><th colspan=$totcolcount>$strindivresp</th></tr>");
  553
+    qr_print_headers($data_tally,"$strname","$strgrade");
532 554
     //now print the lines of answers
533 555
     foreach ($data_tally as $thisuserno=>$thisuser){
534 556
         foreach($thisuser as $thisattemptno=>$thisattempt){
@@ -536,43 +558,43 @@ function display($quiz, $cm, $course) {     /// This function just displays the
536 558
             foreach($thisattempt as $thisitemkey=>$thisitem) {
537 559
             //$thisitemkeys 1 & 2 are name and total score
538 560
             //There needs to be a 3-way branch, keys0 & 1 just print $thisitem
539  
-            //else if $thisitem[qtype] = 5, then processing for MATCH is needed
540  
-            //else the data to be printed is in $thisitem[data] and $thisitem[score] == 1 shows that the item was correct
541  
-                if ($thisitem[score] < 1) {$thiscolor = "ff0000";} else {$thiscolor = "000000";}
  561
+            //else if $thisitem['qtype'] = 5, then processing for MATCH is needed
  562
+            //else the data to be printed is in $thisitem['data'] and $thisitem['score'] == 1 shows that the item was correct
  563
+                if ($thisitem['score'] < 1) {$thiscolor = "ff0000";} else {$thiscolor = "000000";}
542 564
                 if ($thisitemkey == 0){
543  
-                    print("<td class='tdleft'>$thisitem&nbsp;</th>");
  565
+                    print("<th align='left'>$thisitem&nbsp;</th>");
544 566
                 } elseif ($thisitemkey == 1){
545  
-                    print("<td>&nbsp;&nbsp;$thisitem&nbsp;&nbsp;</td>");
546  
-                } elseif ($thisitemkey[qtype] == 2){
  567
+                    print("<td align='right'>&nbsp;$thisitem%&nbsp;&nbsp;</td>");
  568
+                } elseif ($thisitemkey['qtype'] == 2){
547 569
                     print("<td>&nbsp;&nbsp;$thisitem[data][answer]&nbsp;&nbsp;</td>");
548  
-                } elseif ($thisitem[qtype] == 5) {
549  
-                    if ($thisitem[score] == 1) {$thiscolor = "blue";}
550  
-                    if(!$thisitem[data][1]){$thisitem[data][1]="(No Response)";}
551  
-                    print("<td align=center><font size=-2>{$thisitem[data][0]}<br><font color='$thiscolor'>{$thisitem[data][1]}</font></font></td>");
  570
+                } elseif ($thisitem['qtype'] == 5) {
  571
+                    if ($thisitem['score'] == 1) {$thiscolor = "blue";}
  572
+                    if(!$thisitem['data'][1]){$thisitem['data'][1]="($strnoresponse)";}
  573
+                    print("<td align=center><font size=-2>{$thisitem['data'][0]}<br><font color='$thiscolor'>{$thisitem['data'][1]}</font></font></td>");
552 574
                 } else {
553  
-                    print("<td align=center><font color='$thiscolor'>&nbsp;&nbsp;{$thisitem[data]}&nbsp;&nbsp;</font></td>");
  575
+                    print("<td align=center><font color='$thiscolor'>&nbsp;&nbsp;{$thisitem['data']}&nbsp;&nbsp;</font></td>");
554 576
                 }
555 577
             }
556 578
         }
557 579
         print("</tr>\n");
558 580
     }
559 581
     
560  
-if($debug and !$download){
561  
-print("<h3>Qtally</h3>");
562  
-print_object($qtally);
563  
-}
  582
+    if($debug and !$download){
  583
+    print("<h3>Qtally</h3>");
  584
+    print_object($qtally);
  585
+    }
564 586
     //print tally of how many selected each choice
565  
-    print("<tr><th colspan=$totcolcount>Item Response Analysis </th></tr>");
  587
+    print("<tr><th colspan=$totcolcount>$stritemanal</th></tr>");
566 588
     qr_print_headers($data_tally,"Item","&nbsp;");
567 589
     //display row with correct answers
568  
-    print("<tr><th colspan=2 align=right>Correct Response:</th>");
  590
+    print("<tr><th colspan=2 align=right>$strcorrresp:</th>");
569 591
     foreach ($qs_in_order as $qid){
570  
-        if ($quests[$qid][qtype] == 5) {
  592
+        if ($quests[$qid]['qtype'] == 5) {
571 593
             foreach($match_answers[$qid] as $thisans){
572 594
                 print("<th align='center'>&nbsp;$thisans&nbsp;</th>");
573 595
             }
574 596
         } else {
575  
-            print("<th align='center'>&nbsp;{$quests[$qid][correct]}&nbsp;</th>");
  597
+            print("<th align='center'>&nbsp;{$quests[$qid]['correct']}&nbsp;</th>");
576 598
         }
577 599
     }
578 600
     print("</tr>\n");
@@ -591,7 +613,7 @@ function display($quiz, $cm, $course) {     /// This function just displays the
591 613
     }
592 614
     print("</tr>\n");
593 615
     //Finally display the total percent correct
594  
-    print("<tr valign=top><th align=right colspan=2>Percent Correct:</th>");
  616
+    print("<tr valign=top><th align=right colspan=2>$strpercentcorrect:</th>");
595 617
     for ($i = 0; $i< $table_colcount;$i++){
596 618
         print ("<th>{$pct_correct[$i]}</th> ");
597 619
     }
@@ -601,36 +623,36 @@ function display($quiz, $cm, $course) {     /// This function just displays the
601 623
     //Now printout the questions (and M/C answers if $containsMC
602 624
 
603 625
     print ("<p><table width=95% border=1 align=center cellpadding=2 cellspacing=0>\n");
604  
-    print("<tr><th colspan=3>QUIZ: $quiz->name&nbsp;&nbsp; -- &nbsp;&nbsp;Listing of Items in This Quiz </th></tr>\n");
  626
+    print("<tr><th colspan=3>QUIZ: $quiz->name&nbsp;&nbsp; -- &nbsp;&nbsp;$strlistitems</th></tr>\n");
605 627
     $qcount = 0;
606 628
     foreach ($qs_in_order as $qid){
607 629
         $qcount++;
608  
-        print("<tr valign=top><th>Q-$qcount</th><td colspan=2>{$quests[$qid][qtext]}</td></tr>\n");
609  
-        if($quests[$qid][qtype]==3){
610  
-            $nowchoices = $quests[$qid][choice];
  630
+        print("<tr valign=top><th>Q-$qcount</th><td colspan=2>{$quests[$qid]['qtext']}</td></tr>\n");
  631
+        if($quests[$qid]['qtype']==3){
  632
+            $nowchoices = $quests[$qid]['choice'];
611 633
             foreach($nowchoices as $thischoice){
612 634
                 print("<tr valign=top><td>&nbsp;</td>");
613  
-                print("<td width='5%' align=center><b>A-{$thischoice[choiceno]}</b></td><td>{$thischoice[answer]}</td></tr>\n");
  635
+                print("<td width='5%' align=center><b>A-{$thischoice['choiceno']}</b></td><td>{$thischoice['answer']}</td></tr>\n");
614 636
             }
615 637
         }
616 638
     }
617 639
     print("</table>\n");
618 640
     
619  
-        echo "<br />\n";
620  
-        echo "<table border=0 align=center><tr>\n";
621  
-        echo "<td>";
622  
-        unset($options);
623  
-        $options["id"] = "$cm->id";
624  
-        $options["mode"] = "fullstat";
625  
-        $options["noheader"] = "yes";
626  
-        $options["download"] = "xls";
627  
-        print_single_button("report.php", $options, get_string("downloadexcel"));
628  
-        echo "<td>";
629  
-        $options["download"] = "txt";
630  
-        print_single_button("report.php", $options, get_string("downloadtext"));
631  
-        echo "</table>";
  641
+    echo "<br />\n";
  642
+    echo "<table border=0 align=center><tr>\n";
  643
+    echo "<td>";
  644
+    unset($options);
  645
+    $options["id"] = "$cm->id";
  646
+    $options["mode"] = "fullstat";
  647
+    $options["noheader"] = "yes";
  648
+    $options["download"] = "xls";
  649
+    print_single_button("report.php", $options, get_string("downloadexcel"));
  650
+    echo "<td>";
  651
+    $options["download"] = "txt";
  652
+    print_single_button("report.php", $options, get_string("downloadtext"));
  653
+    echo "</table>";
632 654
 ////////---------------------------
633  
-        return true;
  655
+    return true;
634 656
     }
635 657
 }
636 658
 ////just functions below here----------------------------------------------
@@ -646,7 +668,7 @@ function qr_quiz_responses($quiz) {
646 668
 
647 669
 function qr_make_satally($qid,$col){
648 670
     global $analysis, $qtally,$max_choices;
649  
-    $this_sa = $qtally[$qid][response];
  671
+    $this_sa = $qtally[$qid]['response'];
650 672
     $rowcnt = 0;
651 673
     if ($this_sa){
652 674
         foreach($this_sa as $thistext =>$thistally){
@@ -676,7 +698,7 @@ function qr_make_numtally($qid,$col){
676 698
     $this_num = $qtally[$qid];
677 699
     $rowcnt = 0;
678 700
     if ($this_num){
679  
-        foreach($this_num[response] as $thisans=>$thistally){
  701
+        foreach($this_num['response'] as $thisans=>$thistally){
680 702
             if($thisans){
681 703
                 $rowcnt++;
682 704
                 $analysis[$rowcnt][$col] = $thisans . "//" . $thistally;
@@ -697,10 +719,10 @@ function qr_make_matchtally($qid){
697 719
             $itemcntB = 0;
698 720
             if (gettype($thisitem) == "array"){
699 721
                 foreach ($thisitem as $thisrid=>$thisans){
700  
-                    if (!$thisans[answer]){continue;}
  722
+                    if (!$thisans['answer']){continue;}
701 723
                     $itemcntB++;
702  
-                    $inverted[$itemcntB][$itemcntA][answer] = $thisans[answer];
703  
-                    $inverted[$itemcntB][$itemcntA][tally] = $thisans[tally];
  724
+                    $inverted[$itemcntB][$itemcntA]['answer'] = $thisans['answer'];
  725
+                    $inverted[$itemcntB][$itemcntA]['tally'] = $thisans['tally'];
704 726
                 }
705 727
             }
706 728
         }
@@ -709,16 +731,16 @@ function qr_make_matchtally($qid){
709 731
 }
710 732
 
711 733
 function qr_print_headers($data_tally,$nm,$gd){
712  
-    global  $qs_in_order,$qtally,$quests,$total_user_count,$match_number;
  734
+    global  $qs_in_order,$qtally,$quests,$total_user_count,$match_number,$strquestion;
713 735
     $qcount = 0;
714 736
     if($nm == "Item") {
715  
-        print("<tr><th colspan=2 align=right>Question:</th>");
  737
+        print("<tr><th colspan=2 align=right>$strquestion:</th>");
716 738
     } else {
717  
-        print("<tr><th>$nm</th><th>$gd</th>");
  739
+        print("<tr><th>$nm</th><th width='5%'>$gd</th>");
718 740
     }
719 741
     foreach($qs_in_order as $qid){
720 742
         $qcount++;
721  
-        if($quests[$qid][qtype] == 5) {
  743
+        if($quests[$qid]['qtype'] == 5) {
722 744
             $colcount = $match_number[$qid];
723 745
         } else {
724 746
             $colcount = 1;
@@ -732,13 +754,13 @@ function qr_make_footers(){
732 754
     //Create the percent correct for the footer
733 755
     global  $qs_in_order,$qtally,$quests,$total_user_count;
734 756
     foreach($qs_in_order as $qid){
735  
-        if($quests[$qid][qtype] == 5) {
  757
+        if($quests[$qid]['qtype'] == 5) {
736 758
             foreach ($qtally[$qid] as $thisitem){
737  
-                $this_correct = $thisitem[correct];
  759
+                $this_correct = $thisitem['correct'];
738 760
                 $footers[] = qr_make_pct($this_correct);
739 761
             }
740 762
         } else {
741  
-            $this_correct = $qtally[$qid][correct];
  763
+            $this_correct = $qtally[$qid]['correct'];
742 764
             $footers[] = qr_make_pct($this_correct);
743 765
         }
744 766
     }
@@ -758,46 +780,46 @@ function qr_make_pct($this_correct){
758 780
 function qr_answer_lookup($qid,$thisanswer){
759 781
     //For each type of question, this needs to determine answer string to report and whether right or wrong
760 782
     global $quests,$qtally,$max_choices,$thismin,$thismax;
761  
-    $thistype = $quests[$qid][qtype];
762  
-    $returndata[data] = "--";
763  
-    $returndata[score] = 0;
764  
-    $returndata[qtype] = $thistype;
765  
-    $returndata[qid] = $qid;
766  
-    $qtally[$qid][qtype] = $thistype;
  783
+    $thistype = $quests[$qid]['qtype'];
  784
+    $returndata['data'] = "--";
  785
+    $returndata['score'] = 0;
  786
+    $returndata['qtype'] = $thistype;
  787
+    $returndata['qid'] = $qid;
  788
+    $qtally[$qid]['qtype'] = $thistype;
767 789
     switch ($thistype) {
768 790
         case 1:  //SHORTANSWER
769  
-            $returndata[data] = $thisanswer;
770  
-            $qtally[$qid][response][$thisanswer]++;
  791
+            $returndata['data'] = $thisanswer;
  792
+            $qtally[$qid]['response'][$thisanswer]++;
771 793
             //convert all to lowercase to allow for mismatching cases to be correct
772  
-            if (strpos(strtolower($quests[$qid][correct]),trim(strtolower($thisanswer))) >-1){
773  
-                $qtally[$qid][correct]++;
774  
-                $returndata[score] = 1;
  794
+            if (strpos(strtolower($quests[$qid]['correct']),trim(strtolower($thisanswer))) >-1){
  795
+                $qtally[$qid]['correct']++;
  796
+                $returndata['score'] = 1;
775 797
             }
776 798
             break;
777 799
         case 2:  //TRUEFALSE
778  
-            $returndata[data] = $quests[$qid][choice][$thisanswer][answer];
779  
-            $qtally[$qid][$quests[$qid][choice][$thisanswer][answer]]++;
780  
-            if ($quests[$qid][correct]==$quests[$qid][choice][$thisanswer][answer]){
781  
-                $returndata[score] = 1;
782  
-                $qtally[$qid][correct]++;
  800
+            $returndata['data'] = $quests[$qid]['choice'][$thisanswer]['answer'];
  801
+            $qtally[$qid][$quests[$qid]['choice'][$thisanswer]['answer']]++;
  802
+            if ($quests[$qid]['correct']==$quests[$qid]['choice'][$thisanswer]['answer']){
  803
+                $returndata['score'] = 1;
  804
+                $qtally[$qid]['correct']++;
783 805
             }
784 806
             break;
785 807
         case 3:  //MULTICHOICE
786  
-            $returndata[data] = $quests[$qid][choice][$thisanswer][choiceno];
787  
-            if($max_choices < $returndata[data]) {$max_choices = $returndata[data];}
788  
-            $qtally[$qid][$quests[$qid][choice][$thisanswer][choiceno]]++;
789  
-            if (strtolower($quests[$qid][correct])==strtolower($quests[$qid][choice][$thisanswer][choiceno])){
790  
-                $returndata[score] = 1;
791  
-                $qtally[$qid][correct]++;
  808
+            $returndata['data'] = $quests[$qid]['choice'][$thisanswer]['choiceno'];
  809
+            if($max_choices < $returndata['data']) {$max_choices = $returndata['data'];}
  810
+            $qtally[$qid][$quests[$qid]['choice'][$thisanswer]['choiceno']]++;
  811
+            if (strtolower($quests[$qid]['correct'])==strtolower($quests[$qid]['choice'][$thisanswer]['choiceno'])){
  812
+                $returndata['score'] = 1;
  813
+                $qtally[$qid]['correct']++;
792 814
             }
793 815
             break;
794 816
         case 8:  //NUMERICAL
795  
-            $returndata[data] = $thisanswer;
796  
-//            $returndata[data] = $thismin . "<" . $thisanswer . ">" . $thismax;
797  
-            $qtally[$qid][response][$thisanswer]++;
  817
+            $returndata['data'] = $thisanswer;
  818
+//            $returndata['data'] = $thismin . "<" . $thisanswer . ">" . $thismax;
  819
+            $qtally[$qid]['response'][$thisanswer]++;
798 820
             if ($thisanswer >= $thismin[$qid] and $thisanswer <= $thismax[$qid]){
799  
-                $qtally[$qid][correct]++;
800  
-                $returndata[score] = 1;
  821
+                $qtally[$qid]['correct']++;
  822
+                $returndata['score'] = 1;
801 823
             }
802 824
             break;
803 825
     }
@@ -819,7 +841,7 @@ function qr_match_array($nowQ){
819 841
     //builds an array of all questions and answers for match questions in the quiz for use in qr_match_table
820 842
     global $quiz_matches,$quiz_match_hdrs;
821 843
 //make an array of all Q & As for match questions
822  
-//format:  $quiz_matches[quiz_match_sub_id][Q or A]
  844
+//format:  $quiz_matches['quiz_match_sub_id'][Q or A]
823 845
     $allmatch = get_records("quiz_match_sub","question",$nowQ);
824 846
 //    //print_object($allmatch);
825 847
     $hdrcnt=0;

0 notes on commit 21e98e2

Please sign in to comment.
Something went wrong with that request. Please try again.