Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 /** 17 * Core Report class of basic reporting plugin 18 * @package scormreport 19 * @subpackage interactions 20 * @author Dan Marsden and Ankit Kumar Agarwal 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 namespace scormreport_interactions; 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 require_once($CFG->dirroot.'/mod/scorm/report/interactions/responsessettings_form.php'); 29 30 class report extends \mod_scorm\report { 31 /** 32 * displays the full report 33 * @param \stdClass $scorm full SCORM object 34 * @param \stdClass $cm - full course_module object 35 * @param \stdClass $course - full course object 36 * @param string $download - type of download being requested 37 */ 38 public function display($scorm, $cm, $course, $download) { 39 global $CFG, $DB, $OUTPUT, $PAGE; 40 41 $contextmodule = \context_module::instance($cm->id); 42 $action = optional_param('action', '', PARAM_ALPHA); 43 $attemptids = optional_param_array('attemptid', array(), PARAM_RAW); 44 $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT); 45 $PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode))); 46 47 if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) { 48 if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses. 49 echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess'); 50 } 51 } 52 // Find out current groups mode. 53 $currentgroup = groups_get_activity_group($cm, true); 54 55 // Detailed report. 56 $mform = new \mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup')); 57 if ($fromform = $mform->get_data()) { 58 $pagesize = $fromform->pagesize; 59 $includeqtext = $fromform->qtext; 60 $includeresp = $fromform->resp; 61 $includeright = $fromform->right; 62 $includeresult = $fromform->result; 63 set_user_preference('scorm_report_pagesize', $pagesize); 64 set_user_preference('scorm_report_interactions_qtext', $includeqtext); 65 set_user_preference('scorm_report_interactions_resp', $includeresp); 66 set_user_preference('scorm_report_interactions_right', $includeright); 67 set_user_preference('scorm_report_interactions_result', $includeresult); 68 } else { 69 $pagesize = get_user_preferences('scorm_report_pagesize', 0); 70 $includeqtext = get_user_preferences('scorm_report_interactions_qtext', 0); 71 $includeresp = get_user_preferences('scorm_report_interactions_resp', 1); 72 $includeright = get_user_preferences('scorm_report_interactions_right', 0); 73 $includeresult = get_user_preferences('scorm_report_interactions_result', 0); 74 } 75 if ($pagesize < 1) { 76 $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE; 77 } 78 79 // Select group menu. 80 $displayoptions = array(); 81 $displayoptions['attemptsmode'] = $attemptsmode; 82 $displayoptions['qtext'] = $includeqtext; 83 $displayoptions['resp'] = $includeresp; 84 $displayoptions['right'] = $includeright; 85 $displayoptions['result'] = $includeresult; 86 87 $mform->set_data($displayoptions + array('pagesize' => $pagesize)); 88 if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used. 89 if (!$download) { 90 groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions)); 91 } 92 } 93 $formattextoptions = array('context' => \context_course::instance($course->id)); 94 95 // We only want to show the checkbox to delete attempts 96 // if the user has permissions and if the report mode is showing attempts. 97 $candelete = has_capability('mod/scorm:deleteresponses', $contextmodule) 98 && ($attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO); 99 // Select the students. 100 $nostudents = false; 101 list($allowedlistsql, $params) = get_enrolled_sql($contextmodule, 'mod/scorm:savetrack', (int) $currentgroup); 102 if (empty($currentgroup)) { 103 // All users who can attempt scoes. 104 if (!$DB->record_exists_sql($allowedlistsql, $params)) { 105 echo $OUTPUT->notification(get_string('nostudentsyet')); 106 $nostudents = true; 107 } 108 } else { 109 // All users who can attempt scoes and who are in the currently selected group. 110 if (!$DB->record_exists_sql($allowedlistsql, $params)) { 111 echo $OUTPUT->notification(get_string('nostudentsingroup')); 112 $nostudents = true; 113 } 114 } 115 if ( !$nostudents ) { 116 // Now check if asked download of data. 117 $coursecontext = \context_course::instance($course->id); 118 if ($download) { 119 $filename = clean_filename("$course->shortname ".format_string($scorm->name, true, $formattextoptions)); 120 } 121 122 // Define table columns. 123 $columns = array(); 124 $headers = array(); 125 if (!$download && $candelete) { 126 $columns[] = 'checkbox'; 127 $headers[] = $this->generate_master_checkbox(); 128 } 129 if (!$download && $CFG->grade_report_showuserimage) { 130 $columns[] = 'picture'; 131 $headers[] = ''; 132 } 133 $columns[] = 'fullname'; 134 $headers[] = get_string('name'); 135 136 // TODO Does not support custom user profile fields (MDL-70456). 137 $extrafields = \core_user\fields::get_identity_fields($coursecontext, false); 138 foreach ($extrafields as $field) { 139 $columns[] = $field; 140 $headers[] = \core_user\fields::get_display_name($field); 141 } 142 $columns[] = 'attempt'; 143 $headers[] = get_string('attempt', 'scorm'); 144 $columns[] = 'start'; 145 $headers[] = get_string('started', 'scorm'); 146 $columns[] = 'finish'; 147 $headers[] = get_string('last', 'scorm'); 148 $columns[] = 'score'; 149 $headers[] = get_string('score', 'scorm'); 150 $scoes = $DB->get_records('scorm_scoes', array("scorm" => $scorm->id), 'sortorder, id'); 151 foreach ($scoes as $sco) { 152 if ($sco->launch != '') { 153 $columns[] = 'scograde'.$sco->id; 154 $headers[] = format_string($sco->title, '', $formattextoptions); 155 } 156 } 157 158 // Construct the SQL. 159 $select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, '; 160 // TODO Does not support custom user profile fields (MDL-70456). 161 $userfields = \core_user\fields::for_identity($coursecontext, false)->with_userpic()->including('idnumber'); 162 $selectfields = $userfields->get_sql('u', false, '', 'userid')->selects; 163 $select .= 'st.scormid AS scormid, st.attempt AS attempt ' . $selectfields . ' '; 164 165 // This part is the same for all cases - join users and scorm_scoes_track tables. 166 $from = 'FROM {user} u '; 167 $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id; 168 switch ($attemptsmode) { 169 case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH: 170 // Show only students with attempts. 171 $where = " WHERE u.id IN ({$allowedlistsql}) AND st.userid IS NOT NULL"; 172 break; 173 case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO: 174 // Show only students without attempts. 175 $where = " WHERE u.id IN ({$allowedlistsql}) AND st.userid IS NULL"; 176 break; 177 case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS: 178 // Show all students with or without attempts. 179 $where = " WHERE u.id IN ({$allowedlistsql}) AND (st.userid IS NOT NULL OR st.userid IS NULL)"; 180 break; 181 } 182 183 $countsql = 'SELECT COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').')) AS nbresults, '; 184 $countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, '; 185 $countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers '; 186 $countsql .= $from.$where; 187 $questioncount = get_scorm_question_count($scorm->id); 188 $nbmaincolumns = count($columns); 189 for ($id = 0; $id < $questioncount; $id++) { 190 if ($displayoptions['qtext']) { 191 $columns[] = 'question' . $id; 192 $headers[] = get_string('questionx', 'scormreport_interactions', $id); 193 } 194 if ($displayoptions['resp']) { 195 $columns[] = 'response' . $id; 196 $headers[] = get_string('responsex', 'scormreport_interactions', $id); 197 } 198 if ($displayoptions['right']) { 199 $columns[] = 'right' . $id; 200 $headers[] = get_string('rightanswerx', 'scormreport_interactions', $id); 201 } 202 if ($displayoptions['result']) { 203 $columns[] = 'result' . $id; 204 $headers[] = get_string('resultx', 'scormreport_interactions', $id); 205 } 206 } 207 208 if (!$download) { 209 $table = new \flexible_table('mod-scorm-report'); 210 211 $table->define_columns($columns); 212 $table->define_headers($headers); 213 $table->define_baseurl($PAGE->url); 214 215 $table->sortable(true); 216 $table->collapsible(true); 217 218 // This is done to prevent redundant data, when a user has multiple attempts. 219 $table->column_suppress('picture'); 220 $table->column_suppress('fullname'); 221 foreach ($extrafields as $field) { 222 $table->column_suppress($field); 223 } 224 225 $table->no_sorting('start'); 226 $table->no_sorting('finish'); 227 $table->no_sorting('score'); 228 $table->no_sorting('checkbox'); 229 $table->no_sorting('picture'); 230 231 for ($id = 0; $id < $questioncount; $id++) { 232 if ($displayoptions['qtext']) { 233 $table->no_sorting('question'.$id); 234 } 235 if ($displayoptions['resp']) { 236 $table->no_sorting('response'.$id); 237 } 238 if ($displayoptions['right']) { 239 $table->no_sorting('right'.$id); 240 } 241 if ($displayoptions['result']) { 242 $table->no_sorting('result'.$id); 243 } 244 } 245 246 foreach ($scoes as $sco) { 247 if ($sco->launch != '') { 248 $table->no_sorting('scograde'.$sco->id); 249 } 250 } 251 252 $table->column_class('picture', 'picture'); 253 $table->column_class('fullname', 'bold'); 254 $table->column_class('score', 'bold'); 255 256 $table->set_attribute('cellspacing', '0'); 257 $table->set_attribute('id', 'attempts'); 258 $table->set_attribute('class', 'generaltable generalbox'); 259 260 // Start working -- this is necessary as soon as the niceties are over. 261 $table->setup(); 262 } else if ($download == 'ODS') { 263 require_once("$CFG->libdir/odslib.class.php"); 264 265 $filename .= ".ods"; 266 // Creating a workbook. 267 $workbook = new \MoodleODSWorkbook("-"); 268 // Sending HTTP headers. 269 $workbook->send($filename); 270 // Creating the first worksheet. 271 $sheettitle = get_string('report', 'scorm'); 272 $myxls = $workbook->add_worksheet($sheettitle); 273 // Format types. 274 $format = $workbook->add_format(); 275 $format->set_bold(0); 276 $formatbc = $workbook->add_format(); 277 $formatbc->set_bold(1); 278 $formatbc->set_align('center'); 279 $formatb = $workbook->add_format(); 280 $formatb->set_bold(1); 281 $formaty = $workbook->add_format(); 282 $formaty->set_bg_color('yellow'); 283 $formatc = $workbook->add_format(); 284 $formatc->set_align('center'); 285 $formatr = $workbook->add_format(); 286 $formatr->set_bold(1); 287 $formatr->set_color('red'); 288 $formatr->set_align('center'); 289 $formatg = $workbook->add_format(); 290 $formatg->set_bold(1); 291 $formatg->set_color('green'); 292 $formatg->set_align('center'); 293 // Here starts workshhet headers. 294 295 $colnum = 0; 296 foreach ($headers as $item) { 297 $myxls->write(0, $colnum, $item, $formatbc); 298 $colnum++; 299 } 300 $rownum = 1; 301 } else if ($download == 'Excel') { 302 require_once("$CFG->libdir/excellib.class.php"); 303 304 $filename .= ".xls"; 305 // Creating a workbook. 306 $workbook = new \MoodleExcelWorkbook("-"); 307 // Sending HTTP headers. 308 $workbook->send($filename); 309 // Creating the first worksheet. 310 $sheettitle = get_string('report', 'scorm'); 311 $myxls = $workbook->add_worksheet($sheettitle); 312 // Format types. 313 $format = $workbook->add_format(); 314 $format->set_bold(0); 315 $formatbc = $workbook->add_format(); 316 $formatbc->set_bold(1); 317 $formatbc->set_align('center'); 318 $formatb = $workbook->add_format(); 319 $formatb->set_bold(1); 320 $formaty = $workbook->add_format(); 321 $formaty->set_bg_color('yellow'); 322 $formatc = $workbook->add_format(); 323 $formatc->set_align('center'); 324 $formatr = $workbook->add_format(); 325 $formatr->set_bold(1); 326 $formatr->set_color('red'); 327 $formatr->set_align('center'); 328 $formatg = $workbook->add_format(); 329 $formatg->set_bold(1); 330 $formatg->set_color('green'); 331 $formatg->set_align('center'); 332 333 $colnum = 0; 334 foreach ($headers as $item) { 335 $myxls->write(0, $colnum, $item, $formatbc); 336 $colnum++; 337 } 338 $rownum = 1; 339 } else if ($download == 'CSV') { 340 $csvexport = new \csv_export_writer("tab"); 341 $csvexport->set_filename($filename, ".txt"); 342 $csvexport->add_data($headers); 343 } 344 345 if (!$download) { 346 $sort = $table->get_sql_sort(); 347 } else { 348 $sort = ''; 349 } 350 // Fix some wired sorting. 351 if (empty($sort)) { 352 $sort = ' ORDER BY uniqueid'; 353 } else { 354 $sort = ' ORDER BY '.$sort; 355 } 356 357 if (!$download) { 358 // Add extra limits due to initials bar. 359 list($twhere, $tparams) = $table->get_sql_where(); 360 if ($twhere) { 361 $where .= ' AND '.$twhere; // Initial bar. 362 $params = array_merge($params, $tparams); 363 } 364 365 if (!empty($countsql)) { 366 $count = $DB->get_record_sql($countsql, $params); 367 $totalinitials = $count->nbresults; 368 if ($twhere) { 369 $countsql .= ' AND '.$twhere; 370 } 371 $count = $DB->get_record_sql($countsql, $params); 372 $total = $count->nbresults; 373 } 374 375 $table->pagesize($pagesize, $total); 376 377 echo \html_writer::start_div('scormattemptcounts'); 378 if ( $count->nbresults == $count->nbattempts ) { 379 echo get_string('reportcountattempts', 'scorm', $count); 380 } else if ( $count->nbattempts > 0 ) { 381 echo get_string('reportcountallattempts', 'scorm', $count); 382 } else { 383 echo $count->nbusers.' '.get_string('users'); 384 } 385 echo \html_writer::end_div(); 386 } 387 388 // Fetch the attempts. 389 if (!$download) { 390 $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params, 391 $table->get_page_start(), $table->get_page_size()); 392 echo \html_writer::start_div('', array('id' => 'scormtablecontainer')); 393 if ($candelete) { 394 // Start form. 395 $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm')); 396 echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post', 397 'action' => $PAGE->url->out(false), 398 'onsubmit' => 'return confirm("'.$strreallydel.'");')); 399 echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete')); 400 echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); 401 echo \html_writer::start_div('', array('style' => 'display: none;')); 402 echo \html_writer::input_hidden_params($PAGE->url); 403 echo \html_writer::end_div(); 404 echo \html_writer::start_div(); 405 } 406 $table->initialbars($totalinitials > 20); // Build table rows. 407 } else { 408 $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params); 409 } 410 if ($attempts) { 411 foreach ($attempts as $scouser) { 412 $row = array(); 413 if (!empty($scouser->attempt)) { 414 $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt); 415 } else { 416 $timetracks = ''; 417 } 418 if (in_array('checkbox', $columns)) { 419 if ($candelete && !empty($timetracks->start)) { 420 $row[] = $this->generate_row_checkbox('attemptid[]', "{$scouser->userid}:{$scouser->attempt}"); 421 } else if ($candelete) { 422 $row[] = ''; 423 } 424 } 425 if (in_array('picture', $columns)) { 426 $user = new \stdClass(); 427 $additionalfields = explode(',', implode(',', \core_user\fields::get_picture_fields())); 428 $user = username_load_fields_from_object($user, $scouser, null, $additionalfields); 429 $user->id = $scouser->userid; 430 $row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id)); 431 } 432 if (!$download) { 433 $url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id)); 434 $row[] = \html_writer::link($url, fullname($scouser)); 435 } else { 436 $row[] = fullname($scouser); 437 } 438 foreach ($extrafields as $field) { 439 $row[] = s($scouser->{$field}); 440 } 441 if (empty($timetracks->start)) { 442 $row[] = '-'; 443 $row[] = '-'; 444 $row[] = '-'; 445 $row[] = '-'; 446 } else { 447 if (!$download) { 448 $url = new \moodle_url('/mod/scorm/report/userreport.php', 449 array('id' => $cm->id, 450 'user' => $scouser->userid, 451 'attempt' => $scouser->attempt)); 452 $row[] = \html_writer::link($url, $scouser->attempt); 453 } else { 454 $row[] = $scouser->attempt; 455 } 456 if ($download == 'ODS' || $download == 'Excel' ) { 457 $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig")); 458 } else { 459 $row[] = userdate($timetracks->start); 460 } 461 if ($download == 'ODS' || $download == 'Excel' ) { 462 $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig')); 463 } else { 464 $row[] = userdate($timetracks->finish); 465 } 466 $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt); 467 } 468 // Print out all scores of attempt. 469 $emptyrow = $download ? '' : ' '; 470 foreach ($scoes as $sco) { 471 if ($sco->launch != '') { 472 if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) { 473 if ($trackdata->status == '') { 474 $trackdata->status = 'notattempted'; 475 } 476 $strstatus = get_string($trackdata->status, 'scorm'); 477 // If raw score exists, print it. 478 if ($trackdata->score_raw != '') { 479 $score = $trackdata->score_raw; 480 // Add max score if it exists. 481 if (isset($trackdata->score_max)) { 482 $score .= '/'.$trackdata->score_max; 483 } 484 } else { // Else print out status. 485 $score = $strstatus; 486 } 487 if (!$download) { 488 $url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id, 489 'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt)); 490 $row[] = $OUTPUT->pix_icon($trackdata->status, $strstatus, 'scorm') . '<br>' . 491 \html_writer::link($url, $score, array('title' => get_string('details', 'scorm'))); 492 } else { 493 $row[] = $score; 494 } 495 // Interaction data. 496 for ($i = 0; $i < $questioncount; $i++) { 497 if ($displayoptions['qtext']) { 498 $element = 'cmi.interactions_'.$i.'.id'; 499 if (isset($trackdata->$element)) { 500 $row[] = s($trackdata->$element); 501 } else { 502 $row[] = $emptyrow; 503 } 504 } 505 if ($displayoptions['resp']) { 506 $element = 'cmi.interactions_'.$i.'.student_response'; 507 if (isset($trackdata->$element)) { 508 $row[] = s($trackdata->$element); 509 } else { 510 $row[] = $emptyrow; 511 } 512 } 513 if ($displayoptions['right']) { 514 $j = 0; 515 $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern'; 516 $rightans = ''; 517 if (isset($trackdata->$element)) { 518 while (isset($trackdata->$element)) { 519 if ($j > 0) { 520 $rightans .= ','; 521 } 522 $rightans .= s($trackdata->$element); 523 $j++; 524 $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern'; 525 } 526 $row[] = $rightans; 527 } else { 528 $row[] = $emptyrow; 529 } 530 } 531 if ($displayoptions['result']) { 532 $element = 'cmi.interactions_'.$i.'.result'; 533 if (isset($trackdata->$element)) { 534 $row[] = s($trackdata->$element); 535 } else { 536 $row[] = $emptyrow; 537 } 538 } 539 } 540 // End of interaction data. 541 } else { 542 // If we don't have track data, we haven't attempted yet. 543 $strstatus = get_string('notattempted', 'scorm'); 544 if (!$download) { 545 $row[] = $OUTPUT->pix_icon('notattempted', $strstatus, 'scorm') . '<br>' . $strstatus; 546 } else { 547 $row[] = $strstatus; 548 } 549 // Complete the empty cells. 550 for ($i = 0; $i < count($columns) - $nbmaincolumns; $i++) { 551 $row[] = $emptyrow; 552 } 553 } 554 } 555 } 556 557 if (!$download) { 558 $table->add_data($row); 559 } else if ($download == 'Excel' or $download == 'ODS') { 560 $colnum = 0; 561 foreach ($row as $item) { 562 $myxls->write($rownum, $colnum, $item, $format); 563 $colnum++; 564 } 565 $rownum++; 566 } else if ($download == 'CSV') { 567 $csvexport->add_data($row); 568 } 569 } 570 if (!$download) { 571 $table->finish_output(); 572 if ($candelete) { 573 echo \html_writer::start_tag('table', array('id' => 'commands')); 574 echo \html_writer::start_tag('tr').\html_writer::start_tag('td'); 575 echo $this->generate_delete_selected_button(); 576 echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table'); 577 // Close form. 578 echo \html_writer::end_tag('div'); 579 echo \html_writer::end_tag('form'); 580 } 581 echo \html_writer::end_div(); 582 if (!empty($attempts)) { 583 echo \html_writer::start_tag('table', array('class' => 'boxaligncenter')).\html_writer::start_tag('tr'); 584 echo \html_writer::start_tag('td'); 585 echo $OUTPUT->single_button(new \moodle_url($PAGE->url, 586 array('download' => 'ODS') + $displayoptions), 587 get_string('downloadods'), 588 'post', 589 ['class' => 'mt-1']); 590 echo \html_writer::end_tag('td'); 591 echo \html_writer::start_tag('td'); 592 echo $OUTPUT->single_button(new \moodle_url($PAGE->url, 593 array('download' => 'Excel') + $displayoptions), 594 get_string('downloadexcel'), 595 'post', 596 ['class' => 'mt-1']); 597 echo \html_writer::end_tag('td'); 598 echo \html_writer::start_tag('td'); 599 echo $OUTPUT->single_button(new \moodle_url($PAGE->url, 600 array('download' => 'CSV') + $displayoptions), 601 get_string('downloadtext'), 602 'post', 603 ['class' => 'mt-1']); 604 echo \html_writer::end_tag('td'); 605 echo \html_writer::start_tag('td'); 606 echo \html_writer::end_tag('td'); 607 echo \html_writer::end_tag('tr').\html_writer::end_tag('table'); 608 } 609 } 610 } else { 611 if ($candelete && !$download) { 612 echo \html_writer::end_div(); 613 echo \html_writer::end_tag('form'); 614 $table->finish_output(); 615 } 616 echo \html_writer::end_div(); 617 } 618 // Show preferences form irrespective of attempts are there to report or not. 619 if (!$download) { 620 $mform->set_data(compact('pagesize', 'attemptsmode')); 621 $mform->display(); 622 } 623 if ($download == 'Excel' or $download == 'ODS') { 624 $workbook->close(); 625 exit; 626 } else if ($download == 'CSV') { 627 $csvexport->download_file(); 628 exit; 629 } 630 } else { 631 echo $OUTPUT->notification(get_string('noactivity', 'scorm')); 632 } 633 }// Function ends. 634 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body