. /** * This file defines the quiz responses report class. * * @package quiz_responses * @copyright 2006 Jean-Michel Vedrine * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/mod/quiz/report/attemptsreport.php'); require_once($CFG->dirroot . '/mod/quiz/report/responses/responses_options.php'); require_once($CFG->dirroot . '/mod/quiz/report/responses/responses_form.php'); require_once($CFG->dirroot . '/mod/quiz/report/responses/last_responses_table.php'); require_once($CFG->dirroot . '/mod/quiz/report/responses/first_or_all_responses_table.php'); /** * Quiz report subclass for the responses report. * * This report lists some combination of * * what question each student saw (this makes sense if random questions were used). * * the response they gave, * * and what the right answer is. * * Like the overview report, there are options for showing students with/without * attempts, and for deleting selected attempts. * * @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class quiz_responses_report extends quiz_attempts_report { public function display($quiz, $cm, $course) { global $OUTPUT; list($currentgroup, $students, $groupstudents, $allowed) = $this->init('responses', 'quiz_responses_settings_form', $quiz, $cm, $course); $options = new quiz_responses_options('responses', $quiz, $cm, $course); if ($fromform = $this->form->get_data()) { $options->process_settings_from_form($fromform); } else { $options->process_settings_from_params(); } $this->form->set_data($options->get_initial_form_data()); if ($options->attempts == self::ALL_WITH) { // This option is only available to users who can access all groups in // groups mode, so setting allowed to empty (which means all quiz attempts // are accessible, is not a security porblem. $allowed = array(); } // Load the required questions. $questions = quiz_report_get_significant_questions($quiz); // Prepare for downloading, if applicable. $courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id))); if ($options->whichtries === question_attempt::LAST_TRY) { $tableclassname = 'quiz_last_responses_table'; } else { $tableclassname = 'quiz_first_or_all_responses_table'; } $table = new $tableclassname($quiz, $this->context, $this->qmsubselect, $options, $groupstudents, $students, $questions, $options->get_url()); $filename = quiz_report_download_filename(get_string('responsesfilename', 'quiz_responses'), $courseshortname, $quiz->name); $table->is_downloading($options->download, $filename, $courseshortname . ' ' . format_string($quiz->name, true)); if ($table->is_downloading()) { raise_memory_limit(MEMORY_EXTRA); } $this->process_actions($quiz, $cm, $currentgroup, $groupstudents, $allowed, $options->get_url()); // Start output. if (!$table->is_downloading()) { // Only print headers if not asked to download data. $this->print_header_and_tabs($cm, $course, $quiz, $this->mode); } if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used, so output the group selector if we are not downloading. if (!$table->is_downloading()) { groups_print_activity_menu($cm, $options->get_url()); } } // Print information on the number of existing attempts. if (!$table->is_downloading()) { // Do not print notices when downloading. if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) { echo '