public function destination_courses_selector(moodle_url $nextstageurl, destination_courses_search $courses = null, $courseid) { $html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore')); $html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring())); foreach ($nextstageurl->params() as $key => $value) { $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value)); } $html .= html_writer::start_tag('div', array('class' => 'ics-existing-group backup-section')); $html .= $this->output->heading(get_string('selectgroups', 'local_syncgroups'), 2, array('class' => 'header')); $html .= html_writer::start_tag('ul'); $groups = groups_get_all_groups($courseid, 0, 0, 'g.id, g.name'); foreach ($groups as $group) { $html .= html_writer::start_tag('li') . html_writer::checkbox('groups[]', $group->id, false, $group->name) . html_writer::end_tag('li'); } $html .= html_writer::end_tag('ul'); $html .= html_writer::end_tag('div'); // We only allow import adding for now. Enforce it here. $html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section')); $html .= $this->output->heading(get_string('syncgroupsto', 'local_syncgroups'), 2, array('class' => 'header')); $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses)); $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue')))); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); $html .= html_writer::end_tag('div'); return $html; }
public function wrap_html_start() { global $PAGE; if ($this->is_downloading() || !$this->candelete) { return; } // Start form $url = new moodle_url($this->reporturl, $this->displayoptions); $url->param('sesskey', sesskey()); echo '<div id="tablecontainer">'; echo '<form id="attemptsform" method="post" action="' . $url->out_omit_querystring() . '>'; echo html_writer::input_hidden_params($url); echo '<div>'; $PAGE->requires->event_handler('#attemptsform', 'submit', 'M.util.show_confirm_dialog', array('message' => get_string('deleteattemptcheck', 'quiz'))); }
function wrap_html_start() { if (!$this->is_downloading()) { if ($this->candelete) { // Start form $url = new moodle_url($this->reporturl, $this->displayoptions); echo '<div id="tablecontainer">'; echo '<form id="attemptsform" method="post" action="' . $url->out_omit_querystring() . '">'; echo '<div style="display: none;">'; echo html_writer::input_hidden_params($url); echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())) . "\n"; echo '</div>'; echo '<div>'; } } }
function wrap_html_start() { if (!$this->is_downloading()) { if ($this->candelete) { // Start form $displayurl = new moodle_url($this->reporturl, $this->displayoptions); $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'quiz')); echo '<div id="tablecontainer">'; echo '<form id="attemptsform" method="post" action="' . $displayurl->out_omit_querystring() . '" onsubmit="confirm(\'' . $strreallydel . '\');">'; echo '<div style="display: none;">'; echo html_writer::input_hidden_params($displayurl); echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())) . "\n"; echo '</div>'; echo '<div>'; } } }
/** * Renders the process stage screen * * @throws restore_ui_exception * @param core_backup_renderer $renderer renderer instance to use * @return string HTML code */ public function display(core_backup_renderer $renderer) { global $PAGE; $html = ''; $haserrors = false; $url = new moodle_url($PAGE->url, array('restore' => $this->get_uniqueid(), 'stage' => restore_ui::STAGE_PROCESS, 'substage' => $this->substage, 'sesskey' => sesskey())); $html .= html_writer::start_tag('form', array('action' => $url->out_omit_querystring(), 'class' => 'backup-restore', 'enctype' => 'application/x-www-form-urlencoded', 'method' => 'post')); foreach ($url->params() as $name => $value) { $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value)); } switch ($this->substage) { case self::SUBSTAGE_PRECHECKS: $results = $this->ui->get_controller()->get_precheck_results(); $info = $this->ui->get_controller()->get_info(); $haserrors = !empty($results['errors']); $html .= $renderer->precheck_notices($results); if (!empty($info->role_mappings->mappings)) { $context = context_course::instance($this->ui->get_controller()->get_courseid()); $assignableroles = get_assignable_roles($context, ROLENAME_ALIAS, false); $html .= $renderer->role_mappings($info->role_mappings->mappings, $assignableroles); } break; default: throw new restore_ui_exception('backup_ui_must_execute_first'); } $html .= $renderer->substage_buttons($haserrors); $html .= html_writer::end_tag('form'); return $html; }
/** * Displays the import course selector * * @param moodle_url $nextstageurl * @param import_course_search $courses * @return string */ public function import_course_selector(moodle_url $nextstageurl, import_course_search $courses = null) { $html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore')); $html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring())); foreach ($nextstageurl->params() as $key => $value) { $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value)); } // We only allow import adding for now. Enforce it here. $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'target', 'value' => backup::TARGET_CURRENT_ADDING)); $html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section')); $html .= $this->output->heading(get_string('importdatafrom'), 2, array('class' => 'header')); $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses)); $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue')))); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); $html .= html_writer::end_tag('div'); return $html; }
/** * Build the form required to do the pre-flight checks. * @param moodle_url $url the form action URL. * @param int|null $attemptid the id of the current attempt, if there is one, * otherwise null. * @return mod_quiz_preflight_check_form the form. */ public function get_preflight_check_form(moodle_url $url, $attemptid) { return new mod_quiz_preflight_check_form($url->out_omit_querystring(), array('rules' => $this->rules, 'quizobj' => $this->quizobj, 'attemptid' => $attemptid, 'hidden' => $url->params())); }
/** * Build the form required to do the pre-flight checks. * @param moodle_url $url the form action URL. * @param int|null $attemptid the id of the current attempt, if there is one, * otherwise null. * @return mod_quiz_preflight_check_form the form. */ public function get_preflight_check_form(moodle_url $url, $attemptid) { // This form normally wants POST submissins. However, it also needs to // accept GET submissions. Since formslib is strict, we have to detect // which case we are in, and set the form property appropriately. $method = 'post'; if (!empty($_GET['_qf__mod_quiz_preflight_check_form'])) { $method = 'get'; } return new mod_quiz_preflight_check_form($url->out_omit_querystring(), array('rules' => $this->rules, 'quizobj' => $this->quizobj, 'attemptid' => $attemptid, 'hidden' => $url->params()), $method); }
/** * should NEVER be called... throws an exception */ public function display($renderer) { global $PAGE; $haserrors = false; $url = new moodle_url($PAGE->url, array('restore' => $this->get_uniqueid(), 'stage' => restore_ui::STAGE_PROCESS, 'substage' => $this->substage, 'sesskey' => sesskey())); echo html_writer::start_tag('form', array('action' => $url->out_omit_querystring(), 'class' => 'backup-restore', 'method' => 'post')); foreach ($url->params() as $name => $value) { echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value)); } switch ($this->substage) { case self::SUBSTAGE_CONVERT: echo '<h2>Need to show the conversion screens here</h2>'; break; case self::SUBSTAGE_PRECHECKS: $results = $this->ui->get_controller()->get_precheck_results(); $info = $this->ui->get_controller()->get_info(); $haserrors = !empty($results['errors']); echo $renderer->precheck_notices($results); if (!empty($info->role_mappings->mappings)) { $context = get_context_instance(CONTEXT_COURSE, $this->ui->get_controller()->get_courseid()); $assignableroles = get_assignable_roles($context, ROLENAME_ALIAS, false); echo $renderer->role_mappings($info->role_mappings->mappings, $assignableroles); } break; default: throw new restore_ui_exception('backup_ui_must_execute_first'); } echo $renderer->substage_buttons($haserrors); echo html_writer::end_tag('form'); }
public function display($quiz, $cm, $course) { global $CFG, $DB, $OUTPUT, $PAGE; list($currentgroup, $students, $groupstudents, $allowed) = $this->init('overview', 'quiz_overview_settings_form', $quiz, $cm, $course); $options = new quiz_overview_options('overview', $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))); $table = new quiz_overview_table($quiz, $this->context, $this->qmsubselect, $options, $groupstudents, $students, $questions, $options->get_url()); $filename = quiz_report_download_filename(get_string('overviewfilename', 'quiz_overview'), $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->course = $course; // Hack to make this available in process_actions. $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 '<div class="quizattemptcounts">' . $strattemptnum . '</div>'; } } $hasquestions = quiz_questions_in_quiz($quiz->questions); if (!$table->is_downloading()) { if (!$hasquestions) { echo quiz_no_questions_message($quiz, $cm, $this->context); } else { if (!$students) { echo $OUTPUT->notification(get_string('nostudentsyet')); } else { if ($currentgroup && !$groupstudents) { echo $OUTPUT->notification(get_string('nostudentsingroup')); } } } // Print the display options. $this->form->display(); } $hasstudents = $students && (!$currentgroup || $groupstudents); if ($hasquestions && ($hasstudents || $options->attempts == self::ALL_WITH)) { // Construct the SQL. $fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') . ' AS uniqueid, '; if ($this->qmsubselect) { $fields .= "(CASE " . " WHEN {$this->qmsubselect} THEN 1" . " ELSE 0 " . "END) AS gradedattempt, "; } list($fields, $from, $where, $params) = $table->base_sql($allowed); $table->set_count_sql("SELECT COUNT(1) FROM {$from} WHERE {$where}", $params); // Test to see if there are any regraded attempts to be listed. $fields .= ", COALESCE((\n SELECT MAX(qqr.regraded)\n FROM {quiz_overview_regrades} qqr\n WHERE qqr.questionusageid = quiza.uniqueid\n ), -1) AS regraded"; if ($options->onlyregraded) { $where .= " AND COALESCE((\n SELECT MAX(qqr.regraded)\n FROM {quiz_overview_regrades} qqr\n WHERE qqr.questionusageid = quiza.uniqueid\n ), -1) <> -1"; } $table->set_sql($fields, $from, $where, $params); if (!$table->is_downloading()) { // Output the regrade buttons. if (has_capability('mod/quiz:regrade', $this->context)) { $regradesneeded = $this->count_question_attempts_needing_regrade($quiz, $groupstudents); if ($currentgroup) { $a = new stdClass(); $a->groupname = groups_get_group_name($currentgroup); $a->coursestudents = get_string('participants'); $a->countregradeneeded = $regradesneeded; $regradealldrydolabel = get_string('regradealldrydogroup', 'quiz_overview', $a); $regradealldrylabel = get_string('regradealldrygroup', 'quiz_overview', $a); $regradealllabel = get_string('regradeallgroup', 'quiz_overview', $a); } else { $regradealldrydolabel = get_string('regradealldrydo', 'quiz_overview', $regradesneeded); $regradealldrylabel = get_string('regradealldry', 'quiz_overview'); $regradealllabel = get_string('regradeall', 'quiz_overview'); } $displayurl = new moodle_url($options->get_url(), array('sesskey' => sesskey())); echo '<div class="mdl-align">'; echo '<form action="' . $displayurl->out_omit_querystring() . '">'; echo '<div>'; echo html_writer::input_hidden_params($displayurl); echo '<input type="submit" name="regradeall" value="' . $regradealllabel . '"/>'; echo '<input type="submit" name="regradealldry" value="' . $regradealldrylabel . '"/>'; if ($regradesneeded) { echo '<input type="submit" name="regradealldrydo" value="' . $regradealldrydolabel . '"/>'; } echo '</div>'; echo '</form>'; echo '</div>'; } // Print information on the grading method. if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $this->qmsubselect, $options->onlygraded)) { echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>'; } } // Define table columns. $columns = array(); $headers = array(); if (!$table->is_downloading() && $options->checkboxcolumn) { $columns[] = 'checkbox'; $headers[] = null; } $this->add_user_columns($table, $columns, $headers); $this->add_state_column($columns, $headers); $this->add_time_columns($columns, $headers); $this->add_grade_columns($quiz, $options->usercanseegrades, $columns, $headers, false); if (!$table->is_downloading() && has_capability('mod/quiz:regrade', $this->context) && $this->has_regraded_questions($from, $where, $params)) { $columns[] = 'regraded'; $headers[] = get_string('regrade', 'quiz_overview'); } if ($options->slotmarks) { foreach ($questions as $slot => $question) { // Ignore questions of zero length. $columns[] = 'qsgrade' . $slot; $header = get_string('qbrief', 'quiz', $question->number); if (!$table->is_downloading()) { $header .= '<br />'; } else { $header .= ' '; } $header .= '/' . quiz_rescale_grade($question->maxmark, $quiz, 'question'); $headers[] = $header; } } $this->set_up_table_columns($table, $columns, $headers, $this->get_base_url(), $options, false); $table->set_attribute('class', 'generaltable generalbox grades'); $table->out($options->pagesize, true); } if (!$table->is_downloading() && $options->usercanseegrades) { $output = $PAGE->get_renderer('mod_quiz'); if ($currentgroup && $groupstudents) { list($usql, $params) = $DB->get_in_or_equal($groupstudents); $params[] = $quiz->id; if ($DB->record_exists_select('quiz_grades', "userid {$usql} AND quiz = ?", $params)) { $imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php', array('id' => $quiz->id, 'groupid' => $currentgroup)); $graphname = get_string('overviewreportgraphgroup', 'quiz_overview', groups_get_group_name($currentgroup)); echo $output->graph($imageurl, $graphname); } } if ($DB->record_exists('quiz_grades', array('quiz' => $quiz->id))) { $imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php', array('id' => $quiz->id)); $graphname = get_string('overviewreportgraph', 'quiz_overview'); echo $output->graph($imageurl, $graphname); } } return true; }
/** * Display the report. */ function display($quiz, $cm, $course) { global $CFG, $COURSE, $DB, $OUTPUT; $this->context = get_context_instance(CONTEXT_MODULE, $cm->id); // Work out some display options - whether there is feedback, and whether scores should be shown. $hasfeedback = quiz_has_feedback($quiz); $fakeattempt = new stdClass(); $fakeattempt->preview = false; $fakeattempt->timefinish = $quiz->timeopen; $fakeattempt->userid = 0; $reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $this->context); $showgrades = quiz_has_grades($quiz) && $reviewoptions->scores; $download = optional_param('download', '', PARAM_ALPHA); /// find out current groups mode $currentgroup = groups_get_activity_group($cm, true); if (!$students = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'u.id,1','','','','','',false)) { $students = array(); } else { $students = array_keys($students); } if (empty($currentgroup)) { // all users who can attempt quizzes $allowed = $students; $groupstudents = array(); } else { // all users who can attempt quizzes and who are in the currently selected group if (!$groupstudents = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'u.id,1','','','',$currentgroup,'',false)) { $groupstudents = array(); } else { $groupstudents = array_keys($groupstudents); } $allowed = $groupstudents; } $pageoptions = array(); $pageoptions['id'] = $cm->id; $pageoptions['mode'] = 'overview'; $reporturl = new moodle_url('/mod/quiz/report.php', $pageoptions); $qmsubselect = quiz_report_qm_filter_select($quiz); $mform = new mod_quiz_report_overview_settings($reporturl, array('qmsubselect'=> $qmsubselect, 'quiz'=>$quiz, 'currentgroup'=>$currentgroup, 'context'=>$this->context)); if ($fromform = $mform->get_data()) { $regradeall = false; $regradealldry = false; $regradealldrydo = false; $attemptsmode = $fromform->attemptsmode; if ($qmsubselect) { //control is not on the form if //the grading method is not set //to grade one attempt per user eg. for average attempt grade. $qmfilter = $fromform->qmfilter; } else { $qmfilter = 0; } $regradefilter = $fromform->regradefilter; set_user_preference('quiz_report_overview_detailedmarks', $fromform->detailedmarks); set_user_preference('quiz_report_pagesize', $fromform->pagesize); $detailedmarks = $fromform->detailedmarks; $pagesize = $fromform->pagesize; } else { $regradeall = optional_param('regradeall', 0, PARAM_BOOL); $regradealldry = optional_param('regradealldry', 0, PARAM_BOOL); $regradealldrydo = optional_param('regradealldrydo', 0, PARAM_BOOL); $attemptsmode = optional_param('attemptsmode', null, PARAM_INT); if ($qmsubselect) { $qmfilter = optional_param('qmfilter', 0, PARAM_INT); } else { $qmfilter = 0; } $regradefilter = optional_param('regradefilter', 0, PARAM_INT); $detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1); $pagesize = get_user_preferences('quiz_report_pagesize', 0); } if ($currentgroup) { //default for when a group is selected if ($attemptsmode === null || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) { $attemptsmode = QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH; } } else if (!$currentgroup && $course->id == SITEID) { //force report on front page to show all, unless a group is selected. $attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL; } else if ($attemptsmode === null) { //default $attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL; } if (!$reviewoptions->scores) { $detailedmarks = 0; } if ($pagesize < 1) { $pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE; } // We only want to show the checkbox to delete attempts // if the user has permissions and if the report mode is showing attempts. $candelete = has_capability('mod/quiz:deleteattempts', $this->context) && ($attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO); $displayoptions = array(); $displayoptions['attemptsmode'] = $attemptsmode; $displayoptions['qmfilter'] = $qmfilter; $displayoptions['regradefilter'] = $regradefilter; if ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) { $allowed = array(); } if (empty($currentgroup) || $groupstudents) { if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) { if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) { require_capability('mod/quiz:deleteattempts', $this->context); $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed, $groupstudents); redirect($reporturl->out(false, $displayoptions)); } } else if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) { if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) { $this->regrade_selected_attempts($quiz, $attemptids, $groupstudents); redirect($reporturl->out(false, $displayoptions)); } } } //work out the sql for this table. if ($detailedmarks) { $questions = quiz_report_load_questions($quiz); } else { $questions = array(); } $table = new quiz_report_overview_table($quiz , $qmsubselect, $groupstudents, $students, $detailedmarks, $questions, $candelete, $reporturl, $displayoptions, $this->context); $table->is_downloading($download, get_string('reportoverview','quiz'), "$COURSE->shortname ".format_string($quiz->name,true)); if (!$table->is_downloading()) { // Only print headers if not asked to download data $this->print_header_and_tabs($cm, $course, $quiz, "overview"); } if ($regradeall && confirm_sesskey()) { $this->regrade_all(false, $quiz, $groupstudents); } else if ($regradealldry && confirm_sesskey()) { $this->regrade_all(true, $quiz, $groupstudents); } else if ($regradealldrydo && confirm_sesskey()) { $this->regrade_all_needed($quiz, $groupstudents); } if ($regradeall || $regradealldry || $regradealldrydo) { redirect($reporturl->out(false, $displayoptions), '', 5); } if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if (!$table->is_downloading()) { groups_print_activity_menu($cm, $reporturl->out(true, $displayoptions)); } } $nostudents = false; if (!$students) { if (!$table->is_downloading()) { echo $OUTPUT->notification(get_string('nostudentsyet')); } $nostudents = true; } else if ($currentgroup && !$groupstudents) { if (!$table->is_downloading()) { echo $OUTPUT->notification(get_string('nostudentsingroup')); } $nostudents = true; } if (!$table->is_downloading()) { // Print display options $mform->set_data($displayoptions +compact('detailedmarks', 'pagesize')); $mform->display(); // Print information on the number of existing attempts if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) { echo '<div class="quizattemptcounts">' . $strattemptnum . '</div>'; } } if (!$nostudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) { // Construct the SQL $fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(qa.attempt, 0)') . ' AS uniqueid,'; if ($qmsubselect) { $fields .= "\n(CASE WHEN $qmsubselect THEN 1 ELSE 0 END) AS gradedattempt,"; } $fields .= ' qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email, qa.sumgrades, qa.timefinish, qa.timestart, CASE WHEN qa.timefinish = 0 THEN null WHEN qa.timefinish > qa.timestart THEN qa.timefinish - qa.timestart ELSE 0 END AS duration'; // To explain that last bit, in MySQL, qa.timestart and qa.timefinish // are unsigned. Since MySQL 5.5.5, when they introduced strict mode, // subtracting a larger unsigned int from a smaller one gave an error. // Therefore, we avoid doing that. timefinish can be non-zero and less // than timestart when you have two load-balanced servers with very // badly synchronised clocks, and a student does a really quick attempt. // This part is the same for all cases - join users and quiz_attempts tables $from = '{user} u '; $from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid'; $params = array('quizid' => $quiz->id); if ($qmsubselect && $qmfilter) { $from .= ' AND '.$qmsubselect; } switch ($attemptsmode) { case QUIZ_REPORT_ATTEMPTS_ALL: // Show all attempts, including students who are no longer in the course $where = 'qa.id IS NOT NULL AND qa.preview = 0'; break; case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH: // Show only students with attempts list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000'); $params += $allowed_params; $where = "u.id $allowed_usql AND qa.preview = 0 AND qa.id IS NOT NULL"; break; case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO: // Show only students without attempts list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000'); $params += $allowed_params; $where = "u.id $allowed_usql AND qa.id IS NULL"; break; case QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS: // Show all students with or without attempts list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000'); $params += $allowed_params; $where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)"; break; } $table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params); $sqlobject = new stdClass(); $sqlobject->from = $from; $sqlobject->where = $where; $sqlobject->params = $params; //test to see if there are any regraded attempts to be listed. if (quiz_get_regraded_qs($sqlobject, 0, 1)) { $regradedattempts = true; } else { $regradedattempts = false; } $fields .= ', COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_question_regrade} qqr WHERE qqr.attemptid = qa.uniqueid),-1) AS regraded'; if ($regradefilter) { $where .= ' AND COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_question_regrade} qqr WHERE qqr.attemptid = qa.uniqueid),-1) !=\'-1\''; } $table->set_sql($fields, $from, $where, $params); // Define table columns $columns = array(); $headers = array(); if (!$table->is_downloading()) { //do not print notices when downloading //regrade buttons if (has_capability('mod/quiz:regrade', $this->context)) { $countregradeneeded = $this->count_regrade_all_needed($quiz, $groupstudents); if ($currentgroup) { $a= new stdClass(); $a->groupname = groups_get_group_name($currentgroup); $a->coursestudents = get_string('participants'); $a->countregradeneeded = $countregradeneeded; $regradealldrydolabel = get_string('regradealldrydogroup', 'quiz_overview', $a); $regradealldrylabel = get_string('regradealldrygroup', 'quiz_overview', $a); $regradealllabel = get_string('regradeallgroup', 'quiz_overview', $a); } else { $regradealldrydolabel = get_string('regradealldrydo', 'quiz_overview', $countregradeneeded); $regradealldrylabel = get_string('regradealldry', 'quiz_overview'); $regradealllabel = get_string('regradeall', 'quiz_overview'); } $displayurl = new moodle_url($reporturl, $displayoptions); echo '<div class="mdl-align">'; echo '<form action="'.$displayurl->out_omit_querystring().'">'; echo '<div>'; echo html_writer::input_hidden_params($displayurl); echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())) . "\n"; echo '<input type="submit" name="regradeall" value="'.$regradealllabel.'"/>'; echo '<input type="submit" name="regradealldry" value="'.$regradealldrylabel.'"/>'; if ($countregradeneeded) { echo '<input type="submit" name="regradealldrydo" value="'.$regradealldrydolabel.'"/>'; } echo '</div>'; echo '</form>'; echo '</div>'; } // Print information on the grading method if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) { echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>'; } } if (!$table->is_downloading() && $candelete) { $columns[]= 'checkbox'; $headers[]= NULL; } if (!$table->is_downloading() && $CFG->grade_report_showuserimage) { $columns[]= 'picture'; $headers[]= ''; } if (!$table->is_downloading()) { $columns[]= 'fullname'; $headers[]= get_string('name'); } else { $columns[]= 'lastname'; $headers[]= get_string('lastname'); $columns[]= 'firstname'; $headers[]= get_string('firstname'); } if ($CFG->grade_report_showuseridnumber) { $columns[]= 'idnumber'; $headers[]= get_string('idnumber'); } $columns[]= 'timestart'; $headers[]= get_string('startedon', 'quiz'); $columns[]= 'timefinish'; $headers[]= get_string('timecompleted','quiz'); $columns[]= 'duration'; $headers[]= get_string('attemptduration', 'quiz'); if ($detailedmarks) { foreach ($questions as $id => $question) { // Ignore questions of zero length $columns[] = 'qsgrade'.$id; $header = '#'.$question->number; if (!$table->is_downloading()) { $header .='<br />'; } else { $header .=' '; } $header .='--/'.quiz_rescale_grade($question->maxgrade, $quiz, 'question'); $headers[] = $header; $question->formattedname = strip_tags(format_string($question->name)); } } if (!$table->is_downloading() && has_capability('mod/quiz:regrade', $this->context) && $regradedattempts) { $columns[] = 'regraded'; $headers[] = get_string('regrade', 'quiz_overview'); } if ($showgrades) { $columns[] = 'sumgrades'; $headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade); } if ($hasfeedback) { $columns[] = 'feedbacktext'; $headers[] = get_string('feedback', 'quiz'); } $table->define_columns($columns); $table->define_headers($headers); $table->sortable(true, 'uniqueid'); // Set up the table $table->define_baseurl($reporturl->out(true, $displayoptions)); $table->collapsible(true); $table->no_sorting('feedbacktext'); $table->column_class('picture', 'picture'); $table->column_class('lastname', 'bold'); $table->column_class('firstname', 'bold'); $table->column_class('fullname', 'bold'); $table->column_class('sumgrades', 'bold'); $table->set_attribute('id', 'attempts'); $table->out($pagesize, true); } if (!$table->is_downloading() && $showgrades) { if ($currentgroup && $groupstudents) { list($usql, $params) = $DB->get_in_or_equal($groupstudents); $params[] = $quiz->id; if ($DB->record_exists_select('quiz_grades', "userid $usql AND quiz = ?", $params)) { $imageurl = "{$CFG->wwwroot}/mod/quiz/report/overview/overviewgraph.php?id={$quiz->id}&groupid=$currentgroup"; $graphname = get_string('overviewreportgraphgroup', 'quiz_overview', groups_get_group_name($currentgroup)); echo $OUTPUT->heading($graphname); echo '<div class="graph"><img src="'.$imageurl.'" alt="'.$graphname.'" /></div>'; } } if ($DB->record_exists('quiz_grades', array('quiz'=> $quiz->id))) { $graphname = get_string('overviewreportgraph', 'quiz_overview'); $imageurl = $CFG->wwwroot.'/mod/quiz/report/overview/overviewgraph.php?id='.$quiz->id; echo $OUTPUT->heading($graphname); echo '<div class="graph"><img src="'.$imageurl.'" alt="'.$graphname.'" /></div>'; } } return true; }
/** * Return a little form for the user to request to download the full report, including quiz stats and response analysis for * all questions and sub-questions. * * @param moodle_url $reporturl the base URL of the report. * @return string HTML. */ protected function everything_download_options(moodle_url $reporturl) { global $OUTPUT; return $OUTPUT->download_dataformat_selector(get_string('downloadeverything', 'quiz_statistics'), $reporturl->out_omit_querystring(), 'download', $reporturl->params() + array('everything' => 1)); }
public function wrap_html_start() { if ($this->is_downloading() || !$this->includecheckboxes) { return; } $url = new moodle_url($this->reporturl, $this->displayoptions); $url->param('sesskey', sesskey()); echo '<div id="tablecontainer">'; echo '<form id="attemptsform" method="post" action="' . $url->out_omit_querystring() . '">'; echo html_writer::input_hidden_params($url); echo '<div>'; }
/** * view selfregistration-tab */ public function view_selfregistration() { global $OUTPUT, $DB, $CFG, $USER, $PAGE, $SESSION; $userid = $USER->id; $regopen = $this->grouptool->allow_reg && ($this->grouptool->timedue == 0 || time() < $this->grouptool->timedue) && time() > $this->grouptool->timeavailable; // Process submitted form! if (data_submitted() && confirm_sesskey() && optional_param('confirm', 0, PARAM_BOOL)) { // Execution has been confirmed! $hideform = 0; $action = optional_param('action', 'reg', PARAM_ALPHA); if ($action == 'unreg') { require_capability('mod/grouptool:register', $this->context); $agrpid = required_param('group', PARAM_INT); list($error, $message) = $this->unregister_from_agrp($agrpid, $USER->id); } else { if ($action == 'reg') { require_capability('mod/grouptool:register', $this->context); $agrpid = required_param('group', PARAM_INT); // Register user and get feedback! list($error, $message) = $this->register_in_agrp($agrpid, $USER->id); } else { if ($action == 'resolvequeues') { require_capability('mod/grouptool:register_students', $this->context); $mode = optional_param('mode', 'std', PARAM_ALPHA); list($error, $message) = $this->resolve_queues($mode); if ($error == -1) { $error = true; } } } } if ($error === true) { echo $OUTPUT->notification($message, 'notifyproblem'); } else { echo $OUTPUT->notification($message, 'notifysuccess'); } } else { if (data_submitted() && confirm_sesskey()) { // Display confirm-dialog! $hideform = 1; $reg = optional_param_array('reg', null, PARAM_INT); if ($reg != null) { $agrpid = array_keys($reg); $agrpid = reset($agrpid); $action = 'reg'; } $unreg = optional_param_array('unreg', null, PARAM_INT); if ($unreg != null) { $agrpid = array_keys($unreg); $agrpid = reset($agrpid); $action = 'unreg'; } $resolvequeues = optional_param('resolve_queues', 0, PARAM_BOOL); if (!empty($resolvequeues)) { $action = 'resolvequeues'; } $attr = array(); if ($action == 'resolvequeues') { require_capability('mod/grouptool:register_students', $this->context); $mode = optional_param('mode', 'random', PARAM_ALPHA); list($error, $confirmmessage) = $this->resolve_queues($mode, true); // Try only! } else { if ($action == 'unreg') { require_capability('mod/grouptool:register', $this->context); $attr['group'] = $agrpid; // Try only! list($error, $confirmmessage) = $this->unregister_from_agrp($agrpid, $USER->id, true); } else { require_capability('mod/grouptool:register', $this->context); $action = 'reg'; $attr['group'] = $agrpid; // Try only! list($error, $confirmmessage) = $this->register_in_agrp($agrpid, $USER->id, true); } } $attr['confirm'] = '1'; $attr['action'] = $action; $attr['sesskey'] = sesskey(); $continue = new moodle_url($PAGE->url, $attr); $cancel = new moodle_url($PAGE->url); if ($error === true && $action != 'resolvequeues') { $continue->remove_params('confirm', 'group'); $continue = new single_button($continue, get_string('continue'), 'get'); $cancel = null; } echo $this->confirm($confirmmessage, $continue, $cancel); } else { $hideform = 0; } } if (empty($hideform)) { /* * we need a new moodle_url-Object because * $PAGE->url->param('sesskey', sesskey()); * won't set sesskey param in $PAGE->url?!? */ $url = new moodle_url($PAGE->url, array('sesskey' => sesskey())); $formattr = array('method' => 'post', 'action' => $url->out_omit_querystring(), 'id' => 'registration_form', 'class' => 'mform'); echo html_writer::start_tag('form', $formattr); echo html_writer::start_tag('div', array('class' => 'clearfix')); echo html_writer::input_hidden_params($url); $regstat = $this->get_registration_stats($USER->id); if (!empty($this->grouptool->timedue) && time() >= $this->grouptool->timedue && has_capability('mod/grouptool:register_students', $this->context)) { if ($regstat->queued_users > 0) { // Insert queue-resolving button! $attr = array('type' => 'submit', 'name' => 'resolve_queues', 'value' => '1'); $resolvequeuebutton = html_writer::tag('button', get_string('resolve_queue', 'grouptool'), $attr); $resolvequeue = html_writer::tag('div', get_string('resolve_queue_title', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', $resolvequeuebutton, array('class' => 'felement')); $resolvequeue = html_writer::tag('div', $resolvequeue, array('class' => 'fitem')); $resolvequeuelegend = html_writer::tag('legend', get_string('resolve_queue_legend', 'grouptool')); $resolvequeueelement = html_writer::tag('div', $resolvequeue, array('class' => 'fcontainer')); echo html_writer::tag('fieldset', $resolvequeuelegend . $resolvequeueelement, array('class' => 'clearfix')); } } if (!empty($this->grouptool->use_size)) { $placestats = $regstat->group_places . ' ' . get_string('total', 'grouptool'); } else { $placestats = '∞ ' . get_string('total', 'grouptool'); } if ($regstat->free_places != null && !empty($this->grouptool->use_size)) { $placestats .= ' / ' . $regstat->free_places . ' ' . get_string('free', 'grouptool'); } else { $placestats .= ' / ∞ ' . get_string('free', 'grouptool'); } if ($regstat->occupied_places != null) { $placestats .= ' / ' . $regstat->occupied_places . ' ' . get_string('occupied', 'grouptool'); } $registrationinfo = html_writer::tag('div', get_string('group_places', 'grouptool') . $OUTPUT->help_icon('group_places', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', $placestats, array('class' => 'felement')); $generalinfo = html_writer::tag('div', $registrationinfo, array('class' => 'fitem')); $registrationinfo = html_writer::tag('div', get_string('number_of_students', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', $regstat->users, array('class' => 'felement')); $generalinfo .= html_writer::tag('div', $registrationinfo, array('class' => 'fitem')); if ($this->grouptool->allow_multiple && count($regstat->registered) < $this->grouptool->choose_min || !$this->grouptool->allow_multiple && !count($regstat->registered)) { if ($this->grouptool->allow_multiple) { $missing = $this->grouptool->choose_min - count($regstat->registered); $stringlabel = $missing > 1 ? 'registrations_missing' : 'registration_missing'; } else { $missing = 1; $stringlabel = 'registration_missing'; } $missingtext = get_string($stringlabel, 'grouptool', $missing); } else { $missingtext = ""; } if (!empty($regstat->registered)) { foreach ($regstat->registered as $registration) { if (empty($registrationscumulative)) { $registrationscumulative = $registration->grpname . ' (' . $registration->rank . ')'; } else { $registrationscumulative .= ', ' . $registration->grpname . ' (' . $registration->rank . ')'; } } $registrationinfo = html_writer::tag('div', get_string('registrations', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', html_writer::tag('div', $missingtext) . $registrationscumulative, array('class' => 'felement')); $generalinfo .= html_writer::tag('div', $registrationinfo, array('class' => 'fitem')); } else { $registrationinfo = html_writer::tag('div', get_string('registrations', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', html_writer::tag('div', $missingtext) . get_string('not_registered', 'grouptool'), array('class' => 'felement')); $generalinfo .= html_writer::tag('div', $registrationinfo, array('class' => 'fitem')); } if (!empty($regstat->queued)) { foreach ($regstat->queued as $queue) { if (empty($queuescumulative)) { $queuescumulative = $queue->grpname . ' (' . $queue->rank . ')'; } else { $queuescumulative .= ', ' . $queue->grpname . ' (' . $queue->rank . ')'; } } $registrationinfo = html_writer::tag('div', get_string('queues', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', $queuescumulative, array('class' => 'felement')); $generalinfo .= html_writer::tag('div', $registrationinfo, array('class' => 'fitem')); } if (!empty($this->grouptool->timeavailable)) { $timeavailable = html_writer::tag('div', get_string('availabledate', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', userdate($this->grouptool->timeavailable, get_string('strftimedatetime')), array('class' => 'felement')); $generalinfo .= html_writer::tag('div', $timeavailable, array('class' => 'fitem')); } $timedue = html_writer::tag('div', get_string('registrationdue', 'grouptool'), array('class' => 'fitemtitle')); if (!empty($this->grouptool->timedue)) { $timedue .= html_writer::tag('div', userdate($this->grouptool->timedue, get_string('strftimedatetime')), array('class' => 'felement')); } else { $timedue .= html_writer::tag('div', get_string('noregistrationdue', 'grouptool'), array('class' => 'felement')); } $generalinfo .= html_writer::tag('div', $timedue, array('class' => 'fitem')); if (!empty($this->grouptool->allow_unreg)) { $generalinfo .= html_writer::tag('div', html_writer::tag('div', get_string('unreg_is', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', get_string('allowed', 'grouptool'), array('class' => 'felement')), array('class' => 'fitem')); } else { $generalinfo .= html_writer::tag('div', html_writer::tag('div', get_string('unreg_is', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', get_string('not_permitted', 'grouptool'), array('class' => 'felement')), array('class' => 'fitem')); } if (!empty($this->grouptool->allow_multiple)) { $minmaxtitle = html_writer::tag('div', get_string('choose_minmax_title', 'grouptool'), array('class' => 'fitemtitle')); if ($this->grouptool->choose_min && $this->grouptool->choose_max) { $data = array('min' => $this->grouptool->choose_min, 'max' => $this->grouptool->choose_max); $minmaxtext = html_writer::tag('div', get_string('choose_min_max_text', 'grouptool', $data), array('class' => 'felement')); $class = ' choose_min choose_max'; } else { if ($this->grouptool->choose_min) { $minmaxtext = html_writer::tag('div', get_string('choose_min_text', 'grouptool', $this->grouptool->choose_min), array('class' => 'felement')); $class = ' choose_min'; } else { if ($this->grouptool->choose_max) { $minmaxtext = html_writer::tag('div', get_string('choose_max_text', 'grouptool', $this->grouptool->choose_max), array('class' => 'felement')); $class = ' choose_max'; } } } $generalinfo .= html_writer::tag('div', $minmaxtitle . $minmaxtext, array('class' => 'fitem ' . $class)); } if (!empty($this->grouptool->use_queue)) { $generalinfo .= html_writer::tag('div', html_writer::tag('div', get_string('queueing_is', 'grouptool'), array('class' => 'fitemtitle')) . html_writer::tag('div', get_string('active', 'grouptool'), array('class' => 'felement')), array('class' => 'fitem')); } $generalinfolegend = html_writer::tag('legend', get_string('general_information', 'grouptool')); if (has_capability('mod/grouptool:view_description', $this->context)) { echo html_writer::tag('fieldset', $generalinfolegend . html_writer::tag('div', $generalinfo, array('class' => 'fcontainer')), array('class' => 'clearfix')); // Intro-text if set! if (($this->grouptool->alwaysshowdescription || time() > $this->grouptool->timeavailable) && $this->grouptool->intro) { $intro = format_module_intro('grouptool', $this->grouptool, $this->cm->id); echo html_writer::tag('fieldset', html_writer::tag('legend', get_string('intro', 'grouptool')) . html_writer::tag('div', $intro, array('class' => 'fcontainer')), array('class' => 'clearfix')); } } $groups = $this->get_active_groups(); // Student view! if (has_capability("mod/grouptool:view_groups", $this->context)) { // Prepare formular-content for registration-action! foreach ($groups as $key => &$group) { $group = $this->get_active_groups(true, true, 0, $key); $group = current($group); $registered = count($group->registered); $grpsize = $this->grouptool->use_size ? $group->grpsize : "∞"; $grouphtml = html_writer::tag('span', get_string('registered', 'grouptool') . ": " . $registered . "/" . $grpsize, array('class' => 'fillratio')); if ($this->grouptool->use_queue) { $queued = count($group->queued); $grouphtml .= html_writer::tag('span', get_string('queued', 'grouptool') . " " . $queued, array('class' => 'queued')); } if ($this->grouptool->show_members) { $grouphtml .= $this->render_members_link($group->agrpid, $group->name); } if (!empty($group->registered)) { $regrank = $this->get_rank_in_queue($group->registered, $USER->id); } else { $regrank = false; } if (!empty($group->queued)) { $queuerank = $this->get_rank_in_queue($group->queued, $USER->id); } else { $queuerank = false; } /* If we include inactive groups and there's someone registered in one of these, * the label gets displayed incorrectly. */ $agrpids = $DB->get_fieldset_select('grouptool_agrps', 'id', "grouptoolid = ? AND active = 1", array($this->grouptool->id)); list($agrpsql, $params) = $DB->get_in_or_equal($agrpids); array_unshift($params, $userid); $userregs = $DB->count_records_select('grouptool_registered', "modified_by >= 0 AND userid = ? AND agrpid " . $agrpsql, $params); $userqueues = $DB->count_records_select('grouptool_queued', "userid = ? AND agrpid " . $agrpsql, $params); $max = $this->grouptool->allow_multiple ? $this->grouptool->choose_max : 1; $min = $this->grouptool->allow_multiple ? $this->grouptool->choose_min : 0; if (!empty($group->registered) && $this->get_rank_in_queue($group->registered, $userid) != false) { // User is allready registered --> unreg button! if ($this->grouptool->allow_unreg) { $label = get_string('unreg', 'grouptool'); $buttonattr = array('type' => 'submit', 'name' => 'unreg[' . $group->agrpid . ']', 'value' => $group->agrpid, 'class' => 'unregbutton'); if ($regopen && $userregs + $userqueues > $min) { $grouphtml .= html_writer::tag('button', $label, $buttonattr); } } $grouphtml .= html_writer::tag('span', get_string('registered_on_rank', 'grouptool', $regrank), array('class' => 'rank')); } else { if (!empty($group->queued) && $this->get_rank_in_queue($group->queued, $userid) != false) { // We're sorry, but user's already queued in this group! if ($this->grouptool->allow_unreg) { $label = get_string('unqueue', 'grouptool'); $buttonattr = array('type' => 'submit', 'name' => 'unreg[' . $group->agrpid . ']', 'value' => $group->agrpid, 'class' => 'unregbutton'); if ($regopen && $userregs + $userqueues > $min) { $grouphtml .= html_writer::tag('button', $label, $buttonattr); } } $grouphtml .= html_writer::tag('span', get_string('queued_on_rank', 'grouptool', $queuerank), array('class' => 'rank')); } else { if ($this->grpmarked($group->agrpid)) { $grouphtml .= html_writer::tag('span', get_string('grp_marked', 'grouptool'), array('class' => 'rank')); } else { if ($this->grouptool->allow_unreg && ($userqueues == 1 && $userregs == $max - 1 || $userregs + $userqueues == 1 && $max == 1)) { if ($regopen && (!$this->grouptool->use_size || count($group->registered) < $group->grpsize || $this->grouptool->use_queue && count($group->registered) >= $group->grpsize && $userqueues < $this->grouptool->queues_max)) { // Groupchange! $label = get_string('change_group', 'grouptool'); if ($this->grouptool->use_size && count($group->registered) >= $group->grpsize) { $label .= ' (' . get_string('queue', 'grouptool') . ')'; } $buttonattr = array('type' => 'submit', 'name' => 'reg[' . $group->agrpid . ']', 'value' => $group->agrpid, 'class' => 'regbutton'); $grouphtml .= html_writer::tag('button', $label, $buttonattr); } else { if ($regopen && $this->grouptool->use_queue && count($group->registered) >= $group->grpsize && $userqueues >= $this->grouptool->queues_max) { // Too many queues! $grouphtml .= html_writer::tag('div', get_string('max_queues_reached', 'grouptool'), array('class' => 'rank')); } else { if ($regopen) { // Group is full! $grouphtml .= html_writer::tag('div', get_string('fullgroup', 'grouptool'), array('class' => 'rank')); } } } } else { if ($regopen && $userregs + $userqueues < $max) { if (!$this->grouptool->use_size || count($group->registered) < $group->grpsize) { // Register button! $label = get_string('register', 'grouptool'); $buttonattr = array('type' => 'submit', 'name' => 'reg[' . $group->agrpid . ']', 'value' => $group->agrpid, 'class' => 'regbutton'); $grouphtml .= html_writer::tag('button', $label, $buttonattr); } else { if ($this->grouptool->use_queue) { if ($userqueues < $this->grouptool->queues_max) { // Queue button! $label = get_string('queue', 'grouptool'); $buttonattr = array('type' => 'submit', 'name' => 'reg[' . $group->agrpid . ']', 'value' => $group->agrpid, 'class' => 'queuebutton'); $grouphtml .= html_writer::tag('button', $label, $buttonattr); } else { // Too many queues! $grouphtml .= html_writer::tag('div', get_string('max_queues_reached', 'grouptool'), array('class' => 'rank')); } } else { // Group is full! $grouphtml .= html_writer::tag('div', get_string('fullgroup', 'grouptool'), array('class' => 'rank')); } } } else { if ($regopen) { $grouphtml .= html_writer::tag('div', get_string('max_regs_reached', 'grouptool'), array('class' => 'rank')); } } } } } } $status = ""; if ($regrank !== false) { $status = 'registered'; } else { if ($queuerank !== false) { $status = 'queued'; } else { if ($this->grouptool->use_size && $registered >= $group->grpsize) { $status = 'full'; } else { $status = 'empty'; } } } echo html_writer::tag('fieldset', html_writer::tag('legend', $group->name, array('class' => 'groupname')) . html_writer::tag('div', $grouphtml, array('class' => 'fcontainer clearfix')), array('class' => 'clearfix group ' . $status)); } } echo html_writer::end_tag('div'); echo html_writer::end_tag('form'); } }
function view_edit_items() { global $OUTPUT; echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter'); $currindent = 0; $addatend = true; $focusitem = false; $hasauto = false; $thispage = new moodle_url('/mod/checklist/edit.php', array('id' => $this->cm->id, 'sesskey' => sesskey())); if ($this->additemafter) { $thispage->param('additemafter', $this->additemafter); } if ($this->editdates) { $thispage->param('editdates', 'on'); } if ($this->checklist->autoupdate && $this->checklist->autopopulate) { if ($this->checklist->teacheredit == CHECKLIST_MARKING_STUDENT) { echo '<p>' . get_string('autoupdatewarning_student', 'checklist') . '</p>'; } else { if ($this->checklist->teacheredit == CHECKLIST_MARKING_TEACHER) { echo '<p class="checklistwarning">' . get_string('autoupdatewarning_teacher', 'checklist') . '</p>'; } else { echo '<p class="checklistwarning">' . get_string('autoupdatewarning_both', 'checklist') . '</p>'; } } } echo '<ol class="checklist">'; if ($this->items) { $lastitem = count($this->items); $lastindent = 0; foreach ($this->items as $item) { while ($item->indent > $currindent) { $currindent++; echo '<ol class="checklist">'; } while ($item->indent < $currindent) { $currindent--; echo '</ol>'; } $itemname = '"item' . $item->id . '"'; $thispage->param('itemid', $item->id); switch ($item->colour) { case 'red': $itemcolour = 'itemred'; $nexticon = 'colour_orange'; break; case 'orange': $itemcolour = 'itemorange'; $nexticon = 'colour_green'; break; case 'green': $itemcolour = 'itemgreen'; $nexticon = 'colour_purple'; break; case 'purple': $itemcolour = 'itempurple'; $nexticon = 'colour_black'; break; default: $itemcolour = 'itemblack'; $nexticon = 'colour_red'; } $autoitem = $this->checklist->autopopulate && $item->moduleid != 0; if ($autoitem) { $autoclass = ' itemauto'; } else { $autoclass = ''; } $hasauto = $hasauto || $item->moduleid != 0; echo '<li>'; if ($item->itemoptional == CHECKLIST_OPTIONAL_YES) { $title = '"' . get_string('optionalitem', 'checklist') . '"'; echo '<a href="' . $thispage->out(true, array('action' => 'makeheading')) . '">'; echo '<img src="' . $OUTPUT->pix_url('empty_box', 'checklist') . '" alt=' . $title . ' title=' . $title . ' /></a> '; $optional = ' class="itemoptional ' . $itemcolour . $autoclass . '" '; } else { if ($item->itemoptional == CHECKLIST_OPTIONAL_HEADING) { if ($item->hidden) { $title = '"' . get_string('headingitem', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('no_box', 'checklist') . '" alt=' . $title . ' title=' . $title . ' /> '; $optional = ' class="' . $itemcolour . $autoclass . ' itemdisabled"'; } else { $title = '"' . get_string('headingitem', 'checklist') . '"'; if (!$autoitem) { echo '<a href="' . $thispage->out(true, array('action' => 'makerequired')) . '">'; } echo '<img src="' . $OUTPUT->pix_url('no_box', 'checklist') . '" alt=' . $title . ' title=' . $title . ' />'; if (!$autoitem) { echo '</a>'; } echo ' '; $optional = ' class="itemheading ' . $itemcolour . $autoclass . '" '; } } else { if ($item->hidden) { $title = '"' . get_string('requireditem', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('tick_box', 'checklist') . '" alt=' . $title . ' title=' . $title . ' /> '; $optional = ' class="' . $itemcolour . $autoclass . ' itemdisabled"'; } else { $title = '"' . get_string('requireditem', 'checklist') . '"'; echo '<a href="' . $thispage->out(true, array('action' => 'makeoptional')) . '">'; echo '<img src="' . $OUTPUT->pix_url('tick_box', 'checklist') . '" alt=' . $title . ' title=' . $title . ' /></a> '; $optional = ' class="' . $itemcolour . $autoclass . '"'; } } } if (isset($item->editme)) { echo '<form style="display:inline" action="' . $thispage->out_omit_querystring() . '" method="post">'; echo '<input type="text" size="' . CHECKLIST_TEXT_INPUT_WIDTH . '" name="displaytext" value="' . s($item->displaytext) . '" id="updateitembox" />'; echo '<input type="hidden" name="action" value="updateitem" />'; echo html_writer::input_hidden_params($thispage); if ($this->editdates) { $this->print_edit_date($item->duetime); } echo '<input type="submit" name="updateitem" value="' . get_string('updateitem', 'checklist') . '" />'; echo '</form>'; $focusitem = 'updateitembox'; echo '<form style="display:inline" action="' . $thispage->out_omit_querystring() . '" method="get">'; echo html_writer::input_hidden_params($thispage, array('sesskey', 'itemid')); echo '<input type="submit" name="canceledititem" value="' . get_string('canceledititem', 'checklist') . '" />'; echo '</form>'; $addatend = false; } else { echo '<label for=' . $itemname . $optional . '>' . s($item->displaytext) . '</label> '; echo '<a href="' . $thispage->out(true, array('action' => 'nextcolour')) . '">'; $title = '"' . get_string('changetextcolour', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url($nexticon, 'checklist') . '" alt=' . $title . ' title=' . $title . ' /></a>'; if (!$autoitem) { echo '<a href="' . $thispage->out(true, array('action' => 'edititem')) . '">'; $title = '"' . get_string('edititem', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/edit') . '" alt=' . $title . ' title=' . $title . ' /></a> '; } if (!$autoitem && $item->indent > 0) { echo '<a href="' . $thispage->out(true, array('action' => 'unindentitem')) . '">'; $title = '"' . get_string('unindentitem', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/left') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } if (!$autoitem && $item->indent < CHECKLIST_MAX_INDENT && $lastindent + 1 > $currindent) { echo '<a href="' . $thispage->out(true, array('action' => 'indentitem')) . '">'; $title = '"' . get_string('indentitem', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/right') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } echo ' '; // TODO more complex checks to take into account indentation if (!$autoitem && $item->position > 1) { echo '<a href="' . $thispage->out(true, array('action' => 'moveitemup')) . '">'; $title = '"' . get_string('moveitemup', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/up') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } if (!$autoitem && $item->position < $lastitem) { echo '<a href="' . $thispage->out(true, array('action' => 'moveitemdown')) . '">'; $title = '"' . get_string('moveitemdown', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/down') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } if ($autoitem) { if ($item->hidden != CHECKLIST_HIDDEN_BYMODULE) { echo ' <a href="' . $thispage->out(true, array('action' => 'deleteitem')) . '">'; if ($item->hidden == CHECKLIST_HIDDEN_MANUAL) { $title = '"' . get_string('show') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/show') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } else { $title = '"' . get_string('hide') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/hide') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } } } else { echo ' <a href="' . $thispage->out(true, array('action' => 'deleteitem')) . '">'; $title = '"' . get_string('deleteitem', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('/t/delete') . '" alt=' . $title . ' title=' . $title . ' /></a>'; } echo ' <a href="' . $thispage->out(true, array('action' => 'startadditem')) . '">'; $title = '"' . get_string('additemhere', 'checklist') . '"'; echo '<img src="' . $OUTPUT->pix_url('add', 'checklist') . '" alt=' . $title . ' title=' . $title . ' /></a>'; if ($item->duetime) { if ($item->duetime > time()) { echo '<span class="checklist-itemdue"> ' . userdate($item->duetime, get_string('strftimedate')) . '</span>'; } else { echo '<span class="checklist-itemoverdue"> ' . userdate($item->duetime, get_string('strftimedate')) . '</span>'; } } } $thispage->remove_params(array('itemid')); if ($this->additemafter == $item->id) { $addatend = false; echo '<li>'; echo '<form style="display:inline;" action="' . $thispage->out_omit_querystring() . '" method="post">'; echo html_writer::input_hidden_params($thispage); echo '<input type="hidden" name="action" value="additem" />'; echo '<input type="hidden" name="position" value="' . ($item->position + 1) . '" />'; echo '<input type="hidden" name="indent" value="' . $item->indent . '" />'; echo '<img src="' . $OUTPUT->pix_url('tick_box', 'checklist') . '" /> '; echo '<input type="text" size="' . CHECKLIST_TEXT_INPUT_WIDTH . '" name="displaytext" value="" id="additembox" />'; if ($this->editdates) { $this->print_edit_date(); } echo '<input type="submit" name="additem" value="' . get_string('additem', 'checklist') . '" />'; echo '</form>'; echo '<form style="display:inline" action="' . $thispage->out_omit_querystring() . '" method="get">'; echo html_writer::input_hidden_params($thispage, array('sesskey', 'additemafter')); echo '<input type="submit" name="canceledititem" value="' . get_string('canceledititem', 'checklist') . '" />'; echo '</form>'; echo '</li>'; if (!$focusitem) { $focusitem = 'additembox'; } $lastindent = $currindent; } echo '</li>'; } } $thispage->remove_params(array('itemid')); if ($addatend) { echo '<li>'; echo '<form action="' . $thispage->out_omit_querystring() . '" method="post">'; echo html_writer::input_hidden_params($thispage); echo '<input type="hidden" name="action" value="additem" />'; echo '<input type="hidden" name="indent" value="' . $currindent . '" />'; echo '<input type="text" size="' . CHECKLIST_TEXT_INPUT_WIDTH . '" name="displaytext" value="" id="additembox" />'; if ($this->editdates) { $this->print_edit_date(); } echo '<input type="submit" name="additem" value="' . get_string('additem', 'checklist') . '" />'; echo '</form>'; echo '</li>'; if (!$focusitem) { $focusitem = 'additembox'; } } echo '</ol>'; while ($currindent) { $currindent--; echo '</ol>'; } echo '<form action="' . $thispage->out_omit_querystring() . '" method="get">'; echo html_writer::input_hidden_params($thispage, array('sesskey', 'editdates')); if (!$this->editdates) { echo '<input type="hidden" name="editdates" value="on" />'; echo '<input type="submit" value="' . get_string('editdatesstart', 'checklist') . '" />'; } else { echo '<input type="submit" value="' . get_string('editdatesstop', 'checklist') . '" />'; } if (!$this->checklist->autopopulate && $hasauto) { echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; echo '<input type="submit" value="' . get_string('removeauto', 'checklist') . '" name="removeauto" />'; } echo '</form>'; if ($focusitem) { echo '<script type="text/javascript">document.getElementById("' . $focusitem . '").focus();</script>'; } echo $OUTPUT->box_end(); }
/** * Compares this moodle_url with another * See documentation of constants for an explanation of the comparison flags. * @param moodle_url $url The moodle_url object to compare * @param int $matchtype The type of comparison (URL_MATCH_BASE, URL_MATCH_PARAMS, URL_MATCH_EXACT) * @return boolean */ public function compare(moodle_url $url, $matchtype = URL_MATCH_EXACT) { $baseself = $this->out_omit_querystring(); $baseother = $url->out_omit_querystring(); // Append index.php if there is no specific file if (substr($baseself, -1) == '/') { $baseself .= 'index.php'; } if (substr($baseother, -1) == '/') { $baseother .= 'index.php'; } // Compare the two base URLs if ($baseself != $baseother) { return false; } if ($matchtype == URL_MATCH_BASE) { return true; } $urlparams = $url->params(); foreach ($this->params() as $param => $value) { if ($param == 'sesskey') { continue; } if (!array_key_exists($param, $urlparams) || $urlparams[$param] != $value) { return false; } } if ($matchtype == URL_MATCH_PARAMS) { return true; } foreach ($urlparams as $param => $value) { if ($param == 'sesskey') { continue; } if (!array_key_exists($param, $this->params()) || $this->param($param) != $value) { return false; } } return true; }
public function display($quiz, $cm, $course) { global $CFG, $COURSE, $DB, $OUTPUT; $this->context = get_context_instance(CONTEXT_MODULE, $cm->id); $download = optional_param('download', '', PARAM_ALPHA); list($currentgroup, $students, $groupstudents, $allowed) = $this->load_relevant_students($cm); $pageoptions = array(); $pageoptions['id'] = $cm->id; $pageoptions['mode'] = 'overview'; $reporturl = new moodle_url('/mod/quiz/report.php', $pageoptions); $qmsubselect = quiz_report_qm_filter_select($quiz); $mform = new mod_quiz_report_overview_settings($reporturl, array('qmsubselect' => $qmsubselect, 'quiz' => $quiz, 'currentgroup' => $currentgroup, 'context' => $this->context)); if ($fromform = $mform->get_data()) { $regradeall = false; $regradealldry = false; $regradealldrydo = false; $attemptsmode = $fromform->attemptsmode; if ($qmsubselect) { $qmfilter = $fromform->qmfilter; } else { $qmfilter = 0; } $regradefilter = !empty($fromform->regradefilter); set_user_preference('quiz_report_overview_detailedmarks', $fromform->detailedmarks); set_user_preference('quiz_report_pagesize', $fromform->pagesize); $detailedmarks = $fromform->detailedmarks; $pagesize = $fromform->pagesize; } else { $regradeall = optional_param('regradeall', 0, PARAM_BOOL); $regradealldry = optional_param('regradealldry', 0, PARAM_BOOL); $regradealldrydo = optional_param('regradealldrydo', 0, PARAM_BOOL); $attemptsmode = optional_param('attemptsmode', null, PARAM_INT); if ($qmsubselect) { $qmfilter = optional_param('qmfilter', 0, PARAM_INT); } else { $qmfilter = 0; } $regradefilter = optional_param('regradefilter', 0, PARAM_INT); $detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1); $pagesize = get_user_preferences('quiz_report_pagesize', 0); } $this->validate_common_options($attemptsmode, $pagesize, $course, $currentgroup); $displayoptions = array(); $displayoptions['attemptsmode'] = $attemptsmode; $displayoptions['qmfilter'] = $qmfilter; $displayoptions['regradefilter'] = $regradefilter; $mform->set_data($displayoptions + array('detailedmarks' => $detailedmarks, 'pagesize' => $pagesize)); if (!$this->should_show_grades($quiz)) { $detailedmarks = 0; } // We only want to show the checkbox to delete attempts // if the user has permissions and if the report mode is showing attempts. $candelete = has_capability('mod/quiz:deleteattempts', $this->context) && $attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO; if ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) { // 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(); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); $displaycoursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id); $displaycourseshortname = format_string($COURSE->shortname, true, array('context' => $displaycoursecontext)); // Load the required questions. $questions = quiz_report_get_significant_questions($quiz); $table = new quiz_report_overview_table($quiz, $this->context, $qmsubselect, $groupstudents, $students, $detailedmarks, $questions, $candelete, $reporturl, $displayoptions); $filename = quiz_report_download_filename(get_string('overviewfilename', 'quiz_overview'), $courseshortname, $quiz->name); $table->is_downloading($download, $filename, $displaycourseshortname . ' ' . format_string($quiz->name, true)); if ($table->is_downloading()) { raise_memory_limit(MEMORY_EXTRA); } // Process actions. if (empty($currentgroup) || $groupstudents) { if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) { if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) { require_capability('mod/quiz:deleteattempts', $this->context); $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed); redirect($reporturl->out(false, $displayoptions)); } } else { if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) { if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts($quiz, false, $groupstudents, $attemptids); redirect($reporturl->out(false, $displayoptions)); } } } } if ($regradeall && confirm_sesskey()) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts($quiz, false, $groupstudents); redirect($reporturl->out(false, $displayoptions), '', 5); } else { if ($regradealldry && confirm_sesskey()) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts($quiz, true, $groupstudents); redirect($reporturl->out(false, $displayoptions), '', 5); } else { if ($regradealldrydo && confirm_sesskey()) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts_needing_it($quiz, $groupstudents); redirect($reporturl->out(false, $displayoptions), '', 5); } } } // Start output. if (!$table->is_downloading()) { // Only print headers if not asked to download data $this->print_header_and_tabs($cm, $course, $quiz, 'overview'); } if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if (!$table->is_downloading()) { groups_print_activity_menu($cm, $reporturl->out(true, $displayoptions)); } } // 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 '<div class="quizattemptcounts">' . $strattemptnum . '</div>'; } } $hasquestions = quiz_questions_in_quiz($quiz->questions); if (!$table->is_downloading()) { if (!$hasquestions) { echo quiz_no_questions_message($quiz, $cm, $this->context); } else { if (!$students) { echo $OUTPUT->notification(get_string('nostudentsyet')); } else { if ($currentgroup && !$groupstudents) { echo $OUTPUT->notification(get_string('nostudentsingroup')); } } } // Print display options $mform->display(); } $hasstudents = $students && (!$currentgroup || $groupstudents); if ($hasquestions && ($hasstudents || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) { // Construct the SQL $fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') . ' AS uniqueid, '; if ($qmsubselect) { $fields .= "(CASE " . " WHEN {$qmsubselect} THEN 1" . " ELSE 0 " . "END) AS gradedattempt, "; } list($fields, $from, $where, $params) = $this->base_sql($quiz, $qmsubselect, $qmfilter, $attemptsmode, $allowed); $table->set_count_sql("SELECT COUNT(1) FROM {$from} WHERE {$where}", $params); // Test to see if there are any regraded attempts to be listed. $fields .= ", COALESCE((\n SELECT MAX(qqr.regraded)\n FROM {quiz_overview_regrades} qqr\n WHERE qqr.questionusageid = quiza.uniqueid\n ), -1) AS regraded"; if ($regradefilter) { $where .= " AND COALESCE((\n SELECT MAX(qqr.regraded)\n FROM {quiz_overview_regrades} qqr\n WHERE qqr.questionusageid = quiza.uniqueid\n ), -1) <> -1"; } $table->set_sql($fields, $from, $where, $params); if (!$table->is_downloading()) { // Regrade buttons if (has_capability('mod/quiz:regrade', $this->context)) { $regradesneeded = $this->count_question_attempts_needing_regrade($quiz, $groupstudents); if ($currentgroup) { $a = new stdClass(); $a->groupname = groups_get_group_name($currentgroup); $a->coursestudents = get_string('participants'); $a->countregradeneeded = $regradesneeded; $regradealldrydolabel = get_string('regradealldrydogroup', 'quiz_overview', $a); $regradealldrylabel = get_string('regradealldrygroup', 'quiz_overview', $a); $regradealllabel = get_string('regradeallgroup', 'quiz_overview', $a); } else { $regradealldrydolabel = get_string('regradealldrydo', 'quiz_overview', $regradesneeded); $regradealldrylabel = get_string('regradealldry', 'quiz_overview'); $regradealllabel = get_string('regradeall', 'quiz_overview'); } $displayurl = new moodle_url($reporturl, $displayoptions + array('sesskey' => sesskey())); echo '<div class="mdl-align">'; echo '<form action="' . $displayurl->out_omit_querystring() . '">'; echo '<div>'; echo html_writer::input_hidden_params($displayurl); echo '<input type="submit" name="regradeall" value="' . $regradealllabel . '"/>'; echo '<input type="submit" name="regradealldry" value="' . $regradealldrylabel . '"/>'; if ($regradesneeded) { echo '<input type="submit" name="regradealldrydo" value="' . $regradealldrydolabel . '"/>'; } echo '</div>'; echo '</form>'; echo '</div>'; } // Print information on the grading method if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) { echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>'; } } // Define table columns $columns = array(); $headers = array(); if (!$table->is_downloading() && $candelete) { $columns[] = 'checkbox'; $headers[] = null; } $this->add_user_columns($table, $columns, $headers); $this->add_time_columns($columns, $headers); if ($detailedmarks) { foreach ($questions as $slot => $question) { // Ignore questions of zero length $columns[] = 'qsgrade' . $slot; $header = get_string('qbrief', 'quiz', $question->number); if (!$table->is_downloading()) { $header .= '<br />'; } else { $header .= ' '; } $header .= '/' . quiz_rescale_grade($question->maxmark, $quiz, 'question'); $headers[] = $header; } } if (!$table->is_downloading() && has_capability('mod/quiz:regrade', $this->context) && $this->has_regraded_questions($from, $where, $params)) { $columns[] = 'regraded'; $headers[] = get_string('regrade', 'quiz_overview'); } $this->add_grade_columns($quiz, $columns, $headers); $this->set_up_table_columns($table, $columns, $headers, $reporturl, $displayoptions, false); $table->set_attribute('class', 'generaltable generalbox grades'); $table->out($pagesize, true); } if (!$table->is_downloading() && $this->should_show_grades($quiz)) { if ($currentgroup && $groupstudents) { list($usql, $params) = $DB->get_in_or_equal($groupstudents); $params[] = $quiz->id; if ($DB->record_exists_select('quiz_grades', "userid {$usql} AND quiz = ?", $params)) { $imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php', array('id' => $quiz->id, 'groupid' => $currentgroup)); $graphname = get_string('overviewreportgraphgroup', 'quiz_overview', groups_get_group_name($currentgroup)); echo $OUTPUT->heading($graphname); echo html_writer::tag('div', html_writer::empty_tag('img', array('src' => $imageurl, 'alt' => $graphname)), array('class' => 'graph')); } } if ($DB->record_exists('quiz_grades', array('quiz' => $quiz->id))) { $graphname = get_string('overviewreportgraph', 'quiz_overview'); $imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php', array('id' => $quiz->id)); echo $OUTPUT->heading($graphname); echo html_writer::tag('div', html_writer::empty_tag('img', array('src' => $imageurl, 'alt' => $graphname)), array('class' => 'graph')); } } return true; }
/** * Render a form to create a new course section, prompting for basic info. * * @return string */ private function change_num_sections($course) { global $PAGE; $course = course_get_format($course)->get_course(); $context = context_course::instance($course->id); if (!$PAGE->user_is_editing() || !has_capability('moodle/course:update', $context)) { return ''; } $output = "<div class='snap-section-remove'>"; if ($course->numsections > 0) { $strremovesection = get_string('removethissection', 'theme_snap'); $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey())); $output .= html_writer::link($url, $strremovesection, array('class' => 'btn btn-default')); } $output .= "</div>"; $url = new moodle_url('/theme/snap/index.php', array('sesskey' => sesskey(), 'action' => 'addsection', 'contextid' => $context->id)); $heading = get_string('addanewsection', 'theme_snap'); $output .= "<h3>{$heading}</h3>"; $output .= html_writer::start_tag('form', array('method' => 'post', 'action' => $url->out_omit_querystring())); $output .= html_writer::input_hidden_params($url); $output .= '<div class="form-group">'; $output .= html_writer::label(get_string('sectionname'), 'newsection', true); $output .= html_writer::empty_tag('input', array('id' => 'newsection', 'type' => 'text', 'size' => 50, 'name' => 'newsection', 'required' => 'required')); $output .= '</div>'; $output .= '<div class="form-group">'; $output .= html_writer::label(get_string('summary'), 'summary', true); $output .= print_textarea(true, 10, 150, "100%", "auto", "summary", '', $course->id, true); $output .= '</div>'; $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'addtopic', 'value' => get_string('createsection', 'theme_snap'))); $output .= html_writer::end_tag('form'); return $output; }