Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lesson/report.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00027 require_once('../../config.php');
00028 require_once($CFG->dirroot.'/mod/lesson/locallib.php');
00029 
00030 $id     = required_param('id', PARAM_INT);    // Course Module ID
00031 $pageid = optional_param('pageid', NULL, PARAM_INT);    // Lesson Page ID
00032 $action = optional_param('action', 'reportoverview', PARAM_ALPHA);  // action to take
00033 $nothingtodisplay = false;
00034 
00035 $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);
00036 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
00037 $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
00038 
00039 require_login($course, false, $cm);
00040 
00041 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00042 require_capability('mod/lesson:manage', $context);
00043 
00044 $ufields = user_picture::fields('u'); // These fields are enough
00045 $params = array("lessonid" => $lesson->id);
00046 // TODO: Improve this. Fetching all students always is crazy!
00047 if (!empty($cm->groupingid)) {
00048     $params["groupid"] = $cm->groupingid;
00049     $sql = "SELECT DISTINCT $ufields
00050                 FROM {lesson_attempts} a
00051                     INNER JOIN {user} u ON u.id = a.userid
00052                     INNER JOIN {groups_members} gm ON gm.userid = u.id
00053                     INNER JOIN {groupings_groups} gg ON gm.groupid = :groupid
00054                 WHERE a.lessonid = :lessonid
00055                 ORDER BY u.lastname";
00056 } else {
00057     $sql = "SELECT DISTINCT $ufields
00058             FROM {user} u,
00059                  {lesson_attempts} a
00060             WHERE a.lessonid = :lessonid and
00061                   u.id = a.userid
00062             ORDER BY u.lastname";
00063 }
00064 
00065 if (! $students = $DB->get_records_sql($sql, $params)) {
00066     $nothingtodisplay = true;
00067 }
00068 
00069 $url = new moodle_url('/mod/lesson/report.php', array('id'=>$id));
00070 if ($action !== 'reportoverview') {
00071     $url->param('action', $action);
00072 }
00073 if ($pageid !== NULL) {
00074     $url->param('pageid', $pageid);
00075 }
00076 $PAGE->set_url($url);
00077 if ($action == 'reportoverview') {
00078     $PAGE->navbar->add(get_string('reports', 'lesson'));
00079     $PAGE->navbar->add(get_string('overview', 'lesson'));
00080 }
00081 
00082 $lessonoutput = $PAGE->get_renderer('mod_lesson');
00083 
00084 if (! $attempts = $DB->get_records('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen')) {
00085     $nothingtodisplay = true;
00086 }
00087 
00088 if (! $grades = $DB->get_records('lesson_grades', array('lessonid' => $lesson->id), 'completed')) {
00089     $grades = array();
00090 }
00091 
00092 if (! $times = $DB->get_records('lesson_timer', array('lessonid' => $lesson->id), 'starttime')) {
00093     $times = array();
00094 }
00095 
00096 if ($nothingtodisplay) {
00097     echo $lessonoutput->header($lesson, $cm, $action);
00098     echo $OUTPUT->notification(get_string('nolessonattempts', 'lesson'));
00099     echo $OUTPUT->footer();
00100     exit();
00101 }
00102 
00103 if ($action === 'delete') {
00105     if (has_capability('mod/lesson:edit', $context) and $form = data_submitted() and confirm_sesskey()) {
00107         if (!empty($form->attempts)) {
00108             foreach ($form->attempts as $userid => $tries) {
00109                 // Modifier IS VERY IMPORTANT!  What does it do?
00110                 //      Well, it is for when you delete multiple attempts for the same user.
00111                 //      If you delete try 1 and 3 for a user, then after deleting try 1, try 3 then
00112                 //      becomes try 2 (because try 1 is gone and all tries after try 1 get decremented).
00113                 //      So, the modifier makes sure that the submitted try refers to the current try in the
00114                 //      database - hope this all makes sense :)
00115                 $modifier = 0;
00116 
00117                 foreach ($tries as $try => $junk) {
00118                     $try -= $modifier;
00119 
00121                     $params = array ("userid" => $userid, "lessonid" => $lesson->id);
00122                     $timers = $DB->get_records_sql("SELECT id FROM {lesson_timer}
00123                                                      WHERE userid = :userid AND lessonid = :lessonid
00124                                                   ORDER BY starttime", $params, $try, 1);
00125                     if ($timers) {
00126                         $timer = reset($timers);
00127                         $DB->delete_records('lesson_timer', array('id' => $timer->id));
00128                     }
00129 
00131                     $grades = $DB->get_records_sql("SELECT id FROM {lesson_grades}
00132                                                      WHERE userid = :userid AND lessonid = :lessonid
00133                                                   ORDER BY completed", $params, $try, 1);
00134 
00135                     if ($grades) {
00136                         $grade = reset($grades);
00137                         $DB->delete_records('lesson_grades', array('id' => $grade->id));
00138                         $DB->delete_records('lesson_high_scores', array('gradeid' => $grade->id, 'lessonid' => $lesson->id, 'userid' => $userid));
00139                     }
00140 
00142                     $DB->delete_records('lesson_attempts', array('userid' => $userid, 'lessonid' => $lesson->id, 'retry' => $try));
00143                     $DB->execute("UPDATE {lesson_attempts} SET retry = retry - 1 WHERE userid = ? AND lessonid = ? AND retry > ?", array($userid, $lesson->id, $try));
00144 
00146                     $DB->delete_records('lesson_branch', array('userid' => $userid, 'lessonid' => $lesson->id, 'retry' => $try));
00147                     $DB->execute("UPDATE {lesson_branch} SET retry = retry - 1 WHERE userid = ? AND lessonid = ? AND retry > ?", array($userid, $lesson->id, $try));
00148 
00150                     lesson_update_grades($lesson, $userid);
00151 
00152                     $modifier++;
00153                 }
00154             }
00155         }
00156     }
00157     redirect(new moodle_url($PAGE->url, array('action'=>'reportoverview')));
00158 
00159 } else if ($action === 'reportoverview') {
00160     /**************************************************************************
00161     this action is for default view and overview view
00162     **************************************************************************/
00163     echo $lessonoutput->header($lesson, $cm, $action);
00164 
00165     $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
00166     if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
00167         $seeallgradeslink = new moodle_url('/grade/report/grader/index.php', array('id'=>$course->id));
00168         $seeallgradeslink = html_writer::link($seeallgradeslink, get_string('seeallcoursegrades', 'grades'));
00169         echo $OUTPUT->box($seeallgradeslink, 'allcoursegrades');
00170     }
00171 
00172     $studentdata = array();
00173 
00174     // build an array for output
00175     foreach ($attempts as $attempt) {
00176         // if the user is not in the array or if the retry number is not in the sub array, add the data for that try.
00177         if (!array_key_exists($attempt->userid, $studentdata) || !array_key_exists($attempt->retry, $studentdata[$attempt->userid])) {
00178             // restore/setup defaults
00179             $n = 0;
00180             $timestart = 0;
00181             $timeend = 0;
00182             $usergrade = NULL;
00183 
00184             // search for the grade record for this try. if not there, the nulls defined above will be used.
00185             foreach($grades as $grade) {
00186                 // check to see if the grade matches the correct user
00187                 if ($grade->userid == $attempt->userid) {
00188                     // see if n is = to the retry
00189                     if ($n == $attempt->retry) {
00190                         // get grade info
00191                         $usergrade = round($grade->grade, 2); // round it here so we only have to do it once
00192                         break;
00193                     }
00194                     $n++; // if not equal, then increment n
00195                 }
00196             }
00197             $n = 0;
00198             // search for the time record for this try. if not there, the nulls defined above will be used.
00199             foreach($times as $time) {
00200                 // check to see if the grade matches the correct user
00201                 if ($time->userid == $attempt->userid) {
00202                     // see if n is = to the retry
00203                     if ($n == $attempt->retry) {
00204                         // get grade info
00205                         $timeend = $time->lessontime;
00206                         $timestart = $time->starttime;
00207                         break;
00208                     }
00209                     $n++; // if not equal, then increment n
00210                 }
00211             }
00212 
00213             // build up the array.
00214             // this array represents each student and all of their tries at the lesson
00215             $studentdata[$attempt->userid][$attempt->retry] = array( "timestart" => $timestart,
00216                                                                     "timeend" => $timeend,
00217                                                                     "grade" => $usergrade,
00218                                                                     "try" => $attempt->retry,
00219                                                                     "userid" => $attempt->userid);
00220         }
00221     }
00222     // set all the stats variables
00223     $numofattempts = 0;
00224     $avescore      = 0;
00225     $avetime       = 0;
00226     $highscore     = NULL;
00227     $lowscore      = NULL;
00228     $hightime      = NULL;
00229     $lowtime       = NULL;
00230 
00231     $table = new html_table();
00232 
00233     // set up the table object
00234     $table->head = array(get_string('name'), get_string('attempts', 'lesson'), get_string('highscore', 'lesson'));
00235     $table->align = array('center', 'left', 'left');
00236     $table->wrap = array('nowrap', 'nowrap', 'nowrap');
00237     $table->attributes['class'] = 'standardtable generaltable';
00238     $table->size = array(null, '70%', null);
00239 
00240     // print out the $studentdata array
00241     // going through each student that has attempted the lesson, so, each student should have something to be displayed
00242     foreach ($students as $student) {
00243         // check to see if the student has attempts to print out
00244         if (array_key_exists($student->id, $studentdata)) {
00245             // set/reset some variables
00246             $attempts = array();
00247             // gather the data for each user attempt
00248             $bestgrade = 0;
00249             $bestgradefound = false;
00250             // $tries holds all the tries/retries a student has done
00251             $tries = $studentdata[$student->id];
00252             $studentname = "{$student->lastname},&nbsp;$student->firstname";
00253             foreach ($tries as $try) {
00254             // start to build up the checkbox and link
00255                 if (has_capability('mod/lesson:edit', $context)) {
00256                     $temp = '<input type="checkbox" id="attempts" name="attempts['.$try['userid'].']['.$try['try'].']" /> ';
00257                 } else {
00258                     $temp = '';
00259                 }
00260 
00261                 $temp .= "<a href=\"report.php?id=$cm->id&amp;action=reportdetail&amp;userid=".$try['userid'].'&amp;try='.$try['try'].'">';
00262                 if ($try["grade"] !== NULL) { // if NULL then not done yet
00263                     // this is what the link does when the user has completed the try
00264                     $timetotake = $try["timeend"] - $try["timestart"];
00265 
00266                     $temp .= $try["grade"]."%";
00267                     $bestgradefound = true;
00268                     if ($try["grade"] > $bestgrade) {
00269                         $bestgrade = $try["grade"];
00270                     }
00271                     $temp .= "&nbsp;".userdate($try["timestart"]);
00272                     $temp .= ",&nbsp;(".format_time($timetotake).")</a>";
00273                 } else {
00274                     // this is what the link does/looks like when the user has not completed the try
00275                     $temp .= get_string("notcompleted", "lesson");
00276                     $temp .= "&nbsp;".userdate($try["timestart"])."</a>";
00277                     $timetotake = NULL;
00278                 }
00279                 // build up the attempts array
00280                 $attempts[] = $temp;
00281 
00282                 // run these lines for the stats only if the user finnished the lesson
00283                 if ($try["grade"] !== NULL) {
00284                     $numofattempts++;
00285                     $avescore += $try["grade"];
00286                     $avetime += $timetotake;
00287                     if ($try["grade"] > $highscore || $highscore == NULL) {
00288                         $highscore = $try["grade"];
00289                     }
00290                     if ($try["grade"] < $lowscore || $lowscore == NULL) {
00291                         $lowscore = $try["grade"];
00292                     }
00293                     if ($timetotake > $hightime || $hightime == NULL) {
00294                         $hightime = $timetotake;
00295                     }
00296                     if ($timetotake < $lowtime || $lowtime == NULL) {
00297                         $lowtime = $timetotake;
00298                     }
00299                 }
00300             }
00301             // get line breaks in after each attempt
00302             $attempts = implode("<br />\n", $attempts);
00303             // add it to the table data[] object
00304             $table->data[] = array($studentname, $attempts, $bestgrade."%");
00305         }
00306     }
00307     // print it all out !
00308     if (has_capability('mod/lesson:edit', $context)) {
00309         echo  "<form id=\"theform\" method=\"post\" action=\"report.php\">\n
00310                <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n
00311                <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
00312     }
00313     echo html_writer::table($table);
00314     if (has_capability('mod/lesson:edit', $context)) {
00315         $checklinks  = '<a href="javascript: checkall();">'.get_string('selectall').'</a> / ';
00316         $checklinks .= '<a href="javascript: checknone();">'.get_string('deselectall').'</a>';
00317         $checklinks .= html_writer::select(array('delete' => get_string('deleteselected')), 'action', 0, array(''=>'choosedots'), array('id'=>'actionid'));
00318         $PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('theform', 'actionid', ''));
00319         echo $OUTPUT->box($checklinks, 'center');
00320         echo '</form>';
00321     }
00322 
00323     // some stat calculations
00324     if ($numofattempts == 0) {
00325         $avescore = get_string("notcompleted", "lesson");
00326     } else {
00327         $avescore = format_float($avescore/$numofattempts, 2);
00328     }
00329     if ($avetime == NULL) {
00330         $avetime = get_string("notcompleted", "lesson");
00331     } else {
00332         $avetime = format_float($avetime/$numofattempts, 0);
00333         $avetime = format_time($avetime);
00334     }
00335     if ($hightime == NULL) {
00336         $hightime = get_string("notcompleted", "lesson");
00337     } else {
00338         $hightime = format_time($hightime);
00339     }
00340     if ($lowtime == NULL) {
00341         $lowtime = get_string("notcompleted", "lesson");
00342     } else {
00343         $lowtime = format_time($lowtime);
00344     }
00345     if ($highscore == NULL) {
00346         $highscore = get_string("notcompleted", "lesson");
00347     }
00348     if ($lowscore == NULL) {
00349         $lowscore = get_string("notcompleted", "lesson");
00350     }
00351 
00352     // output the stats
00353     echo $OUTPUT->heading(get_string('lessonstats', 'lesson'));
00354     $stattable = new html_table();
00355     $stattable->head = array(get_string('averagescore', 'lesson'), get_string('averagetime', 'lesson'),
00356                             get_string('highscore', 'lesson'), get_string('lowscore', 'lesson'),
00357                             get_string('hightime', 'lesson'), get_string('lowtime', 'lesson'));
00358     $stattable->align = array('center', 'center', 'center', 'center', 'center', 'center');
00359     $stattable->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
00360     $stattable->attributes['class'] = 'standardtable generaltable';
00361     $stattable->data[] = array($avescore.'%', $avetime, $highscore.'%', $lowscore.'%', $hightime, $lowtime);
00362 
00363     echo html_writer::table($stattable);
00364 } else if ($action === 'reportdetail') {
00365     /**************************************************************************
00366     this action is for a student detailed view and for the general detailed view
00367 
00368     General flow of this section of the code
00369     1.  Generate a object which holds values for the statistics for each question/answer
00370     2.  Cycle through all the pages to create a object.  Foreach page, see if the student actually answered
00371         the page.  Then process the page appropriatly.  Display all info about the question,
00372         Highlight correct answers, show how the user answered the question, and display statistics
00373         about each page
00374     3.  Print out info about the try (if needed)
00375     4.  Print out the object which contains all the try info
00376 
00377 **************************************************************************/
00378     echo $lessonoutput->header($lesson, $cm, $action);
00379 
00380     $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
00381     if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
00382         $seeallgradeslink = new moodle_url('/grade/report/grader/index.php', array('id'=>$course->id));
00383         $seeallgradeslink = html_writer::link($seeallgradeslink, get_string('seeallcoursegrades', 'grades'));
00384         echo $OUTPUT->box($seeallgradeslink, 'allcoursegrades');
00385     }
00386 
00387     $formattextdefoptions = new stdClass;
00388     $formattextdefoptions->para = false;  //I'll use it widely in this page
00389     $formattextdefoptions->overflowdiv = true;
00390 
00391     $userid = optional_param('userid', NULL, PARAM_INT); // if empty, then will display the general detailed view
00392     $try    = optional_param('try', NULL, PARAM_INT);
00393 
00394     $lessonpages = $lesson->load_all_pages();
00395     foreach ($lessonpages as $lessonpage) {
00396         if ($lessonpage->prevpageid == 0) {
00397             $pageid = $lessonpage->id;
00398         }
00399     }
00400 
00401     // now gather the stats into an object
00402     $firstpageid = $pageid;
00403     $pagestats = array();
00404     while ($pageid != 0) { // EOL
00405         $page = $lessonpages[$pageid];
00406         $params = array ("lessonid" => $lesson->id, "pageid" => $page->id);
00407         if ($allanswers = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND pageid = :pageid", $params, "timeseen")) {
00408             // get them ready for processing
00409             $orderedanswers = array();
00410             foreach ($allanswers as $singleanswer) {
00411                 // ordering them like this, will help to find the single attempt record that we want to keep.
00412                 $orderedanswers[$singleanswer->userid][$singleanswer->retry][] = $singleanswer;
00413             }
00414             // this is foreach user and for each try for that user, keep one attempt record
00415             foreach ($orderedanswers as $orderedanswer) {
00416                 foreach($orderedanswer as $tries) {
00417                     $page->stats($pagestats, $tries);
00418                 }
00419             }
00420         } else {
00421             // no one answered yet...
00422         }
00423         //unset($orderedanswers);  initialized above now
00424         $pageid = $page->nextpageid;
00425     }
00426 
00427     $manager = lesson_page_type_manager::get($lesson);
00428     $qtypes = $manager->get_page_type_strings();
00429 
00430     $answerpages = array();
00431     $answerpage = "";
00432     $pageid = $firstpageid;
00433     // cycle through all the pages
00434     //  foreach page, add to the $answerpages[] array all the data that is needed
00435     //  from the question, the users attempt, and the statistics
00436     // grayout pages that the user did not answer and Branch, end of branch, cluster
00437     // and end of cluster pages
00438     while ($pageid != 0) { // EOL
00439         $page = $lessonpages[$pageid];
00440         $answerpage = new stdClass;
00441         $data ='';
00442         
00443         $answerdata = new stdClass;
00444         // Set some defaults for the answer data.
00445         $answerdata->score = NULL;
00446         $answerdata->response = NULL;
00447         $answerdata->responseformat = FORMAT_PLAIN;
00448 
00449         $answerpage->title = format_string($page->title);
00450 
00451         $options = new stdClass;
00452         $options->noclean = true;
00453         $options->overflowdiv = true;
00454         $answerpage->contents = format_text($page->contents, $page->contentsformat, $options);
00455 
00456         $answerpage->qtype = $qtypes[$page->qtype].$page->option_description_string();
00457         $answerpage->grayout = $page->grayout;
00458         $answerpage->context = $context;
00459 
00460         if (empty($userid)) {
00461             // there is no userid, so set these vars and display stats.
00462             $answerpage->grayout = 0;
00463             $useranswer = NULL;    
00464         } elseif ($useranswers = $DB->get_records("lesson_attempts",array("lessonid"=>$lesson->id, "userid"=>$userid, "retry"=>$try,"pageid"=>$page->id), "timeseen")) {
00465             // get the user's answer for this page
00466             // need to find the right one
00467             $i = 0;
00468             foreach ($useranswers as $userattempt) {
00469                 $useranswer = $userattempt;
00470                 $i++;
00471                 if ($lesson->maxattempts == $i) {
00472                     break; // reached maxattempts, break out
00473                 }
00474             }
00475         } else {
00476             // user did not answer this page, gray it out and set some nulls
00477             $answerpage->grayout = 1;
00478             $useranswer = NULL;
00479         }
00480         $i = 0;
00481         $n = 0;
00482         $answerpages[] = $page->report_answers(clone($answerpage), clone($answerdata), $useranswer, $pagestats, $i, $n);
00483         $pageid = $page->nextpageid;
00484     }
00485 
00487     $table = new html_table();
00488     $table->wrap = array();
00489     $table->width = "60%";
00490     if (!empty($userid)) {
00491         // if looking at a students try, print out some basic stats at the top
00492 
00493             // print out users name
00494             //$headingobject->lastname = $students[$userid]->lastname;
00495             //$headingobject->firstname = $students[$userid]->firstname;
00496             //$headingobject->attempt = $try + 1;
00497             //print_heading(get_string("studentattemptlesson", "lesson", $headingobject));
00498         echo $OUTPUT->heading(get_string('attempt', 'lesson', $try+1));
00499 
00500         $table->head = array();
00501         $table->align = array('right', 'left');
00502         $table->attributes['class'] = 'compacttable generaltable';
00503 
00504         $params = array("lessonid"=>$lesson->id, "userid"=>$userid);
00505         if (!$grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid and userid = :userid", $params, "completed", "*", $try, 1)) {
00506             $grade = -1;
00507             $completed = -1;
00508         } else {
00509             $grade = current($grades);
00510             $completed = $grade->completed;
00511             $grade = round($grade->grade, 2);
00512         }
00513         if (!$times = $DB->get_records_select("lesson_timer", "lessonid = :lessonid and userid = :userid", $params, "starttime", "*", $try, 1)) {
00514             $timetotake = -1;
00515         } else {
00516             $timetotake = current($times);
00517             $timetotake = $timetotake->lessontime - $timetotake->starttime;
00518         }
00519 
00520         if ($timetotake == -1 || $completed == -1 || $grade == -1) {
00521             $table->align = array("center");
00522 
00523             $table->data[] = array(get_string("notcompleted", "lesson"));
00524         } else {
00525             $user = $students[$userid];
00526 
00527             $gradeinfo = lesson_grade($lesson, $try, $user->id);
00528 
00529             $table->data[] = array(get_string('name').':', $OUTPUT->user_picture($user, array('courseid'=>$course->id)).fullname($user, true));
00530             $table->data[] = array(get_string("timetaken", "lesson").":", format_time($timetotake));
00531             $table->data[] = array(get_string("completed", "lesson").":", userdate($completed));
00532             $table->data[] = array(get_string('rawgrade', 'lesson').':', $gradeinfo->earned.'/'.$gradeinfo->total);
00533             $table->data[] = array(get_string("grade", "lesson").":", $grade."%");
00534         }
00535         echo html_writer::table($table);
00536 
00537         // Don't want this class for later tables
00538         $table->attributes['class'] = '';
00539     }
00540 
00541 
00542     $table->align = array('left', 'left');
00543     $table->size = array('70%', null);
00544     $table->attributes['class'] = 'compacttable generaltable';
00545 
00546     foreach ($answerpages as $page) {
00547         unset($table->data);
00548         if ($page->grayout) { // set the color of text
00549             $fontstart = "<span class=\"dimmed\">";
00550             $fontend = "</font>";
00551             $fontstart2 = $fontstart;
00552             $fontend2 = $fontend;
00553         } else {
00554             $fontstart = "";
00555             $fontend = "";
00556             $fontstart2 = "";
00557             $fontend2 = "";
00558         }
00559 
00560         $table->head = array($fontstart2.$page->qtype.": ".format_string($page->title).$fontend2, $fontstart2.get_string("classstats", "lesson").$fontend2);
00561         $table->data[] = array($fontstart.get_string("question", "lesson").": <br />".$fontend.$fontstart2.$page->contents.$fontend2, " ");
00562         $table->data[] = array($fontstart.get_string("answer", "lesson").":".$fontend, ' ');
00563         // apply the font to each answer
00564         if (!empty($page->answerdata)) {
00565             foreach ($page->answerdata->answers as $answer){
00566                 $modified = array();
00567                 foreach ($answer as $single) {
00568                     // need to apply a font to each one
00569                     $modified[] = $fontstart2.$single.$fontend2;
00570                 }
00571                 $table->data[] = $modified;
00572             }
00573             if (isset($page->answerdata->response)) {
00574                 $table->data[] = array($fontstart.get_string("response", "lesson").": <br />".$fontend.$fontstart2.format_text($page->answerdata->response,$page->answerdata->responseformat,$formattextdefoptions).$fontend2, " ");
00575             }
00576             $table->data[] = array($page->answerdata->score, " ");
00577         } else {
00578             $table->data[] = array(get_string('didnotanswerquestion', 'lesson'), " ");
00579         }
00580         echo html_writer::table($table);
00581     }
00582 } else {
00583     print_error('unknowaction');
00584 }
00585 
00587 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations