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" class="overview-tablecontainer">'; echo '<form id="attemptsform" method="post" action="' . $this->reporturl->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>'; } } }
/** * Prints the table of questions in a category with interactions * * @param object $course The course object * @param int $categoryid The id of the question category to be displayed * @param int $cm The course module record if we are in the context of a particular module, 0 otherwise * @param int $recurse This is 1 if subcategories should be included, 0 otherwise * @param int $page The number of the page to be displayed * @param int $perpage Number of questions to show per page * @param bool $showhidden True if also hidden questions should be displayed * @param bool $showquestiontext whether the text of each question should be shown in the list */ protected function display_question_list($contexts, $pageurl, $categoryandcontext, $cm = null, $recurse=1, $page=0, $perpage=100, $showhidden=false, $showquestiontext = false, $addcontexts = array()) { global $CFG, $DB, $OUTPUT; $category = $this->get_current_category($categoryandcontext); $cmoptions = new stdClass(); $cmoptions->hasattempts = !empty($this->quizhasattempts); $strselectall = get_string('selectall'); $strselectnone = get_string('deselectall'); $strdelete = get_string('delete'); list($categoryid, $contextid) = explode(',', $categoryandcontext); $catcontext = context::instance_by_id($contextid); $canadd = has_capability('moodle/question:add', $catcontext); $caneditall =has_capability('moodle/question:editall', $catcontext); $canuseall =has_capability('moodle/question:useall', $catcontext); $canmoveall =has_capability('moodle/question:moveall', $catcontext); $this->create_new_question_form($category, $canadd); $this->build_query_sql($category, $recurse, $showhidden); $totalnumber = $this->get_question_count(); if ($totalnumber == 0) { return; } $questions = $this->load_page_questions($page, $perpage); echo '<div class="categorypagingbarcontainer">'; $pageing_url = new moodle_url('edit.php'); $r = $pageing_url->params($pageurl->params()); $pagingbar = new paging_bar($totalnumber, $page, $perpage, $pageing_url); $pagingbar->pagevar = 'qpage'; echo $OUTPUT->render($pagingbar); echo '</div>'; echo '<form method="post" action="edit.php">'; echo '<fieldset class="invisiblefieldset" style="display: block;">'; echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; echo html_writer::input_hidden_params($pageurl); echo '<div class="categoryquestionscontainer">'; $this->start_table(); $rowcount = 0; foreach ($questions as $question) { $this->print_table_row($question, $rowcount); $rowcount += 1; } $this->end_table(); echo "</div>\n"; echo '<div class="categorypagingbarcontainer pagingbottom">'; echo $OUTPUT->render($pagingbar); if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) { if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) { $url = new moodle_url('edit.php', array_merge($pageurl->params(), array('qperpage'=>1000))); $showall = '<a href="'.$url.'">'.get_string('showall', 'moodle', $totalnumber).'</a>'; } else { $url = new moodle_url('edit.php', array_merge($pageurl->params(), array('qperpage'=>DEFAULT_QUESTIONS_PER_PAGE))); $showall = '<a href="'.$url.'">'.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).'</a>'; } echo "<div class='paging'>$showall</div>"; } echo '</div>'; echo '<div class="modulespecificbuttonscontainer">'; if ($caneditall || $canmoveall || $canuseall){ echo '<strong> '.get_string('withselected', 'question').':</strong><br />'; if (function_exists('module_specific_buttons')) { echo module_specific_buttons($this->cm->id,$cmoptions); } // print delete and move selected question if ($caneditall) { echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" />\n"; } if ($canmoveall && count($addcontexts)) { echo '<input type="submit" name="move" value="'.get_string('moveto', 'question')."\" />\n"; question_category_select_menu($addcontexts, false, 0, "$category->id,$category->contextid"); } if (function_exists('module_specific_controls') && $canuseall) { $modulespecific = module_specific_controls($totalnumber, $recurse, $category, $this->cm->id,$cmoptions); if(!empty($modulespecific)){ echo "<hr />$modulespecific"; } } } echo "</div>\n"; echo '</fieldset>'; echo "</form>\n"; }
echo $OUTPUT->box(format_module_intro('zoom', $zoom, $cm->id), 'generalbox mod_introbox', 'intro'); } $table = new html_table(); $table->attributes['class'] = 'generaltable mod_view'; $table->align = array('center', 'left'); $numcolumns = 2; list($inprogress, $available, $finished) = zoom_get_state($zoom); if ($available) { if ($userishost) { $buttonhtml = html_writer::tag('button', $strstart, array('type' => 'submit', 'class' => 'btn btn-success')); $aurl = new moodle_url($zoom->start_url); } else { $buttonhtml = html_writer::tag('button', $strjoin, array('type' => 'submit', 'class' => 'btn btn-primary')); $aurl = new moodle_url('/mod/zoom/loadmeeting.php', array('id' => $cm->id)); } $buttonhtml .= html_writer::input_hidden_params($aurl); $link = html_writer::tag('form', $buttonhtml, array('action' => $aurl->out_omit_querystring())); } else { $link = html_writer::tag('span', $strunavailable, array('style' => 'font-size:20px')); } $title = new html_table_cell($link); $title->header = true; $title->colspan = $numcolumns; $table->data[] = array($title); $sessionsurl = new moodle_url('/mod/zoom/report.php', array('id' => $cm->id)); $sessionslink = html_writer::link($sessionsurl, get_string('sessions', 'mod_zoom')); $sessions = new html_table_cell($sessionslink); $sessions->colspan = $numcolumns; $table->data[] = array($sessions); if ($zoom->recurring) { $recurringmessage = new html_table_cell(get_string('recurringmeetinglong', 'mod_zoom'));
$buttons = $OUTPUT->single_button($url, $caption, 'get'); $PAGE->set_button($buttons); } $visiblepathtosection = array_reverse($settingspage->visiblepath); $PAGE->set_title("{$SITE->shortname}: " . implode(": ", $visiblepathtosection)); $PAGE->set_heading($SITE->fullname); echo $OUTPUT->header(); if ($errormsg !== '') { echo $OUTPUT->notification($errormsg); } else { if ($statusmsg !== '') { echo $OUTPUT->notification($statusmsg, 'notifysuccess'); } } // --------------------------------------------------------------------------------------------------------------- echo '<form action="settings.php" method="post" id="adminsettings">'; echo '<div class="settingsform clearfix">'; echo html_writer::input_hidden_params($PAGE->url); echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; echo '<input type="hidden" name="return" value="' . $return . '" />'; echo $OUTPUT->heading($settingspage->visiblename); echo $settingspage->output_html(); if ($settingspage->show_save()) { echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges', 'admin') . '" /></div>'; } echo '</div>'; echo '</form>'; } $PAGE->requires->yui_module('moodle-core-formchangechecker', 'M.core_formchangechecker.init', array(array('formid' => 'adminsettings'))); $PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle'); echo $OUTPUT->footer();
protected function display_options($recurse, $showhidden, $showquestiontext) { echo '<form method="get" action="edit.php" id="displayoptions">'; echo "<fieldset class='invisiblefieldset'>"; echo html_writer::input_hidden_params($this->baseurl, array('recurse', 'showhidden', 'qbshowtext')); $this->display_category_form_checkbox('recurse', $recurse, get_string('includesubcategories', 'question')); $this->display_category_form_checkbox('showhidden', $showhidden, get_string('showhidden', 'question')); echo '<noscript><div class="centerpara"><input type="submit" value="' . get_string('go') . '" />'; echo '</div></noscript></fieldset></form>'; }
} } echo '</div>'; } // Fetch the attempts if (!$download) { $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size()); echo '<div id="scormtablecontainer">'; if ($candelete) { // Start form $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm')); echo '<form id="attemptsform" method="post" action="' . $reporturlwithdisplayoptions->out(true) . '" onsubmit="return confirm(\'' . $strreallydel . '\');">'; echo '<input type="hidden" name="action" value="delete"/>'; echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; echo '<div style="display: none;">'; echo html_writer::input_hidden_params($reporturlwithdisplayoptions); echo '</div>'; echo '<div>'; } $table->initialbars($totalinitials > 20); // Build table rows } else { $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params); } if ($attempts) { foreach ($attempts as $scouser) { $row = array(); if (!empty($scouser->attempt)) { $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt); } if (in_array('checkbox', $columns)) {
protected function display_grading_interface($slot, $questionid, $grade, $pagesize, $page, $shownames, $showidnumbers, $order, $counts) { global $OUTPUT; if ($pagesize * $page >= $counts->{$grade}) { $page = 0; } list($qubaids, $count) = $this->get_usage_ids_where_question_in_state($grade, $slot, $questionid, $order, $page, $pagesize); $attempts = $this->load_attempts_by_usage_ids($qubaids); // Prepare the form. $hidden = array('id' => $this->cm->id, 'mode' => 'grading', 'slot' => $slot, 'qid' => $questionid, 'page' => $page); if (array_key_exists('includeauto', $this->viewoptions)) { $hidden['includeauto'] = $this->viewoptions['includeauto']; } $mform = new quiz_grading_settings_form($hidden, $counts, $shownames, $showidnumbers); // Tell the form the current settings. $settings = new stdClass(); $settings->grade = $grade; $settings->pagesize = $pagesize; $settings->order = $order; $mform->set_data($settings); // Print the heading and form. echo question_engine::initialise_js(); $a = new stdClass(); $a->number = $this->questions[$slot]->number; $a->questionname = format_string($counts->name); echo $OUTPUT->heading(get_string('gradingquestionx', 'quiz_grading', $a), 3); echo html_writer::tag('p', html_writer::link($this->list_questions_url(), get_string('backtothelistofquestions', 'quiz_grading')), array('class' => 'mdl-align')); $mform->display(); // Paging info. $a = new stdClass(); $a->from = $page * $pagesize + 1; $a->to = min(($page + 1) * $pagesize, $count); $a->of = $count; echo $OUTPUT->heading(get_string('gradingattemptsxtoyofz', 'quiz_grading', $a), 3); if ($count > $pagesize && $order != 'random') { echo $OUTPUT->paging_bar($count, $page, $pagesize, $this->grade_question_url($slot, $questionid, $grade, false)); } // Display the form with one section for each attempt. $sesskey = sesskey(); $qubaidlist = implode(',', $qubaids); echo html_writer::start_tag('form', array('method' => 'post', 'action' => $this->grade_question_url($slot, $questionid, $grade, $page), 'class' => 'mform', 'id' => 'manualgradingform')) . html_writer::start_tag('div') . html_writer::input_hidden_params(new moodle_url('', array('qubaids' => $qubaidlist, 'slots' => $slot, 'sesskey' => $sesskey))); foreach ($qubaids as $qubaid) { $attempt = $attempts[$qubaid]; $quba = question_engine::load_questions_usage_by_activity($qubaid); $displayoptions = quiz_get_review_options($this->quiz, $attempt, $this->context); $displayoptions->hide_all_feedback(); $displayoptions->history = question_display_options::HIDDEN; $displayoptions->manualcomment = question_display_options::EDITABLE; $heading = $this->get_question_heading($attempt, $shownames, $showidnumbers); if ($heading) { echo $OUTPUT->heading($heading, 4); } echo $quba->render_question($slot, $displayoptions, $this->questions[$slot]->number); } echo html_writer::tag('div', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('saveandnext', 'quiz_grading'))), array('class' => 'mdl-align')) . html_writer::end_tag('div') . html_writer::end_tag('form'); }
/** * displays the full report * @param \stdClass $scorm full SCORM object * @param \stdClass $cm - full course_module object * @param \stdClass $course - full course object * @param string $download - type of download being requested */ public function display($scorm, $cm, $course, $download) { global $CFG, $DB, $OUTPUT, $PAGE; $contextmodule = \context_module::instance($cm->id); $action = optional_param('action', '', PARAM_ALPHA); $attemptids = optional_param_array('attemptid', array(), PARAM_RAW); $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT); $PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode))); if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) { if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses. echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess'); } } // Find out current groups mode. $currentgroup = groups_get_activity_group($cm, true); // Detailed report. $mform = new \mod_scorm_report_objectives_settings($PAGE->url, compact('currentgroup')); if ($fromform = $mform->get_data()) { $pagesize = $fromform->pagesize; $showobjectivescore = $fromform->objectivescore; set_user_preference('scorm_report_pagesize', $pagesize); set_user_preference('scorm_report_objectives_score', $showobjectivescore); } else { $pagesize = get_user_preferences('scorm_report_pagesize', 0); $showobjectivescore = get_user_preferences('scorm_report_objectives_score', 0); } if ($pagesize < 1) { $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE; } // Select group menu. $displayoptions = array(); $displayoptions['attemptsmode'] = $attemptsmode; $displayoptions['objectivescore'] = $showobjectivescore; $mform->set_data($displayoptions + array('pagesize' => $pagesize)); if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used. if (!$download) { groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions)); } } $formattextoptions = array('context' => \context_course::instance($course->id)); // 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/scorm:deleteresponses', $contextmodule) && $attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO; // Select the students. $nostudents = false; if (empty($currentgroup)) { // All users who can attempt scoes. if (!($students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', '', '', false))) { echo $OUTPUT->notification(get_string('nostudentsyet')); $nostudents = true; $allowedlist = ''; } else { $allowedlist = array_keys($students); } unset($students); } else { // All users who can attempt scoes and who are in the currently selected group. $groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', $currentgroup, '', false); if (!$groupstudents) { echo $OUTPUT->notification(get_string('nostudentsingroup')); $nostudents = true; $groupstudents = array(); } $allowedlist = array_keys($groupstudents); unset($groupstudents); } if (!$nostudents) { // Now check if asked download of data. $coursecontext = \context_course::instance($course->id); if ($download) { $filename = clean_filename("{$course->shortname} " . format_string($scorm->name, true, $formattextoptions)); } // Define table columns. $columns = array(); $headers = array(); if (!$download && $candelete) { $columns[] = 'checkbox'; $headers[] = null; } if (!$download && $CFG->grade_report_showuserimage) { $columns[] = 'picture'; $headers[] = ''; } $columns[] = 'fullname'; $headers[] = get_string('name'); $extrafields = get_extra_user_fields($coursecontext); foreach ($extrafields as $field) { $columns[] = $field; $headers[] = get_user_field_name($field); } $columns[] = 'attempt'; $headers[] = get_string('attempt', 'scorm'); $columns[] = 'start'; $headers[] = get_string('started', 'scorm'); $columns[] = 'finish'; $headers[] = get_string('last', 'scorm'); $columns[] = 'score'; $headers[] = get_string('score', 'scorm'); $scoes = $DB->get_records('scorm_scoes', array("scorm" => $scorm->id), 'sortorder, id'); foreach ($scoes as $sco) { if ($sco->launch != '') { $columns[] = 'scograde' . $sco->id; $headers[] = format_string($sco->title, '', $formattextoptions); } } $params = array(); list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED); // Construct the SQL. $select = 'SELECT DISTINCT ' . $DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)') . ' AS uniqueid, '; $select .= 'st.scormid AS scormid, st.attempt AS attempt, ' . \user_picture::fields('u', array('idnumber'), 'userid') . get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' '; // This part is the same for all cases - join users and scorm_scoes_track tables. $from = 'FROM {user} u '; $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = ' . $scorm->id; switch ($attemptsmode) { case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH: // Show only students with attempts. $where = ' WHERE u.id ' . $usql . ' AND st.userid IS NOT NULL'; break; case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO: // Show only students without attempts. $where = ' WHERE u.id ' . $usql . ' AND st.userid IS NULL'; break; case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS: // Show all students with or without attempts. $where = ' WHERE u.id ' . $usql . ' AND (st.userid IS NOT NULL OR st.userid IS NULL)'; break; } $countsql = 'SELECT COUNT(DISTINCT(' . $DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)') . ')) AS nbresults, '; $countsql .= 'COUNT(DISTINCT(' . $DB->sql_concat('u.id', '\'#\'', 'st.attempt') . ')) AS nbattempts, '; $countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers '; $countsql .= $from . $where; $nbmaincolumns = count($columns); // Get number of main columns used. $objectives = get_scorm_objectives($scorm->id); $nosort = array(); foreach ($objectives as $scoid => $sco) { foreach ($sco as $id => $objectivename) { $colid = $scoid . 'objectivestatus' . $id; $columns[] = $colid; $nosort[] = $colid; if (!$displayoptions['objectivescore']) { // Display the objective name only. $headers[] = $objectivename; } else { // Display the objective status header with a "status" suffix to avoid confusion. $headers[] = $objectivename . ' ' . get_string('status', 'scormreport_objectives'); // Now print objective score headers. $colid = $scoid . 'objectivescore' . $id; $columns[] = $colid; $nosort[] = $colid; $headers[] = $objectivename . ' ' . get_string('score', 'scormreport_objectives'); } } } $emptycell = ''; // Used when an empty cell is being printed - in html we add a space. if (!$download) { $emptycell = ' '; $table = new \flexible_table('mod-scorm-report'); $table->define_columns($columns); $table->define_headers($headers); $table->define_baseurl($PAGE->url); $table->sortable(true); $table->collapsible(true); // This is done to prevent redundant data, when a user has multiple attempts. $table->column_suppress('picture'); $table->column_suppress('fullname'); foreach ($extrafields as $field) { $table->column_suppress($field); } foreach ($nosort as $field) { $table->no_sorting($field); } $table->no_sorting('start'); $table->no_sorting('finish'); $table->no_sorting('score'); $table->no_sorting('checkbox'); $table->no_sorting('picture'); foreach ($scoes as $sco) { if ($sco->launch != '') { $table->no_sorting('scograde' . $sco->id); } } $table->column_class('picture', 'picture'); $table->column_class('fullname', 'bold'); $table->column_class('score', 'bold'); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'attempts'); $table->set_attribute('class', 'generaltable generalbox'); // Start working -- this is necessary as soon as the niceties are over. $table->setup(); } else { if ($download == 'ODS') { require_once "{$CFG->libdir}/odslib.class.php"; $filename .= ".ods"; // Creating a workbook. $workbook = new \MoodleODSWorkbook("-"); // Sending HTTP headers. $workbook->send($filename); // Creating the first worksheet. $sheettitle = get_string('report', 'scorm'); $myxls = $workbook->add_worksheet($sheettitle); // Format types. $format = $workbook->add_format(); $format->set_bold(0); $formatbc = $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb = $workbook->add_format(); $formatb->set_bold(1); $formaty = $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc = $workbook->add_format(); $formatc->set_align('center'); $formatr = $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg = $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); // Here starts workshhet headers. $colnum = 0; foreach ($headers as $item) { $myxls->write(0, $colnum, $item, $formatbc); $colnum++; } $rownum = 1; } else { if ($download == 'Excel') { require_once "{$CFG->libdir}/excellib.class.php"; $filename .= ".xls"; // Creating a workbook. $workbook = new \MoodleExcelWorkbook("-"); // Sending HTTP headers. $workbook->send($filename); // Creating the first worksheet. $sheettitle = get_string('report', 'scorm'); $myxls = $workbook->add_worksheet($sheettitle); // Format types. $format = $workbook->add_format(); $format->set_bold(0); $formatbc = $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb = $workbook->add_format(); $formatb->set_bold(1); $formaty = $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc = $workbook->add_format(); $formatc->set_align('center'); $formatr = $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg = $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); $colnum = 0; foreach ($headers as $item) { $myxls->write(0, $colnum, $item, $formatbc); $colnum++; } $rownum = 1; } else { if ($download == 'CSV') { $csvexport = new \csv_export_writer("tab"); $csvexport->set_filename($filename, ".txt"); $csvexport->add_data($headers); } } } } if (!$download) { $sort = $table->get_sql_sort(); } else { $sort = ''; } // Fix some wired sorting. if (empty($sort)) { $sort = ' ORDER BY uniqueid'; } else { $sort = ' ORDER BY ' . $sort; } if (!$download) { // Add extra limits due to initials bar. list($twhere, $tparams) = $table->get_sql_where(); if ($twhere) { $where .= ' AND ' . $twhere; // Initial bar. $params = array_merge($params, $tparams); } if (!empty($countsql)) { $count = $DB->get_record_sql($countsql, $params); $totalinitials = $count->nbresults; if ($twhere) { $countsql .= ' AND ' . $twhere; } $count = $DB->get_record_sql($countsql, $params); $total = $count->nbresults; } $table->pagesize($pagesize, $total); echo \html_writer::start_div('scormattemptcounts'); if ($count->nbresults == $count->nbattempts) { echo get_string('reportcountattempts', 'scorm', $count); } else { if ($count->nbattempts > 0) { echo get_string('reportcountallattempts', 'scorm', $count); } else { echo $count->nbusers . ' ' . get_string('users'); } } echo \html_writer::end_div(); } // Fetch the attempts. if (!$download) { $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size()); echo \html_writer::start_div('', array('id' => 'scormtablecontainer')); if ($candelete) { // Start form. $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm')); echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post', 'action' => $PAGE->url->out(false), 'onsubmit' => 'return confirm("' . $strreallydel . '");')); echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete')); echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); echo \html_writer::start_div('', array('style' => 'display: none;')); echo \html_writer::input_hidden_params($PAGE->url); echo \html_writer::end_div(); echo \html_writer::start_div(); } $table->initialbars($totalinitials > 20); // Build table rows. } else { $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params); } if ($attempts) { foreach ($attempts as $scouser) { $row = array(); if (!empty($scouser->attempt)) { $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt); } else { $timetracks = ''; } if (in_array('checkbox', $columns)) { if ($candelete && !empty($timetracks->start)) { $row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false); } else { if ($candelete) { $row[] = ''; } } } if (in_array('picture', $columns)) { $user = new \stdClass(); $additionalfields = explode(',', \user_picture::fields()); $user = username_load_fields_from_object($user, $scouser, null, $additionalfields); $user->id = $scouser->userid; $row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id)); } if (!$download) { $url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id)); $row[] = \html_writer::link($url, fullname($scouser)); } else { $row[] = fullname($scouser); } foreach ($extrafields as $field) { $row[] = s($scouser->{$field}); } if (empty($timetracks->start)) { $row[] = '-'; $row[] = '-'; $row[] = '-'; $row[] = '-'; } else { if (!$download) { $url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt)); $row[] = \html_writer::link($url, $scouser->attempt); } else { $row[] = $scouser->attempt; } if ($download == 'ODS' || $download == 'Excel') { $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig")); } else { $row[] = userdate($timetracks->start); } if ($download == 'ODS' || $download == 'Excel') { $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig')); } else { $row[] = userdate($timetracks->finish); } $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt); } // Print out all scores of attempt. foreach ($scoes as $sco) { if ($sco->launch != '') { if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) { if ($trackdata->status == '') { $trackdata->status = 'notattempted'; } $strstatus = get_string($trackdata->status, 'scorm'); if ($trackdata->score_raw != '') { // If raw score exists, print it. $score = $trackdata->score_raw; // Add max score if it exists. if (isset($trackdata->score_max)) { $score .= '/' . $trackdata->score_max; } } else { // ...else print out status. $score = $strstatus; } if (!$download) { $url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id, 'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt)); $row[] = \html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus, array('title' => $strstatus)) . \html_writer::empty_tag('br') . \html_writer::link($url, $score, array('title' => get_string('details', 'scorm'))); } else { $row[] = $score; } // Iterate over tracks and match objective id against values. $scorm2004 = false; if (scorm_version_check($scorm->version, SCORM_13)) { $scorm2004 = true; $objectiveprefix = "cmi.objectives."; } else { $objectiveprefix = "cmi.objectives_"; } $keywords = array(".id", $objectiveprefix); $objectivestatus = array(); $objectivescore = array(); foreach ($trackdata as $name => $value) { if (strpos($name, $objectiveprefix) === 0 && strrpos($name, '.id') !== false) { $num = trim(str_ireplace($keywords, '', $name)); if (is_numeric($num)) { if ($scorm2004) { $element = $objectiveprefix . $num . '.completion_status'; } else { $element = $objectiveprefix . $num . '.status'; } if (isset($trackdata->{$element})) { $objectivestatus[$value] = $trackdata->{$element}; } else { $objectivestatus[$value] = ''; } if ($displayoptions['objectivescore']) { $element = $objectiveprefix . $num . '.score.raw'; if (isset($trackdata->{$element})) { $objectivescore[$value] = $trackdata->{$element}; } else { $objectivescore[$value] = ''; } } } } } // Interaction data. if (!empty($objectives[$trackdata->scoid])) { foreach ($objectives[$trackdata->scoid] as $name) { if (isset($objectivestatus[$name])) { $row[] = s($objectivestatus[$name]); } else { $row[] = $emptycell; } if ($displayoptions['objectivescore']) { if (isset($objectivescore[$name])) { $row[] = s($objectivescore[$name]); } else { $row[] = $emptycell; } } } } // End of interaction data. } else { // If we don't have track data, we haven't attempted yet. $strstatus = get_string('notattempted', 'scorm'); if (!$download) { $row[] = \html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus, array('title' => $strstatus)) . \html_writer::empty_tag('br') . $strstatus; } else { $row[] = $strstatus; } // Complete the empty cells. for ($i = 0; $i < count($columns) - $nbmaincolumns; $i++) { $row[] = $emptycell; } } } } if (!$download) { $table->add_data($row); } else { if ($download == 'Excel' or $download == 'ODS') { $colnum = 0; foreach ($row as $item) { $myxls->write($rownum, $colnum, $item, $format); $colnum++; } $rownum++; } else { if ($download == 'CSV') { $csvexport->add_data($row); } } } } if (!$download) { $table->finish_output(); if ($candelete) { echo \html_writer::start_tag('table', array('id' => 'commands')); echo \html_writer::start_tag('tr') . \html_writer::start_tag('td'); echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');', get_string('selectall', 'scorm')) . ' / '; echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');', get_string('selectnone', 'scorm')); echo ' '; echo \html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('deleteselected', 'scorm'), 'class' => 'btn btn-secondary')); echo \html_writer::end_tag('td') . \html_writer::end_tag('tr') . \html_writer::end_tag('table'); // Close form. echo \html_writer::end_tag('div'); echo \html_writer::end_tag('form'); } echo \html_writer::end_div(); if (!empty($attempts)) { echo \html_writer::start_tag('table', array('class' => 'boxaligncenter')) . \html_writer::start_tag('tr'); echo \html_writer::start_tag('td'); echo $OUTPUT->single_button(new \moodle_url($PAGE->url, array('download' => 'ODS') + $displayoptions), get_string('downloadods'), 'post', ['class' => 'm-t-1']); echo \html_writer::end_tag('td'); echo \html_writer::start_tag('td'); echo $OUTPUT->single_button(new \moodle_url($PAGE->url, array('download' => 'Excel') + $displayoptions), get_string('downloadexcel'), 'post', ['class' => 'm-t-1']); echo \html_writer::end_tag('td'); echo \html_writer::start_tag('td'); echo $OUTPUT->single_button(new \moodle_url($PAGE->url, array('download' => 'CSV') + $displayoptions), get_string('downloadtext'), 'post', ['class' => 'm-t-1']); echo \html_writer::end_tag('td'); echo \html_writer::start_tag('td'); echo \html_writer::end_tag('td'); echo \html_writer::end_tag('tr') . \html_writer::end_tag('table'); } } } else { if ($candelete && !$download) { echo \html_writer::end_div(); echo \html_writer::end_tag('form'); $table->finish_output(); } echo \html_writer::end_div(); } // Show preferences form irrespective of attempts are there to report or not. if (!$download) { $mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode')); $mform->display(); } if ($download == 'Excel' or $download == 'ODS') { $workbook->close(); exit; } else { if ($download == 'CSV') { $csvexport->download_file(); exit; } } } else { echo $OUTPUT->notification(get_string('noactivity', 'scorm')); } }
/** * Prints the table of questions in a category with interactions * * @param array $contexts Not used! * @param moodle_url $pageurl The URL to reload this page. * @param string $categoryandcontext 'categoryID,contextID'. * @param stdClass $cm Not used! * @param bool $recurse Whether to include subcategories. * @param int $page The number of the page to be displayed * @param int $perpage Number of questions to show per page * @param bool $showhidden whether deleted questions should be displayed. * @param bool $showquestiontext whether the text of each question should be shown in the list. Deprecated. * @param array $addcontexts contexts where the user is allowed to add new questions. */ protected function display_question_list($contexts, $pageurl, $categoryandcontext, $cm = null, $recurse = 1, $page = 0, $perpage = 100, $showhidden = false, $showquestiontext = false, $addcontexts = array()) { global $CFG, $DB, $OUTPUT; // This function can be moderately slow with large question counts and may time out. // We probably do not want to raise it to unlimited, so randomly picking 5 minutes. // Note: We do not call this in the loop because quiz ob_ captures this function (see raise() PHP doc). \core_php_time_limit::raise(300); $category = $this->get_current_category($categoryandcontext); $strselectall = get_string('selectall'); $strselectnone = get_string('deselectall'); list($categoryid, $contextid) = explode(',', $categoryandcontext); $catcontext = \context::instance_by_id($contextid); $canadd = has_capability('moodle/question:add', $catcontext); $this->create_new_question_form($category, $canadd); $this->build_query(); $totalnumber = $this->get_question_count(); if ($totalnumber == 0) { return; } $questions = $this->load_page_questions($page, $perpage); echo '<div class="categorypagingbarcontainer">'; $pageingurl = new \moodle_url('edit.php'); $r = $pageingurl->params($pageurl->params()); $pagingbar = new \paging_bar($totalnumber, $page, $perpage, $pageingurl); $pagingbar->pagevar = 'qpage'; echo $OUTPUT->render($pagingbar); echo '</div>'; echo '<form method="post" action="edit.php">'; echo '<fieldset class="invisiblefieldset" style="display: block;">'; echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; echo \html_writer::input_hidden_params($this->baseurl); echo '<div class="categoryquestionscontainer">'; $this->start_table(); $rowcount = 0; foreach ($questions as $question) { $this->print_table_row($question, $rowcount); $rowcount += 1; } $this->end_table(); echo "</div>\n"; echo '<div class="categorypagingbarcontainer pagingbottom">'; echo $OUTPUT->render($pagingbar); if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) { if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) { $url = new \moodle_url('edit.php', array_merge($pageurl->params(), array('qperpage' => MAXIMUM_QUESTIONS_PER_PAGE))); if ($totalnumber > MAXIMUM_QUESTIONS_PER_PAGE) { $showall = '<a href="' . $url . '">' . get_string('showperpage', 'moodle', MAXIMUM_QUESTIONS_PER_PAGE) . '</a>'; } else { $showall = '<a href="' . $url . '">' . get_string('showall', 'moodle', $totalnumber) . '</a>'; } } else { $url = new \moodle_url('edit.php', array_merge($pageurl->params(), array('qperpage' => DEFAULT_QUESTIONS_PER_PAGE))); $showall = '<a href="' . $url . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>'; } echo "<div class='paging'>{$showall}</div>"; } echo '</div>'; $this->display_bottom_controls($totalnumber, $recurse, $category, $catcontext, $addcontexts); echo '</fieldset>'; echo "</form>\n"; }
/** * Displays a table containing static data or form for subject reviews * * Displays a table, with a set of rows for each review. If $form is true, * the rows displayed are generated by each subject review plugin's add_form_rows * method. Otherwise, they are generated by the add_table_rows. * * If displaying the form, we also add the autosave javascript init call to the page, * along with any javascript provided by the plugins. * * @param array $reviews * @param bool $form * @param int $displayby A flag passed to the plugins, PROGRESSREVIEW_STUDENT if we're displaying all * subject reviews for a student, or PROGRESSREVIEW_SUBECJT if we're displaying all students' reviews * for a subject * @return string HTML for the table */ public function subject_review_table($reviews, $form = true, $displayby = PROGRESSREVIEW_STUDENT) { $output = ''; $table = new html_table(); $table->head = array('', '', get_string('attendance', 'local_progressreview'), get_string('punctuality', 'local_progressreview'), get_string('homework', 'local_progressreview'), get_string('behaviour', 'local_progressreview'), get_string('effort', 'local_progressreview')); if ($form) { $table->head[] = get_string('minimumgrade', 'local_progressreview'); } $table->head[] = get_string('targetgrade', 'local_progressreview'); $table->head[] = get_string('performancegrade', 'local_progressreview'); if (!$form && $displayby == PROGRESSREVIEW_SUBJECT) { $table->head[0] = get_string('course'); $table->head[1] = get_string('teacher', 'local_progressreview'); } $rows = array(); foreach ($reviews as $review) { $student = $review->get_student(); $session = $review->get_session(); $plugins = $review->get_plugins(); if ($form) { $idattrs = array('type' => 'hidden', 'id' => 'id_student_' . $review->id, 'value' => $student->id); $output .= html_writer::empty_tag('input', $idattrs); foreach ($plugins as $pluginnname => $plugin) { $newrows = $plugin->add_form_rows(); foreach ($newrows as $newrow) { if (get_class($newrow) != 'html_table_row') { throw new coding_exception('add_form_rows must return an array of html_table_row objects. The ' . $pluginname . ' plugin didn\'t do this.'); } } $rows = array_merge($rows, $newrows); } } else { foreach ($plugins as $pluginname => $plugin) { $newrows = $plugin->add_table_rows($displayby); foreach ($newrows as $newrow) { if (get_class($newrow) != 'html_table_row') { throw new coding_exception('add_table_rows must return an array of html_table_row objects. The ' . $pluginname . ' plugin didn\'t do this.'); } } $rows = array_merge($rows, $newrows); } } } $table->data = $rows; $params = array('action' => $this->page->url->out_omit_querystring(), 'method' => 'post'); if ($form) { $output .= html_writer::start_tag('form', $params); $output .= html_writer::input_hidden_params($this->page->url); $hiddens = array('sessionid' => $review->get_session()->id, 'courseid' => $review->get_course()->originalid, 'teacherid' => $review->get_teacher()->originalid, 'reviewtype' => $review->get_type(), 'editid' => ''); $hiddenparams = array('type' => 'hidden'); foreach ($hiddens as $name => $value) { $hiddenparams['name'] = $name; $hiddenparams['id'] = 'id_' . $name; $hiddenparams['value'] = $value; $output .= html_writer::empty_tag('input', $hiddenparams); } $strsave = get_string('savechanges'); $output .= html_writer::empty_tag('input', array('id' => 'id_save', 'name' => 'submit', 'type' => 'submit', 'value' => $strsave)); $jsmodule = array('name' => 'local_progressreview', 'fullpath' => '/local/progressreview/module.js', 'requires' => array('base', 'node', 'io', 'io-queue', 'json', 'event-valuechange', 'event-delegate'), 'strings' => array(array('autosaveactive', 'local_progressreview'), array('autosavefailed', 'local_progressreview'), array('autosaving', 'local_progressreview'))); $this->page->requires->js_init_call('M.local_progressreview.init_autosave', array($strsave), false, $jsmodule); foreach ($review->get_plugins() as $plugin) { $modulename = 'M.progressreview_' . $plugin->get_name(); $this->page->requires->js_init_call($modulename . '.init_autosave'); } $output .= $this->progress_indicator(); $output .= $this->error_indicator(); } $output .= html_writer::table($table); if ($form) { html_writer::end_tag('form'); } return $output; }
public function render_opendesktop_overview(opendesktop_overview $data) { global $USER, $OUTPUT, $PAGE, $CFG; $o = ''; //start own opendesktop $formattributes = array('id' => 'opendesktop_sessionlogin', 'class' => 'opendesktopconnect', 'action' => $PAGE->url, 'method' => 'post', 'name' => 'launchopendesktop'); $formcontent = html_writer::input_hidden_params($data->params['ovdstartlink']['url']); $formcontent .= html_writer::select(array('desktopplus' => 'OpenDesktop + Video/Audio', 'portal' => 'Portal (Nur zum Dateiupload)', 'desktop' => 'OpenDesktop ohne Audio/Video'), 'sessionmode', 'desktopplus'); $formcontent .= html_writer::start_tag('div', array('id' => 'loading_div')); $formcontent .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('loading', 'opendesktop'), 'alt' => 'Loading...', 'title' => 'Loading...', 'height' => '25', 'width' => '25')); $formcontent .= html_writer::end_tag('div'); $formcontent .= html_writer::start_tag('div', array('class' => 'fail_buttons')); $formcontent .= html_writer::empty_tag('input', array('type' => 'button', 'id' => 'failed_button', 'value' => 'ERROR')); $formcontent .= html_writer::start_tag('span', array('id' => 'java_download')); $formcontent .= html_writer::tag('a', 'Click here to install the free Java-Plugin', array('href' => 'http://www.java.com/download/', 'class' => 'failed', 'target' => '_blank')); $formcontent .= html_writer::end_tag('span'); $formcontent .= html_writer::end_tag('div'); $formcontent .= html_writer::empty_tag('input', array('type' => 'hidden', 'id' => 'timezone', 'class' => 'timezone', 'value' => "")); $formcontent .= html_writer::empty_tag('input', array('type' => 'submit', 'id' => 'launch_button', 'class' => 'launch_button', 'value' => get_string($data->params['ovdstartlink']['buttonmessage'], 'opendesktop'))); $form = html_writer::tag('form', $formcontent, $formattributes); $starthtml = html_writer::tag('h2', get_string('logintoyourdesktop', 'opendesktop')); $starthtml .= $data->params['ovdstartlink']['message']; $starthtml .= $form; $o .= $OUTPUT->box($starthtml); //login to opendesktops of other users $joinhtml = html_writer::tag('h2', get_string('desktopstojoin', 'opendesktop')); if (empty($data->params['availabledesktops'])) { $joinhtml .= html_writer::tag('div', get_string('nosession', 'opendesktop')); $o .= $OUTPUT->box($joinhtml); return $o; } foreach ($data->params['availabledesktops'] as $username => $desktop) { $joinhtml .= html_writer::start_tag('div'); $joinhtml .= html_writer::tag('h3', get_string('joindesktop', 'opendesktop') . ' ' . $desktop['fullname']); if (array_key_exists('active', $desktop)) { $joinhtml .= html_writer::tag('a', get_string('joinactive', 'opendesktop'), array('href' => $desktop['active'], 'class' => 'opendesktop_join')); } if (array_key_exists('passive', $desktop)) { $joinhtml .= html_writer::tag('a', get_string('joinviewonly', 'opendesktop'), array('href' => $desktop['passive'], 'class' => 'opendesktop_join')); } $joinhtml .= html_writer::end_tag('div'); } $data->params['availabledesktops']; $o .= $OUTPUT->box($joinhtml); return $o; }
/** * 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'); } }
protected function render_attendance_preferences_data(attendance_preferences_data $prefdata) { $this->page->requires->js('/mod/attendance/module.js'); $table = new html_table(); $table->width = '100%'; $table->head = array('#', get_string('acronym', 'attendance'), get_string('description'), get_string('grade'), get_string('action')); $table->align = array('center', 'center', 'center', 'center', 'center', 'center'); $i = 1; foreach ($prefdata->statuses as $st) { $table->data[$i][] = $i; $table->data[$i][] = $this->construct_text_input('acronym[' . $st->id . ']', 2, 2, $st->acronym); $table->data[$i][] = $this->construct_text_input('description[' . $st->id . ']', 30, 30, $st->description); $table->data[$i][] = $this->construct_text_input('grade[' . $st->id . ']', 4, 4, format_float($st->grade)); $table->data[$i][] = $this->construct_preferences_actions_icons($st, $prefdata); $i++; } $table->data[$i][] = '*'; $table->data[$i][] = $this->construct_text_input('newacronym', 2, 2); $table->data[$i][] = $this->construct_text_input('newdescription', 30, 30); $table->data[$i][] = $this->construct_text_input('newgrade', 4, 4); $table->data[$i][] = $this->construct_preferences_button(get_string('add', 'attendance'), att_preferences_page_params::ACTION_ADD); $o = html_writer::tag('h1', get_string('myvariables', 'attendance')); $o .= html_writer::table($table); $o .= html_writer::input_hidden_params($prefdata->url(array(), false)); $o .= $this->construct_preferences_button(get_string('update', 'attendance'), att_preferences_page_params::ACTION_SAVE); $o = html_writer::tag('form', $o, array('id' => 'preferencesform', 'method' => 'post', 'action' => $prefdata->url(array(), false)->out_omit_querystring())); $o = $this->output->container($o, 'generalbox attwidth'); return $o; }
redirect($url); } // Display $PAGE->set_title(format_string($opencast->name)); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); $renderer = $PAGE->get_renderer('mod_opencast'); echo html_writer::tag('h2', get_string('set_clip_details', 'opencast')); echo html_writer::tag('p', get_string('set_clip_details_warning', 'opencast'), ['class' => 'notify']); echo html_writer::start_tag('table', ['class' => 'opencast-clips']); $renderer->display_singleclip_table_header(false, true, $opencast->userupload, false); $renderer->display_clip_outline($sc_clip, false, false, null, true, $opencast->userupload, false, false); echo html_writer::end_tag('table'); if (has_capability('mod/opencast:isproducer', $context)) { echo html_writer::start_tag('form', ['method' => 'post', 'action' => 'event_editdetails.php', 'class' => 'details border']); echo html_writer::input_hidden_params($url, ['action', 'userid']); echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()]); echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'action', 'value' => 'edit']); echo html_writer::start_div(); echo html_writer::tag('span', get_string('title', 'opencast')); echo html_writer::empty_tag('input', ['type' => 'text', 'name' => 'title', 'value' => $sc_clip->getTitle()]); echo html_writer::end_div(); echo html_writer::start_div(); echo html_writer::tag('span', get_string('subtitle', 'opencast')); echo html_writer::empty_tag('input', ['type' => 'text', 'name' => 'subtitle', 'value' => $sc_clip->getSubtitle()]); echo html_writer::end_div(); echo html_writer::start_div(); echo html_writer::tag('span', get_string('presenter', 'opencast')); echo html_writer::empty_tag('input', ['type' => 'text', 'name' => 'presenter', 'value' => $sc_clip->getPresenter()]); echo html_writer::end_div(); echo html_writer::start_div();
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; }
/** * wrap_html_start */ function wrap_html_start() { // check this table has a "selected" column if (!$this->has_column('selected')) { return false; } // check user can delete attempts if (!$this->output->hotpot->can_deleteattempts()) { return false; } // start form $url = $this->output->hotpot->report_url($this->output->mode); $params = array('id' => 'attemptsform', 'method' => 'post', 'action' => $url->out_omit_querystring()); echo html_writer::start_tag('form', $params); // create hidden fields $params = array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()); $hidden_fields = html_writer::input_hidden_params($url) . html_writer::empty_tag('input', $params) . "\n"; // put hidden fields in a containiner (for strict XHTML compatability) $params = array('style' => 'display: none;'); echo html_writer::tag('div', $hidden_fields, $params); }
$outputhtml .= html_writer::end_tag('div'); } $visiblepathtosection = array_reverse($settingspage->visiblepath); $PAGE->set_title("{$SITE->shortname}: " . implode(": ", $visiblepathtosection)); $PAGE->set_heading($SITE->fullname); $PAGE->set_button($buttons); echo $OUTPUT->header(); if ($errormsg !== '') { echo $OUTPUT->notification($errormsg); } else { if ($statusmsg !== '') { echo $OUTPUT->notification($statusmsg, 'notifysuccess'); } } $path = array_reverse($settingspage->visiblepath); if (is_array($path)) { $visiblename = join(' / ', $path); } else { $visiblename = $path; } echo $OUTPUT->heading(get_string('admincategory', 'admin', $visiblename), 2); echo html_writer::start_tag('form', array('action' => '', 'method' => 'post', 'id' => 'adminsettings')); echo html_writer::start_tag('div'); echo html_writer::input_hidden_params(new moodle_url($PAGE->url, array('sesskey' => sesskey(), 'return' => $return))); echo html_writer::end_tag('div'); echo html_writer::start_tag('fieldset'); echo html_writer::tag('div', '<!-- -->', array('class' => 'clearer')); echo $outputhtml; echo html_writer::end_tag('fieldset'); echo html_writer::end_tag('form'); echo $OUTPUT->footer();
public function wrap_html_start() { if ($this->is_downloading() || !$this->includecheckboxes) { return; } $url = $this->options->get_url(); $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>'; }
public function to_html($format = null, $addstr = null) { global $CFG, $COURSE, $OUTPUT, $USER; if (!$this->is_renderable()) { return; } if (empty($this->callbackclass) || empty($this->callbackfile)) { throw new portfolio_button_exception('mustsetcallbackoptions', 'portfolio'); } if (empty($this->formats)) { // use the caller defaults $this->set_formats(); } $url = new moodle_url('/portfolio/add.php'); foreach ($this->callbackargs as $key => $value) { if (!empty($value) && !is_string($value) && !is_numeric($value)) { $a = new stdClass(); $a->key = $key; $a->value = print_r($value, true); debugging(get_string('nonprimative', 'portfolio', $a)); return; } $url->param('ca_' . $key, $value); } $url->param('sesskey', sesskey()); $url->param('callbackfile', $this->callbackfile); $url->param('callbackclass', $this->callbackclass); $url->param('course', !empty($COURSE) ? $COURSE->id : 0); $url->param('callerformats', implode(',', $this->formats)); $mimetype = null; if ($this->file instanceof stored_file) { $mimetype = $this->file->get_mimetype(); } else { if ($this->intendedmimetype) { $mimetype = $this->intendedmimetype; } } $selectoutput = ''; if (count($this->instances) == 1) { $tmp = array_values($this->instances); $instance = $tmp[0]; $formats = portfolio_supported_formats_intersect($this->formats, $instance->supported_formats()); if (count($formats) == 0) { // bail. no common formats. //debugging(get_string('nocommonformats', 'portfolio', (object)array('location' => $this->callbackclass, 'formats' => implode(',', $this->formats)))); return; } if ($error = portfolio_instance_sanity_check($instance)) { // bail, plugin is misconfigured //debugging(get_string('instancemisconfigured', 'portfolio', get_string($error[$instance->get('id')], 'portfolio_' . $instance->get('plugin')))); return; } if (!$instance->allows_multiple_exports() && ($already = portfolio_existing_exports($USER->id, $instance->get('plugin')))) { //debugging(get_string('singleinstancenomultiallowed', 'portfolio')); return; } if ($mimetype && !$instance->file_mime_check($mimetype)) { // bail, we have a specific file or mimetype and this plugin doesn't support it //debugging(get_string('mimecheckfail', 'portfolio', (object)array('plugin' => $instance->get('plugin'), 'mimetype' => $mimetype))); return; } $url->param('instance', $instance->get('id')); } else { if (!($selectoutput = portfolio_instance_select($this->instances, $this->formats, $this->callbackclass, $mimetype, 'instance', true))) { return; } } // if we just want a url to redirect to, do it now if ($format == PORTFOLIO_ADD_FAKE_URL) { return $url->out(false); } if (empty($addstr)) { $addstr = get_string('addtoportfolio', 'portfolio'); } if (empty($format)) { $format = PORTFOLIO_ADD_FULL_FORM; } $formoutput = '<form method="post" action="' . $CFG->wwwroot . '/portfolio/add.php" id="portfolio-add-button">' . "\n"; $formoutput .= html_writer::input_hidden_params($url); $linkoutput = '<a class="portfolio-add-link" title="' . $addstr . '" href="' . $url->out(); switch ($format) { case PORTFOLIO_ADD_FULL_FORM: $formoutput .= $selectoutput; $formoutput .= "\n" . '<input type="submit" value="' . $addstr . '" />'; $formoutput .= "\n" . '</form>'; break; case PORTFOLIO_ADD_ICON_FORM: $formoutput .= $selectoutput; $formoutput .= "\n" . '<input class="portfolio-add-icon" type="image" src="' . $OUTPUT->pix_url('t/portfolioadd') . '" alt=' . $addstr . '" />'; $formoutput .= "\n" . '</form>'; break; case PORTFOLIO_ADD_ICON_LINK: $linkoutput .= '"><img class="portfolio-add-icon" src="' . $OUTPUT->pix_url('t/portfolioadd') . '" alt="' . $addstr . '" /></a>'; break; case PORTFOLIO_ADD_TEXT_LINK: $linkoutput .= '">' . $addstr . '</a>'; break; default: debugging(get_string('invalidaddformat', 'portfolio', $format)); } $output = in_array($format, array(PORTFOLIO_ADD_FULL_FORM, PORTFOLIO_ADD_ICON_FORM)) ? $formoutput : $linkoutput; return $output; }
/** * Displays a user selector * * @param bool $withproducers shall the producers be included ? * @param string $action_url where the form shall be posted * @param string $buttonlabel value attribute of the submit button * @param bool $switchaaionly display users with ExternalAccount only * @param bool $with_emtpyoption display 'remove user' option or not * @param bool $selectonly display HTML SELECT element only * @param int $selected_id if not zero, select OPTION with this index */ function display_user_selector($withproducers = false, $action_url = '', $buttonlabel = 'OK', $switchaaionly = false, $with_emtpyoption = false, $selectonly = false, $selected_id = 0) { global $context, $url, $course; if ($withproducers === false) { $producers = get_users_by_capability($context, 'mod/opencast:isproducer', 'u.id'); } $possible_users = get_users_by_capability($context, 'mod/opencast:use', 'u.id, u.lastname, u.firstname, u.maildisplay, u.email', 'u.lastname, u.firstname'); $options = []; if ($with_emtpyoption) { $options[-1] = '(' . get_string('removeowner', 'opencast') . ')'; } foreach ($possible_users as $possible_user_id => $possible_user) { if (in_array($possible_user_id, $this->displayed_userids)) { continue; } if ($withproducers === false && array_key_exists($possible_user_id, $producers)) { continue; } if ($switchaaionly && !mod_opencast_user::getExtIdFromMoodleUserId($possible_user_id)) { continue; } $option_text = $possible_user->lastname . ', ' . $possible_user->firstname; if ($possible_user->maildisplay == 1 or $possible_user->maildisplay == 2 and $course->id != SITEID and !isguestuser() or has_capability('moodle/course:viewhiddenuserfields', $context)) { $option_text .= ' (' . $possible_user->email . ')'; } $options[$possible_user_id] = $option_text; } if (count($options)) { if (!$selectonly) { echo html_writer::start_tag('form', ['method' => 'post', 'action' => $action_url, 'onsubmit' => 'return document.getElementById(\'menuuserid\').selectedIndex != 0;']); echo html_writer::input_hidden_params($url, ['action', 'userid']); echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()]); echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'action', 'value' => 'add']); } echo html_writer::select($options, 'userid', $selected_id); if (!$selectonly) { echo html_writer::empty_tag('input', ['type' => 'submit', 'value' => $buttonlabel]); echo html_writer::end_tag('form'); } } else { if (!$selectonly) { echo html_writer::start_tag('form'); } echo html_writer::select($options, 'userid', null, null, ['disabled' => 'disabled']); if (!$selectonly) { echo html_writer::empty_tag('input', ['type' => 'submit', 'value' => $buttonlabel, 'disabled' => 'disabled']); echo html_writer::tag('div', get_string('nomoreusers', 'opencast')); echo html_writer::end_tag('form'); } } }
/** * displays the full report * @param stdClass $scorm full SCORM object * @param stdClass $cm - full course_module object * @param stdClass $course - full course object * @param string $download - type of download being requested */ function display($scorm, $cm, $course, $download) { global $CFG, $DB, $OUTPUT, $PAGE; $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id); $action = optional_param('action', '', PARAM_ALPHA); $attemptids = optional_param_array('attemptid', array(), PARAM_RAW); $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT); $PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode))); if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) { if (scorm_delete_responses($attemptids, $scorm)) { //delete responses. add_to_log($course->id, 'scorm', 'delete attempts', 'report.php?id=' . $cm->id, implode(",", $attemptids), $cm->id); echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess'); } } // find out current groups mode $currentgroup = groups_get_activity_group($cm, true); // detailed report $mform = new mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup')); if ($fromform = $mform->get_data()) { $pagesize = $fromform->pagesize; $includeqtext = $fromform->qtext; $includeresp = $fromform->resp; $includeright = $fromform->right; set_user_preference('scorm_report_pagesize', $pagesize); set_user_preference('scorm_report_interactions_qtext', $includeqtext); set_user_preference('scorm_report_interactions_resp', $includeresp); set_user_preference('scorm_report_interactions_right', $includeright); } else { $pagesize = get_user_preferences('scorm_report_pagesize', 0); $includeqtext = get_user_preferences('scorm_report_interactions_qtext', 0); $includeresp = get_user_preferences('scorm_report_interactions_resp', 1); $includeright = get_user_preferences('scorm_report_interactions_right', 0); } if ($pagesize < 1) { $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE; } // select group menu $displayoptions = array(); $displayoptions['attemptsmode'] = $attemptsmode; $displayoptions['qtext'] = $includeqtext; $displayoptions['resp'] = $includeresp; $displayoptions['right'] = $includeright; $mform->set_data($displayoptions + array('pagesize' => $pagesize)); if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if (!$download) { groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions)); } } $formattextoptions = array('context' => get_context_instance(CONTEXT_COURSE, $course->id)); // 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/scorm:deleteresponses', $contextmodule) && ($attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO); // select the students $nostudents = false; if (empty($currentgroup)) { // all users who can attempt scoes if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', '', '', false)) { echo $OUTPUT->notification(get_string('nostudentsyet')); $nostudents = true; $allowedlist = ''; } else { $allowedlist = array_keys($students); } } else { // all users who can attempt scoes and who are in the currently selected group if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', $currentgroup, '', false)) { echo $OUTPUT->notification(get_string('nostudentsingroup')); $nostudents = true; $groupstudents = array(); } $allowedlist = array_keys($groupstudents); } if ( !$nostudents ) { // Now check if asked download of data $coursecontext = context_course::instance($course->id); if ($download) { $filename = clean_filename("$course->shortname ".format_string($scorm->name, true,$formattextoptions)); } // Define table columns $columns = array(); $headers = array(); if (!$download && $candelete) { $columns[] = 'checkbox'; $headers[] = null; } if (!$download && $CFG->grade_report_showuserimage) { $columns[] = 'picture'; $headers[] = ''; } $columns[] = 'fullname'; $headers[] = get_string('name'); $extrafields = get_extra_user_fields($coursecontext); foreach ($extrafields as $field) { $columns[] = $field; $headers[] = get_user_field_name($field); } $columns[] = 'attempt'; $headers[] = get_string('attempt', 'scorm'); $columns[] = 'start'; $headers[] = get_string('started', 'scorm'); $columns[] = 'finish'; $headers[] = get_string('last', 'scorm'); $columns[] = 'score'; $headers[] = get_string('score', 'scorm'); $scoes = $DB->get_records('scorm_scoes', array("scorm"=>$scorm->id), 'id'); foreach ($scoes as $sco) { if ($sco->launch != '') { $columns[] = 'scograde'.$sco->id; $headers[] = format_string($sco->title,'',$formattextoptions); } } $params = array(); list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED); // Construct the SQL $select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, '; $select .= 'st.scormid AS scormid, st.attempt AS attempt, ' . 'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email'. get_extra_user_fields_sql($coursecontext, 'u', '', array('idnumber')) . ' '; // This part is the same for all cases - join users and scorm_scoes_track tables $from = 'FROM {user} u '; $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id; switch ($attemptsmode) { case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH: // Show only students with attempts $where = ' WHERE u.id ' .$usql. ' AND st.userid IS NOT NULL'; break; case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO: // Show only students without attempts $where = ' WHERE u.id ' .$usql. ' AND st.userid IS NULL'; break; case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS: // Show all students with or without attempts $where = ' WHERE u.id ' .$usql. ' AND (st.userid IS NOT NULL OR st.userid IS NULL)'; break; } $countsql = 'SELECT COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').')) AS nbresults, '; $countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, '; $countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers '; $countsql .= $from.$where; $attempts = $DB->get_records_sql($select.$from.$where, $params); $questioncount = get_scorm_question_count($scorm->id); for($id = 0; $id < $questioncount; $id++) { if ($displayoptions['qtext']) { $columns[] = 'question' . $id; $headers[] = get_string('questionx', 'scormreport_interactions', $id); } if ($displayoptions['resp']) { $columns[] = 'response' . $id; $headers[] = get_string('responsex', 'scormreport_interactions', $id); } if ($displayoptions['right']) { $columns[] = 'right' . $id; $headers[] = get_string('rightanswerx', 'scormreport_interactions', $id); } } if (!$download) { $table = new flexible_table('mod-scorm-report'); $table->define_columns($columns); $table->define_headers($headers); $table->define_baseurl($PAGE->url); $table->sortable(true); $table->collapsible(true); // This is done to prevent redundant data, when a user has multiple attempts $table->column_suppress('picture'); $table->column_suppress('fullname'); foreach ($extrafields as $field) { $table->column_suppress($field); } $table->no_sorting('start'); $table->no_sorting('finish'); $table->no_sorting('score'); foreach ($scoes as $sco) { if ($sco->launch != '') { $table->no_sorting('scograde'.$sco->id); } } $table->column_class('picture', 'picture'); $table->column_class('fullname', 'bold'); $table->column_class('score', 'bold'); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'attempts'); $table->set_attribute('class', 'generaltable generalbox'); // Start working -- this is necessary as soon as the niceties are over $table->setup(); } else if ($download == 'ODS') { require_once("$CFG->libdir/odslib.class.php"); $filename .= ".ods"; // Creating a workbook $workbook = new MoodleODSWorkbook("-"); // Sending HTTP headers $workbook->send($filename); // Creating the first worksheet $sheettitle = get_string('report', 'scorm'); $myxls =& $workbook->add_worksheet($sheettitle); // format types $format =& $workbook->add_format(); $format->set_bold(0); $formatbc =& $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb =& $workbook->add_format(); $formatb->set_bold(1); $formaty =& $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc =& $workbook->add_format(); $formatc->set_align('center'); $formatr =& $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg =& $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); // Here starts workshhet headers $colnum = 0; foreach ($headers as $item) { $myxls->write(0, $colnum, $item, $formatbc); $colnum++; } $rownum = 1; } else if ($download =='Excel') { require_once("$CFG->libdir/excellib.class.php"); $filename .= ".xls"; // Creating a workbook $workbook = new MoodleExcelWorkbook("-"); // Sending HTTP headers $workbook->send($filename); // Creating the first worksheet $sheettitle = get_string('report', 'scorm'); $myxls =& $workbook->add_worksheet($sheettitle); // format types $format =& $workbook->add_format(); $format->set_bold(0); $formatbc =& $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb =& $workbook->add_format(); $formatb->set_bold(1); $formaty =& $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc =& $workbook->add_format(); $formatc->set_align('center'); $formatr =& $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg =& $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); $colnum = 0; foreach ($headers as $item) { $myxls->write(0, $colnum, $item, $formatbc); $colnum++; } $rownum = 1; } else if ($download == 'CSV') { $filename .= ".txt"; header("Content-Type: application/download\n"); header("Content-Disposition: attachment; filename=\"$filename\""); header("Expires: 0"); header("Cache-Control: must-revalidate,post-check=0,pre-check=0"); header("Pragma: public"); echo implode("\t", $headers)." \n"; } if (!$download) { $sort = $table->get_sql_sort(); } else { $sort = ''; } // Fix some wired sorting if (empty($sort)) { $sort = ' ORDER BY uniqueid'; } else { $sort = ' ORDER BY '.$sort; } if (!$download) { // Add extra limits due to initials bar list($twhere, $tparams) = $table->get_sql_where(); if ($twhere) { $where .= ' AND '.$twhere; //initial bar $params = array_merge($params, $tparams); } if (!empty($countsql)) { $count = $DB->get_record_sql($countsql,$params); $totalinitials = $count->nbresults; if ($twhere) { $countsql .= ' AND '.$twhere; } $count = $DB->get_record_sql($countsql, $params); $total = $count->nbresults; } $table->pagesize($pagesize, $total); echo '<div class="quizattemptcounts">'; if ( $count->nbresults == $count->nbattempts ) { echo get_string('reportcountattempts', 'scorm', $count); } else if ( $count->nbattempts>0 ) { echo get_string('reportcountallattempts', 'scorm', $count); } else { echo $count->nbusers.' '.get_string('users'); } echo '</div>'; } // Fetch the attempts if (!$download) { $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params, $table->get_page_start(), $table->get_page_size()); echo '<div id="scormtablecontainer">'; if ($candelete) { // Start form $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm')); echo '<form id="attemptsform" method="post" action="' . $PAGE->url->out(false) . '" onsubmit="return confirm(\''.$strreallydel.'\');">'; echo '<input type="hidden" name="action" value="delete"/>'; echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; echo '<div style="display: none;">'; echo html_writer::input_hidden_params($PAGE->url); echo '</div>'; echo '<div>'; } $table->initialbars($totalinitials>20); // Build table rows } else { $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params); } if ($attempts) { foreach ($attempts as $scouser) { $row = array(); if (!empty($scouser->attempt)) { $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt); } else { $timetracks = ''; } if (in_array('checkbox', $columns)) { if ($candelete && !empty($timetracks->start)) { $row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid . ':' . $scouser->attempt . '" />'; } else if ($candelete) { $row[] = ''; } } if (in_array('picture', $columns)) { $user = (object)array( 'id'=>$scouser->userid, 'picture'=>$scouser->picture, 'imagealt'=>$scouser->imagealt, 'email'=>$scouser->email, 'firstname'=>$scouser->firstname, 'lastname'=>$scouser->lastname); $row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id)); } if (!$download) { $row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&course='.$course->id.'">'.fullname($scouser).'</a>'; } else { $row[] = fullname($scouser); } foreach ($extrafields as $field) { $row[] = s($scouser->{$field}); } if (empty($timetracks->start)) { $row[] = '-'; $row[] = '-'; $row[] = '-'; $row[] = '-'; } else { if (!$download) { $row[] = '<a href="userreport.php?a='.$scorm->id.'&user='******'&attempt='.$scouser->attempt.'">'.$scouser->attempt.'</a>'; } else { $row[] = $scouser->attempt; } if ($download =='ODS' || $download =='Excel' ) { $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig")); } else { $row[] = userdate($timetracks->start); } if ($download =='ODS' || $download =='Excel' ) { $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig')); } else { $row[] = userdate($timetracks->finish); } $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt); } // print out all scores of attempt foreach ($scoes as $sco) { if ($sco->launch != '') { if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) { if ($trackdata->status == '') { $trackdata->status = 'notattempted'; } $strstatus = get_string($trackdata->status, 'scorm'); // if raw score exists, print it if ($trackdata->score_raw != '') { $score = $trackdata->score_raw; // add max score if it exists if ($scorm->version == 'SCORM_1.3') { $maxkey = 'cmi.score.max'; } else { $maxkey = 'cmi.core.score.max'; } if (isset($trackdata->$maxkey)) { $score .= '/'.$trackdata->$maxkey; } // else print out status } else { $score = $strstatus; } if (!$download) { $row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/> <a href="userreport.php?b='.$sco->id.'&user='******'&attempt='.$scouser->attempt. '" title="'.get_string('details', 'scorm').'">'.$score.'</a>'; } else { $row[] = $score; } // interaction data $i=0; $element='cmi.interactions_'.$i.'.id'; while(isset($trackdata->$element)) { if ($displayoptions['qtext']) { $element='cmi.interactions_'.$i.'.id'; if (isset($trackdata->$element)) { $row[] = s($trackdata->$element); } else { $row[] = ' '; } } if ($displayoptions['resp']) { $element='cmi.interactions_'.$i.'.student_response'; if (isset($trackdata->$element)) { $row[] = s($trackdata->$element); } else { $row[] = ' '; } } if ($displayoptions['right']) { $j=0; $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern'; $rightans = ''; if (isset($trackdata->$element)) { while(isset($trackdata->$element)) { if($j>0) { $rightans .= ','; } $rightans .= s($trackdata->$element); $j++; $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern'; } $row[] = $rightans; } else { $row[] = ' '; } } $i++; $element = 'cmi.interactions_'.$i.'.id'; } //---end of interaction data*/ } else { // if we don't have track data, we haven't attempted yet $strstatus = get_string('notattempted', 'scorm'); if (!$download) { $row[] = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>'.$strstatus; } else { $row[] = $strstatus; } } } } if (!$download) { $table->add_data($row); } else if ($download == 'Excel' or $download == 'ODS') { $colnum = 0; foreach ($row as $item) { $myxls->write($rownum, $colnum, $item, $format); $colnum++; } $rownum++; } else if ($download == 'CSV') { $text = implode("\t", $row); echo $text." \n"; } } if (!$download) { $table->finish_output(); if ($candelete) { echo '<table id="commands">'; echo '<tr><td>'; echo '<a href="javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');">'. get_string('selectall', 'scorm').'</a> / '; echo '<a href="javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');">'. get_string('selectnone', 'scorm').'</a> '; echo ' '; echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>'; echo '</td></tr></table>'; // Close form echo '</div>'; echo '</form>'; } echo '</div>'; if (!empty($attempts)) { echo '<table class="boxaligncenter"><tr>'; echo '<td>'; echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('download'=>'ODS') + $displayoptions), get_string('downloadods')); echo "</td>\n"; echo '<td>'; echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('download'=>'Excel') + $displayoptions), get_string('downloadexcel')); echo "</td>\n"; echo '<td>'; echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('download'=>'CSV') + $displayoptions), get_string('downloadtext')); echo "</td>\n"; echo "<td>"; echo "</td>\n"; echo '</tr></table>'; } } } else { if ($candelete && !$download) { echo '</div>'; echo '</form>'; $table->finish_output(); } echo '</div>'; } // Show preferences form irrespective of attempts are there to report or not if (!$download) { $mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode')); $mform->display(); } if ($download == 'Excel' or $download == 'ODS') { $workbook->close(); exit; } else if ($download == 'CSV') { exit; } } else { echo $OUTPUT->notification(get_string('noactivity', 'scorm')); } }// function ends
/** * 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; }
/** * Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless * * @staticvar int $formcounter counts number of forms * @param string $formName Form's name. * @param string $method Form's method defaults to 'POST' * @param string|moodle_url $action Form's action * @param string $target (optional)Form's target defaults to none * @param mixed $attributes (optional)Extra attributes for <form> tag */ function MoodleQuickForm($formName, $method, $action, $target = '', $attributes = null) { global $CFG, $OUTPUT; static $formcounter = 1; HTML_Common::HTML_Common($attributes); $target = empty($target) ? array() : array('target' => $target); $this->_formName = $formName; if (is_a($action, 'moodle_url')) { $this->_pageparams = html_writer::input_hidden_params($action); $action = $action->out_omit_querystring(); } else { $this->_pageparams = ''; } // No 'name' atttribute for form in xhtml strict : $attributes = array('action' => $action, 'method' => $method, 'accept-charset' => 'utf-8') + $target; if (is_null($this->getAttribute('id'))) { $attributes['id'] = 'mform' . $formcounter; } $formcounter++; $this->updateAttributes($attributes); // This is custom stuff for Moodle : $oldclass = $this->getAttribute('class'); if (!empty($oldclass)) { $this->updateAttributes(array('class' => $oldclass . ' mform')); } else { $this->updateAttributes(array('class' => 'mform')); } $this->_reqHTML = '<img class="req" title="' . get_string('requiredelement', 'form') . '" alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />'; $this->_advancedHTML = '<img class="adv" title="' . get_string('advancedelement', 'form') . '" alt="' . get_string('advancedelement', 'form') . '" src="' . $OUTPUT->pix_url('adv') . '" />'; $this->setRequiredNote(get_string('somefieldsrequired', 'form', '<img alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />')); }
$line[2] = " "; $line[3] = " "; $data[] = $line; } if (groups_is_member($groupid[0], $USER->id) or has_capability('moodle/site:accessallgroups', $context)) { if (groups_is_leader($groupid[0], $USER->id) or has_capability('moodle/site:accessallgroups', $context)) { $table = new html_table(); $table->id = "table_request"; $table->head = array($strstudent, $stremailstudent, $strdescription); $table->size = array('30%', '20%', '20%', '5%'); $table->align = array('left', 'left', 'center'); $table->width = '90%'; $table->data = $data; echo html_writer::table($table); echo html_writer::div(get_string('deleterequest', 'group'), '', array('id' => 'dialog_delete_request', 'style' => 'display:none')); echo html_writer::input_hidden_params(new moodle_url($PAGE->url, array('sesskey' => sesskey(), 'courseid' => $courseid, 'groupid' => $groupid[0]))); } else { echo html_writer::div(get_string('groupnotaleader', 'group'), ''); echo $OUTPUT->continue_button(new moodle_url('/group/index.php', array('id' => $course->id))); } } else { echo html_writer::div(get_string('groupnotamember', 'group'), ''); } echo $OUTPUT->footer(); ?> <script type="text/javascript" > $(document).ready(function(){ $("#dialog_delete_request").dialog({ autoOpen: false,
if (!empty($notifystrings)) { echo $OUTPUT->box('<p>' . implode('</p><p>', $notifystrings) . '</p>', 'statusdisplay'); } if ($quiz_reordertool) { $perpage = array(); $perpage[0] = get_string('allinone', 'quiz'); for ($i = 1; $i <= 50; ++$i) { $perpage[$i] = $i; } $gostring = get_string('go'); echo '<div id="repaginatedialog"><div class="hd">'; echo get_string('repaginatecommand', 'quiz'); echo '</div><div class="bd">'; echo '<form action="edit.php" method="post">'; echo '<fieldset class="invisiblefieldset">'; echo html_writer::input_hidden_params($thispageurl); echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; // YUI does not submit the value of the submit button so we need to add the value. echo '<input type="hidden" name="repaginate" value="' . $gostring . '" />'; $attributes = array(); $attributes['disabled'] = $repaginatingdisabledhtml ? 'disabled' : null; $select = html_writer::select($perpage, 'questionsperpage', $quiz->questionsperpage, null, $attributes); print_string('repaginate', 'quiz', $select); echo '<div class="quizquestionlistcontrols">'; echo ' <input type="submit" name="repaginate" value="' . $gostring . '" ' . $repaginatingdisabledhtml . ' />'; echo '</div></fieldset></form></div></div>'; } if ($quiz_reordertool) { echo '<div class="reorder">'; } else { echo '<div class="editq">';
$attr = array(); // other attributes; echo html_writer::checkbox('name', 'value', true, 'Checkbox label', $attr); echo html_writer::tag('p', 'To render a single yes/no select:'); echo html_writer::select_yes_no('name2', true, $attr); echo html_writer::tag('p', 'To render a normal single select:'); $options = array(1 => 'One', 2 => 'Two', 3 => 'Three'); echo html_writer::select($options, 'name3', 1, array('' => 'choosedots'), $attr); echo html_writer::tag('p', 'Or a single select with option grouping:'); $optoptions = array(array('Group 1' => array(1 => 'Option 1a', 2 => 'Option 1b', 3 => 'Option 1c')), array('Group 2' => array(4 => 'Option 2a', 5 => 'Option 2b', 6 => 'Option 2c'))); echo html_writer::select($optoptions, 'name4'); echo html_writer::tag('p', 'To render a time selector - you can choose the units (years, months, days, hours, minutes):'); echo html_writer::select_time('years', 'name5', time(), 5, $attr); echo html_writer::tag('p', 'Generate a hidden input field for every parameter in a moodle_url object (output displayed below instead of rendered):'); $url = new moodle_url('index.php', array('a' => 1, 'b' => 2, 'exclude' => 'this')); echo html_writer::tag('pre', htmlentities(html_writer::input_hidden_params($url, array('exclude')))); echo html_writer::tag('p', 'Generate a script tag (output displayed below instead of rendered):'); echo html_writer::tag('pre', htmlentities(html_writer::script('alert(\'hi\');'))); echo html_writer::tag('p', 'Generate a form label:'); echo html_writer::label('Label text', 'checkbox1'); echo html_writer::checkbox('name', 'value', false, null, array('id' => 'checkbox1')); echo html_writer::tag('p', 'A confirm form with continue/cancel options (just providing urls to go to):'); $continueurl = new moodle_url('index.php'); $cancelurl = new moodle_url('index.php'); echo $OUTPUT->confirm('This is the message', $continueurl, $cancelurl); echo html_writer::tag('p', 'A confirm form with continue/cancel options (with custom buttons):'); $continueurl = new moodle_url('index.php'); $cancelurl = new moodle_url('index.php'); $continuebutton = new single_button($continueurl, 'Custom Button text', 'post'); $cancelbutton = new single_button($cancelurl, 'Something else', 'get'); echo $OUTPUT->confirm('This is another message', $continuebutton, $cancelbutton);
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; }
echo html_writer::tag('div', stack_string('showingundeployedvariant', html_writer::tag('b', $question->seed)) . $deploybutton, array('class' => 'undeployedvariant')); } if ($question->has_random_variants()) { echo html_writer::start_tag('form', array('method' => 'get', 'class' => 'switchtovariant', 'action' => new moodle_url('/question/type/stack/questiontestrun.php'))); echo html_writer::start_tag('p'); echo html_writer::input_hidden_params($PAGE->url, array('seed')); echo html_writer::tag('label', stack_string('switchtovariant'), array('for' => 'seedfield')); echo ' ' . html_writer::empty_tag('input', array('type' => 'text', 'size' => 7, 'id' => 'seedfield', 'name' => 'seed', 'value' => mt_rand())); echo ' ' . html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('go'))); echo html_writer::end_tag('p'); echo html_writer::end_tag('form'); // Deploy many variants. if ($canedit) { echo html_writer::start_tag('form', array('method' => 'get', 'class' => 'deploymany', 'action' => new moodle_url('/question/type/stack/deploy.php', $urlparams))); echo html_writer::start_tag('p'); echo html_writer::input_hidden_params(new moodle_url($PAGE->url, array('sesskey' => sesskey())), array('seed')); echo html_writer::tag('label', stack_string('deploymany')); echo ' ' . html_writer::empty_tag('input', array('type' => 'text', 'size' => 4, 'id' => 'deploymanyfield', 'name' => 'deploymany', 'value' => '')); echo ' ' . html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('go'))); echo html_writer::tag('label', ' ' . stack_string('deploymanynotes')); echo html_writer::end_tag('p'); echo html_writer::end_tag('form'); } } // Display the controls to add another question test. echo $OUTPUT->heading(stack_string('questiontests'), 2); // Display the test results. $addlabel = stack_string('addanothertestcase', 'qtype_stack'); if (empty($testresults)) { echo html_writer::tag('p', stack_string('notestcasesyet')); $addlabel = stack_string('addatestcase', 'qtype_stack');