|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00024 defined('MOODLE_INTERNAL') || die(); 00025 00026 require_once($CFG->dirroot.'/mod/scorm/report/interactions/responsessettings_form.php'); 00027 00028 class scorm_interactions_report extends scorm_default_report { 00036 function display($scorm, $cm, $course, $download) { 00037 global $CFG, $DB, $OUTPUT, $PAGE; 00038 $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id); 00039 $action = optional_param('action', '', PARAM_ALPHA); 00040 $attemptids = optional_param_array('attemptid', array(), PARAM_RAW); 00041 $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT); 00042 $PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode))); 00043 00044 if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) { 00045 if (scorm_delete_responses($attemptids, $scorm)) { //delete responses. 00046 add_to_log($course->id, 'scorm', 'delete attempts', 'report.php?id=' . $cm->id, implode(",", $attemptids), $cm->id); 00047 echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess'); 00048 } 00049 } 00050 // find out current groups mode 00051 $currentgroup = groups_get_activity_group($cm, true); 00052 00053 // detailed report 00054 $mform = new mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup')); 00055 if ($fromform = $mform->get_data()) { 00056 $pagesize = $fromform->pagesize; 00057 $includeqtext = $fromform->qtext; 00058 $includeresp = $fromform->resp; 00059 $includeright = $fromform->right; 00060 set_user_preference('scorm_report_pagesize', $pagesize); 00061 set_user_preference('scorm_report_interactions_qtext', $includeqtext); 00062 set_user_preference('scorm_report_interactions_resp', $includeresp); 00063 set_user_preference('scorm_report_interactions_right', $includeright); 00064 } else { 00065 $pagesize = get_user_preferences('scorm_report_pagesize', 0); 00066 $includeqtext = get_user_preferences('scorm_report_interactions_qtext', 0); 00067 $includeresp = get_user_preferences('scorm_report_interactions_resp', 1); 00068 $includeright = get_user_preferences('scorm_report_interactions_right', 0); 00069 } 00070 if ($pagesize < 1) { 00071 $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE; 00072 } 00073 00074 // select group menu 00075 $displayoptions = array(); 00076 $displayoptions['attemptsmode'] = $attemptsmode; 00077 $displayoptions['qtext'] = $includeqtext; 00078 $displayoptions['resp'] = $includeresp; 00079 $displayoptions['right'] = $includeright; 00080 00081 $mform->set_data($displayoptions + array('pagesize' => $pagesize)); 00082 if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used 00083 if (!$download) { 00084 groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions)); 00085 } 00086 } 00087 $formattextoptions = array('context' => get_context_instance(CONTEXT_COURSE, $course->id)); 00088 00089 // We only want to show the checkbox to delete attempts 00090 // if the user has permissions and if the report mode is showing attempts. 00091 $candelete = has_capability('mod/scorm:deleteresponses', $contextmodule) 00092 && ($attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO); 00093 // select the students 00094 $nostudents = false; 00095 00096 if (empty($currentgroup)) { 00097 // all users who can attempt scoes 00098 if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', '', '', false)) { 00099 echo $OUTPUT->notification(get_string('nostudentsyet')); 00100 $nostudents = true; 00101 $allowedlist = ''; 00102 } else { 00103 $allowedlist = array_keys($students); 00104 } 00105 } else { 00106 // all users who can attempt scoes and who are in the currently selected group 00107 if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', $currentgroup, '', false)) { 00108 echo $OUTPUT->notification(get_string('nostudentsingroup')); 00109 $nostudents = true; 00110 $groupstudents = array(); 00111 } 00112 $allowedlist = array_keys($groupstudents); 00113 } 00114 if ( !$nostudents ) { 00115 // Now check if asked download of data 00116 $coursecontext = context_course::instance($course->id); 00117 if ($download) { 00118 $filename = clean_filename("$course->shortname ".format_string($scorm->name, true,$formattextoptions)); 00119 } 00120 00121 // Define table columns 00122 $columns = array(); 00123 $headers = array(); 00124 if (!$download && $candelete) { 00125 $columns[] = 'checkbox'; 00126 $headers[] = null; 00127 } 00128 if (!$download && $CFG->grade_report_showuserimage) { 00129 $columns[] = 'picture'; 00130 $headers[] = ''; 00131 } 00132 $columns[] = 'fullname'; 00133 $headers[] = get_string('name'); 00134 00135 $extrafields = get_extra_user_fields($coursecontext); 00136 foreach ($extrafields as $field) { 00137 $columns[] = $field; 00138 $headers[] = get_user_field_name($field); 00139 } 00140 $columns[] = 'attempt'; 00141 $headers[] = get_string('attempt', 'scorm'); 00142 $columns[] = 'start'; 00143 $headers[] = get_string('started', 'scorm'); 00144 $columns[] = 'finish'; 00145 $headers[] = get_string('last', 'scorm'); 00146 $columns[] = 'score'; 00147 $headers[] = get_string('score', 'scorm'); 00148 $scoes = $DB->get_records('scorm_scoes', array("scorm"=>$scorm->id), 'id'); 00149 foreach ($scoes as $sco) { 00150 if ($sco->launch != '') { 00151 $columns[] = 'scograde'.$sco->id; 00152 $headers[] = format_string($sco->title,'',$formattextoptions); 00153 } 00154 } 00155 00156 $params = array(); 00157 list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED); 00158 // Construct the SQL 00159 $select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, '; 00160 $select .= 'st.scormid AS scormid, st.attempt AS attempt, ' . 00161 'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email'. 00162 get_extra_user_fields_sql($coursecontext, 'u', '', array('idnumber')) . ' '; 00163 00164 // This part is the same for all cases - join users and scorm_scoes_track tables 00165 $from = 'FROM {user} u '; 00166 $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id; 00167 switch ($attemptsmode) { 00168 case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH: 00169 // Show only students with attempts 00170 $where = ' WHERE u.id ' .$usql. ' AND st.userid IS NOT NULL'; 00171 break; 00172 case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO: 00173 // Show only students without attempts 00174 $where = ' WHERE u.id ' .$usql. ' AND st.userid IS NULL'; 00175 break; 00176 case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS: 00177 // Show all students with or without attempts 00178 $where = ' WHERE u.id ' .$usql. ' AND (st.userid IS NOT NULL OR st.userid IS NULL)'; 00179 break; 00180 } 00181 00182 $countsql = 'SELECT COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').')) AS nbresults, '; 00183 $countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, '; 00184 $countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers '; 00185 $countsql .= $from.$where; 00186 $attempts = $DB->get_records_sql($select.$from.$where, $params); 00187 $questioncount = get_scorm_question_count($scorm->id); 00188 for($id = 0; $id < $questioncount; $id++) { 00189 if ($displayoptions['qtext']) { 00190 $columns[] = 'question' . $id; 00191 $headers[] = get_string('questionx', 'scormreport_interactions', $id); 00192 } 00193 if ($displayoptions['resp']) { 00194 $columns[] = 'response' . $id; 00195 $headers[] = get_string('responsex', 'scormreport_interactions', $id); 00196 } 00197 if ($displayoptions['right']) { 00198 $columns[] = 'right' . $id; 00199 $headers[] = get_string('rightanswerx', 'scormreport_interactions', $id); 00200 } 00201 } 00202 00203 if (!$download) { 00204 $table = new flexible_table('mod-scorm-report'); 00205 00206 $table->define_columns($columns); 00207 $table->define_headers($headers); 00208 $table->define_baseurl($PAGE->url); 00209 00210 $table->sortable(true); 00211 $table->collapsible(true); 00212 00213 // This is done to prevent redundant data, when a user has multiple attempts 00214 $table->column_suppress('picture'); 00215 $table->column_suppress('fullname'); 00216 foreach ($extrafields as $field) { 00217 $table->column_suppress($field); 00218 } 00219 00220 $table->no_sorting('start'); 00221 $table->no_sorting('finish'); 00222 $table->no_sorting('score'); 00223 00224 foreach ($scoes as $sco) { 00225 if ($sco->launch != '') { 00226 $table->no_sorting('scograde'.$sco->id); 00227 } 00228 } 00229 00230 $table->column_class('picture', 'picture'); 00231 $table->column_class('fullname', 'bold'); 00232 $table->column_class('score', 'bold'); 00233 00234 $table->set_attribute('cellspacing', '0'); 00235 $table->set_attribute('id', 'attempts'); 00236 $table->set_attribute('class', 'generaltable generalbox'); 00237 00238 // Start working -- this is necessary as soon as the niceties are over 00239 $table->setup(); 00240 } else if ($download == 'ODS') { 00241 require_once("$CFG->libdir/odslib.class.php"); 00242 00243 $filename .= ".ods"; 00244 // Creating a workbook 00245 $workbook = new MoodleODSWorkbook("-"); 00246 // Sending HTTP headers 00247 $workbook->send($filename); 00248 // Creating the first worksheet 00249 $sheettitle = get_string('report', 'scorm'); 00250 $myxls =& $workbook->add_worksheet($sheettitle); 00251 // format types 00252 $format =& $workbook->add_format(); 00253 $format->set_bold(0); 00254 $formatbc =& $workbook->add_format(); 00255 $formatbc->set_bold(1); 00256 $formatbc->set_align('center'); 00257 $formatb =& $workbook->add_format(); 00258 $formatb->set_bold(1); 00259 $formaty =& $workbook->add_format(); 00260 $formaty->set_bg_color('yellow'); 00261 $formatc =& $workbook->add_format(); 00262 $formatc->set_align('center'); 00263 $formatr =& $workbook->add_format(); 00264 $formatr->set_bold(1); 00265 $formatr->set_color('red'); 00266 $formatr->set_align('center'); 00267 $formatg =& $workbook->add_format(); 00268 $formatg->set_bold(1); 00269 $formatg->set_color('green'); 00270 $formatg->set_align('center'); 00271 // Here starts workshhet headers 00272 00273 $colnum = 0; 00274 foreach ($headers as $item) { 00275 $myxls->write(0, $colnum, $item, $formatbc); 00276 $colnum++; 00277 } 00278 $rownum = 1; 00279 } else if ($download =='Excel') { 00280 require_once("$CFG->libdir/excellib.class.php"); 00281 00282 $filename .= ".xls"; 00283 // Creating a workbook 00284 $workbook = new MoodleExcelWorkbook("-"); 00285 // Sending HTTP headers 00286 $workbook->send($filename); 00287 // Creating the first worksheet 00288 $sheettitle = get_string('report', 'scorm'); 00289 $myxls =& $workbook->add_worksheet($sheettitle); 00290 // format types 00291 $format =& $workbook->add_format(); 00292 $format->set_bold(0); 00293 $formatbc =& $workbook->add_format(); 00294 $formatbc->set_bold(1); 00295 $formatbc->set_align('center'); 00296 $formatb =& $workbook->add_format(); 00297 $formatb->set_bold(1); 00298 $formaty =& $workbook->add_format(); 00299 $formaty->set_bg_color('yellow'); 00300 $formatc =& $workbook->add_format(); 00301 $formatc->set_align('center'); 00302 $formatr =& $workbook->add_format(); 00303 $formatr->set_bold(1); 00304 $formatr->set_color('red'); 00305 $formatr->set_align('center'); 00306 $formatg =& $workbook->add_format(); 00307 $formatg->set_bold(1); 00308 $formatg->set_color('green'); 00309 $formatg->set_align('center'); 00310 00311 $colnum = 0; 00312 foreach ($headers as $item) { 00313 $myxls->write(0, $colnum, $item, $formatbc); 00314 $colnum++; 00315 } 00316 $rownum = 1; 00317 } else if ($download == 'CSV') { 00318 $filename .= ".txt"; 00319 header("Content-Type: application/download\n"); 00320 header("Content-Disposition: attachment; filename=\"$filename\""); 00321 header("Expires: 0"); 00322 header("Cache-Control: must-revalidate,post-check=0,pre-check=0"); 00323 header("Pragma: public"); 00324 echo implode("\t", $headers)." \n"; 00325 } 00326 00327 if (!$download) { 00328 $sort = $table->get_sql_sort(); 00329 } else { 00330 $sort = ''; 00331 } 00332 // Fix some wired sorting 00333 if (empty($sort)) { 00334 $sort = ' ORDER BY uniqueid'; 00335 } else { 00336 $sort = ' ORDER BY '.$sort; 00337 } 00338 00339 if (!$download) { 00340 // Add extra limits due to initials bar 00341 list($twhere, $tparams) = $table->get_sql_where(); 00342 if ($twhere) { 00343 $where .= ' AND '.$twhere; //initial bar 00344 $params = array_merge($params, $tparams); 00345 } 00346 00347 if (!empty($countsql)) { 00348 $count = $DB->get_record_sql($countsql,$params); 00349 $totalinitials = $count->nbresults; 00350 if ($twhere) { 00351 $countsql .= ' AND '.$twhere; 00352 } 00353 $count = $DB->get_record_sql($countsql, $params); 00354 $total = $count->nbresults; 00355 } 00356 00357 $table->pagesize($pagesize, $total); 00358 00359 echo '<div class="quizattemptcounts">'; 00360 if ( $count->nbresults == $count->nbattempts ) { 00361 echo get_string('reportcountattempts', 'scorm', $count); 00362 } else if ( $count->nbattempts>0 ) { 00363 echo get_string('reportcountallattempts', 'scorm', $count); 00364 } else { 00365 echo $count->nbusers.' '.get_string('users'); 00366 } 00367 echo '</div>'; 00368 } 00369 00370 // Fetch the attempts 00371 if (!$download) { 00372 $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params, 00373 $table->get_page_start(), $table->get_page_size()); 00374 echo '<div id="scormtablecontainer">'; 00375 if ($candelete) { 00376 // Start form 00377 $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm')); 00378 echo '<form id="attemptsform" method="post" action="' . $PAGE->url->out(false) . 00379 '" onsubmit="return confirm(\''.$strreallydel.'\');">'; 00380 echo '<input type="hidden" name="action" value="delete"/>'; 00381 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; 00382 echo '<div style="display: none;">'; 00383 echo html_writer::input_hidden_params($PAGE->url); 00384 echo '</div>'; 00385 echo '<div>'; 00386 } 00387 $table->initialbars($totalinitials>20); // Build table rows 00388 } else { 00389 $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params); 00390 } 00391 if ($attempts) { 00392 foreach ($attempts as $scouser) { 00393 $row = array(); 00394 if (!empty($scouser->attempt)) { 00395 $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt); 00396 } else { 00397 $timetracks = ''; 00398 } 00399 if (in_array('checkbox', $columns)) { 00400 if ($candelete && !empty($timetracks->start)) { 00401 $row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid . ':' . $scouser->attempt . '" />'; 00402 } else if ($candelete) { 00403 $row[] = ''; 00404 } 00405 } 00406 if (in_array('picture', $columns)) { 00407 $user = (object)array( 00408 'id'=>$scouser->userid, 00409 'picture'=>$scouser->picture, 00410 'imagealt'=>$scouser->imagealt, 00411 'email'=>$scouser->email, 00412 'firstname'=>$scouser->firstname, 00413 'lastname'=>$scouser->lastname); 00414 $row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id)); 00415 } 00416 if (!$download) { 00417 $row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&course='.$course->id.'">'.fullname($scouser).'</a>'; 00418 } else { 00419 $row[] = fullname($scouser); 00420 } 00421 foreach ($extrafields as $field) { 00422 $row[] = s($scouser->{$field}); 00423 } 00424 if (empty($timetracks->start)) { 00425 $row[] = '-'; 00426 $row[] = '-'; 00427 $row[] = '-'; 00428 $row[] = '-'; 00429 } else { 00430 if (!$download) { 00431 $row[] = '<a href="userreport.php?a='.$scorm->id.'&user='.$scouser->userid.'&attempt='.$scouser->attempt.'">'.$scouser->attempt.'</a>'; 00432 } else { 00433 $row[] = $scouser->attempt; 00434 } 00435 if ($download =='ODS' || $download =='Excel' ) { 00436 $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig")); 00437 } else { 00438 $row[] = userdate($timetracks->start); 00439 } 00440 if ($download =='ODS' || $download =='Excel' ) { 00441 $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig')); 00442 } else { 00443 $row[] = userdate($timetracks->finish); 00444 } 00445 $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt); 00446 } 00447 // print out all scores of attempt 00448 foreach ($scoes as $sco) { 00449 if ($sco->launch != '') { 00450 if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) { 00451 if ($trackdata->status == '') { 00452 $trackdata->status = 'notattempted'; 00453 } 00454 $strstatus = get_string($trackdata->status, 'scorm'); 00455 // if raw score exists, print it 00456 if ($trackdata->score_raw != '') { 00457 $score = $trackdata->score_raw; 00458 // add max score if it exists 00459 if ($scorm->version == 'SCORM_1.3') { 00460 $maxkey = 'cmi.score.max'; 00461 } else { 00462 $maxkey = 'cmi.core.score.max'; 00463 } 00464 if (isset($trackdata->$maxkey)) { 00465 $score .= '/'.$trackdata->$maxkey; 00466 } 00467 // else print out status 00468 } else { 00469 $score = $strstatus; 00470 } 00471 if (!$download) { 00472 $row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/> 00473 <a href="userreport.php?b='.$sco->id.'&user='.$scouser->userid.'&attempt='.$scouser->attempt. 00474 '" title="'.get_string('details', 'scorm').'">'.$score.'</a>'; 00475 } else { 00476 $row[] = $score; 00477 } 00478 // interaction data 00479 $i=0; 00480 $element='cmi.interactions_'.$i.'.id'; 00481 while(isset($trackdata->$element)) { 00482 if ($displayoptions['qtext']) { 00483 $element='cmi.interactions_'.$i.'.id'; 00484 if (isset($trackdata->$element)) { 00485 $row[] = s($trackdata->$element); 00486 } else { 00487 $row[] = ' '; 00488 } 00489 } 00490 if ($displayoptions['resp']) { 00491 $element='cmi.interactions_'.$i.'.student_response'; 00492 if (isset($trackdata->$element)) { 00493 $row[] = s($trackdata->$element); 00494 } else { 00495 $row[] = ' '; 00496 } 00497 } 00498 if ($displayoptions['right']) { 00499 $j=0; 00500 $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern'; 00501 $rightans = ''; 00502 if (isset($trackdata->$element)) { 00503 while(isset($trackdata->$element)) { 00504 if($j>0) { 00505 $rightans .= ','; 00506 } 00507 $rightans .= s($trackdata->$element); 00508 $j++; 00509 $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern'; 00510 } 00511 $row[] = $rightans; 00512 } else { 00513 $row[] = ' '; 00514 } 00515 } 00516 $i++; 00517 $element = 'cmi.interactions_'.$i.'.id'; 00518 } 00519 //---end of interaction data*/ 00520 } else { 00521 // if we don't have track data, we haven't attempted yet 00522 $strstatus = get_string('notattempted', 'scorm'); 00523 if (!$download) { 00524 $row[] = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>'.$strstatus; 00525 } else { 00526 $row[] = $strstatus; 00527 } 00528 } 00529 } 00530 } 00531 00532 if (!$download) { 00533 $table->add_data($row); 00534 } else if ($download == 'Excel' or $download == 'ODS') { 00535 $colnum = 0; 00536 foreach ($row as $item) { 00537 $myxls->write($rownum, $colnum, $item, $format); 00538 $colnum++; 00539 } 00540 $rownum++; 00541 } else if ($download == 'CSV') { 00542 $text = implode("\t", $row); 00543 echo $text." \n"; 00544 } 00545 } 00546 if (!$download) { 00547 $table->finish_output(); 00548 if ($candelete) { 00549 echo '<table id="commands">'; 00550 echo '<tr><td>'; 00551 echo '<a href="javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');">'. 00552 get_string('selectall', 'scorm').'</a> / '; 00553 echo '<a href="javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');">'. 00554 get_string('selectnone', 'scorm').'</a> '; 00555 echo ' '; 00556 echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>'; 00557 echo '</td></tr></table>'; 00558 // Close form 00559 echo '</div>'; 00560 echo '</form>'; 00561 } 00562 echo '</div>'; 00563 if (!empty($attempts)) { 00564 echo '<table class="boxaligncenter"><tr>'; 00565 echo '<td>'; 00566 echo $OUTPUT->single_button(new moodle_url($PAGE->url, 00567 array('download'=>'ODS') + $displayoptions), 00568 get_string('downloadods')); 00569 echo "</td>\n"; 00570 echo '<td>'; 00571 echo $OUTPUT->single_button(new moodle_url($PAGE->url, 00572 array('download'=>'Excel') + $displayoptions), 00573 get_string('downloadexcel')); 00574 echo "</td>\n"; 00575 echo '<td>'; 00576 echo $OUTPUT->single_button(new moodle_url($PAGE->url, 00577 array('download'=>'CSV') + $displayoptions), 00578 get_string('downloadtext')); 00579 echo "</td>\n"; 00580 echo "<td>"; 00581 echo "</td>\n"; 00582 echo '</tr></table>'; 00583 } 00584 } 00585 } else { 00586 if ($candelete && !$download) { 00587 echo '</div>'; 00588 echo '</form>'; 00589 $table->finish_output(); 00590 } 00591 echo '</div>'; 00592 } 00593 // Show preferences form irrespective of attempts are there to report or not 00594 if (!$download) { 00595 $mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode')); 00596 $mform->display(); 00597 } 00598 if ($download == 'Excel' or $download == 'ODS') { 00599 $workbook->close(); 00600 exit; 00601 } else if ($download == 'CSV') { 00602 exit; 00603 } 00604 } else { 00605 echo $OUTPUT->notification(get_string('noactivity', 'scorm')); 00606 } 00607 }// function ends 00608 }