function output_individual_question_data($quiz, $question, $reporturl, $quizstats) { global $CFG, $DB, $QTYPES, $OUTPUT; require_once $CFG->dirroot . '/mod/quiz/report/statistics/statistics_question_table.php'; $this->qtable = new quiz_report_statistics_question_table($question->id); $downloadtype = $this->table->is_downloading(); if (!$this->table->is_downloading()) { $datumfromtable = $this->table->format_row($question); $questioninfotable = new html_table(); $questioninfotable->align = array('center', 'center'); $questioninfotable->width = '60%'; $questioninfotable->add_class('generaltable titlesleft'); $questioninfotable->data = array(); $questioninfotable->data[] = array(get_string('modulename', 'quiz'), $quiz->name); $questioninfotable->data[] = array(get_string('questionname', 'quiz_statistics'), $question->name . ' ' . $datumfromtable['actions']); $questioninfotable->data[] = array(get_string('questiontype', 'quiz_statistics'), $datumfromtable['icon'] . ' ' . get_string($question->qtype, 'quiz') . ' ' . $datumfromtable['icon']); $questioninfotable->data[] = array(get_string('positions', 'quiz_statistics'), $question->_stats->positions); $questionstatstable = new html_table(); $questionstatstable->align = array('center', 'center'); $questionstatstable->width = '60%'; $questionstatstable->add_class('generaltable titlesleft'); unset($datumfromtable['number']); unset($datumfromtable['icon']); $actions = $datumfromtable['actions']; unset($datumfromtable['actions']); unset($datumfromtable['name']); $labels = array('s' => get_string('attempts', 'quiz_statistics'), 'facility' => get_string('facility', 'quiz_statistics'), 'sd' => get_string('standarddeviationq', 'quiz_statistics'), 'random_guess_score' => get_string('random_guess_score', 'quiz_statistics'), 'intended_weight' => get_string('intended_weight', 'quiz_statistics'), 'effective_weight' => get_string('effective_weight', 'quiz_statistics'), 'discrimination_index' => get_string('discrimination_index', 'quiz_statistics'), 'discriminative_efficiency' => get_string('discriminative_efficiency', 'quiz_statistics')); foreach ($datumfromtable as $item => $value) { $questionstatstable->data[] = array($labels[$item], $value); } echo $OUTPUT->heading(get_string('questioninformation', 'quiz_statistics')); echo $OUTPUT->table($questioninfotable); echo $OUTPUT->box(format_text($question->questiontext, $question->questiontextformat) . $actions, 'boxaligncenter generalbox boxwidthnormal mdl-align'); echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics')); echo $OUTPUT->table($questionstatstable); } else { $this->qtable->export_class_instance($this->table->export_class_instance()); $questiontabletitle = !empty($question->number) ? '(' . $question->number . ') ' : ''; $questiontabletitle .= "\"{$question->name}\""; $questiontabletitle = "<em>{$questiontabletitle}</em>"; if ($downloadtype == 'xhtml') { $questiontabletitle = get_string('analysisofresponsesfor', 'quiz_statistics', $questiontabletitle); } $exportclass =& $this->table->export_class_instance(); $exportclass->start_table($questiontabletitle); } if ($QTYPES[$question->qtype]->show_analysis_of_responses()) { if (!$this->table->is_downloading()) { echo $OUTPUT->heading(get_string('analysisofresponses', 'quiz_statistics')); } $teacherresponses = $QTYPES[$question->qtype]->get_possible_responses($question); $this->qtable->setup($reporturl, $question, count($teacherresponses) > 1); if ($this->table->is_downloading()) { $exportclass->output_headers($this->qtable->headers); } $responses = $DB->get_records('quiz_question_response_stats', array('quizstatisticsid' => $quizstats->id, 'questionid' => $question->id), 'credit DESC, subqid ASC, aid ASC, rcount DESC'); $responses = quiz_report_index_by_keys($responses, array('subqid', 'aid'), false); foreach ($responses as $subqid => $response) { foreach (array_keys($responses[$subqid]) as $aid) { uasort($responses[$subqid][$aid], array('quiz_statistics_report', 'sort_answers')); } if (isset($responses[$subqid]['0'])) { $wildcardresponse = new object(); $wildcardresponse->answer = '*'; $wildcardresponse->credit = 0; $teacherresponses[$subqid][0] = $wildcardresponse; } } $first = true; $subq = 0; foreach ($teacherresponses as $subqid => $tresponsesforsubq) { $subq++; $qhaswildcards = $QTYPES[$question->qtype]->has_wildcards_in_responses($question, $subqid); if (!$first) { $this->qtable->add_separator(); } uasort($tresponsesforsubq, array('quiz_statistics_report', 'sort_response_details')); foreach ($tresponsesforsubq as $aid => $teacherresponse) { $teacherresponserow = new object(); $teacherresponserow->response = $teacherresponse->answer; $teacherresponserow->rcount = 0; $teacherresponserow->subq = $subq; $teacherresponserow->credit = $teacherresponse->credit; if (isset($responses[$subqid][$aid])) { $singleanswer = count($responses[$subqid][$aid]) == 1 && $responses[$subqid][$aid][0]->response == $teacherresponserow->response; if (!$singleanswer && $qhaswildcards) { $this->qtable->add_separator(); } foreach ($responses[$subqid][$aid] as $response) { $teacherresponserow->rcount += $response->rcount; } if ($aid != 0 || $qhaswildcards) { $this->qtable->add_data_keyed($this->qtable->format_row($teacherresponserow)); } if (!$singleanswer) { foreach ($responses[$subqid][$aid] as $response) { if (!$downloadtype || $downloadtype == 'xhtml') { $indent = ' '; } else { $indent = ' '; } $response->response = ($qhaswildcards ? $indent : '') . $response->response; $response->subq = $subq; if (count($responses[$subqid][$aid]) < 2 || $response->rcount > $teacherresponserow->rcount / 10) { $this->qtable->add_data_keyed($this->qtable->format_row($response)); } } } } else { $this->qtable->add_data_keyed($this->qtable->format_row($teacherresponserow)); } } $first = false; } $this->qtable->finish_output(!$this->table->is_downloading()); } if (!$this->table->is_downloading()) { $url = $reporturl->out(); $text = get_string('backtoquizreport', 'quiz_statistics'); echo $OUTPUT->box("<a href=\"{$url}\">{$text}</a>", 'boxaligncenter generalbox boxwidthnormal mdl-align'); } }
/** * Return the html contents for the summary for the last execution of the * given test type * * @param string $type of the test to return last execution summary (dbtest|unittest) * @return string html contents of the summary */ public static function get_summary_info($type) { global $CFG, $OUTPUT; $serfilepath = $CFG->dataroot . '/codecoverage/' . $type . '/codecoverage.ser'; if (file_exists($serfilepath) && is_readable($serfilepath)) { if ($data = unserialize(file_get_contents($serfilepath))) { // return one table with all the totals (we avoid individual file results here) $result = ''; $table = new html_table(); $table->align = array('right', 'left'); $table->tablealign = 'center'; $table->add_class('codecoveragetable'); $table->id = 'codecoveragetable_' . $type; $table->rowclasses = array('label', 'value'); $table->data = array(array(get_string('date'), userdate($data->time)), array(get_string('files'), format_float($data->totalfiles, 0)), array(get_string('totallines', 'simpletest'), format_float($data->totalln, 0)), array(get_string('executablelines', 'simpletest'), format_float($data->totalcoveredln + $data->totaluncoveredln, 0)), array(get_string('coveredlines', 'simpletest'), format_float($data->totalcoveredln, 0)), array(get_string('uncoveredlines', 'simpletest'), format_float($data->totaluncoveredln, 0)), array(get_string('coveredpercentage', 'simpletest'), format_float($data->totalpercentage, 2) . '%')); $url = $CFG->wwwroot . '/admin/report/unittest/coveragefile.php/' . $type . '/index.html'; $result .= $OUTPUT->heading($data->title, 3, 'main codecoverageheading'); $result .= $OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');return false;"' . ' title="">' . get_string('codecoveragecompletereport', 'simpletest') . '</a>', 4, 'main codecoveragelink'); $result .= $OUTPUT->table($table); return $OUTPUT->box($result, 'generalbox boxwidthwide boxaligncenter codecoveragebox', '', true); } } return false; }
/** * This function will print one beautiful table with all the environmental * configuration and how it suits Moodle needs. * * @global object * @param boolean $result final result of the check (true/false) * @param array $environment_results array of results gathered * @return void */ function print_moodle_environment($result, $environment_results) { global $CFG, $OUTPUT; /// Get some strings $strname = get_string('name'); $strinfo = get_string('info'); $strreport = get_string('report'); $strstatus = get_string('status'); $strok = get_string('ok'); $strerror = get_string('error'); $strcheck = get_string('check'); $strbypassed = get_string('bypassed'); $strrestricted = get_string('restricted'); $strenvironmenterrortodo = get_string('environmenterrortodo', 'admin'); /// Table headers $servertable = new html_table(); //table for server checks $servertable->head = array($strname, $strinfo, $strreport, $strstatus); $servertable->align = array('center', 'center', 'left', 'center'); $servertable->wrap = array('nowrap', '', '', 'nowrap'); $servertable->size = array('10', 10, '100%', '10'); $servertable->width = '90%'; $servertable->add_class('environmenttable generaltable'); $serverdata = array('ok' => array(), 'warn' => array(), 'error' => array()); $othertable = new html_table(); //table for custom checks $othertable->head = array($strinfo, $strreport, $strstatus); $othertable->align = array('center', 'left', 'center'); $othertable->wrap = array('', '', 'nowrap'); $othertable->size = array(10, '100%', '10'); $othertable->width = '90%'; $othertable->add_class('environmenttable generaltable'); $otherdata = array('ok' => array(), 'warn' => array(), 'error' => array()); /// Iterate over each environment_result $continue = true; foreach ($environment_results as $environment_result) { $errorline = false; $warningline = false; $stringtouse = ''; if ($continue) { $type = $environment_result->getPart(); $info = $environment_result->getInfo(); $status = $environment_result->getStatus(); $error_code = $environment_result->getErrorCode(); /// Process Report field $rec = new stdClass(); /// Something has gone wrong at parsing time if ($error_code) { $stringtouse = 'environmentxmlerror'; $rec->error_code = $error_code; $status = $strerror; $errorline = true; $continue = false; } if ($continue) { /// We are comparing versions if ($rec->needed = $environment_result->getNeededVersion()) { $rec->current = $environment_result->getCurrentVersion(); if ($environment_result->getLevel() == 'required') { $stringtouse = 'environmentrequireversion'; } else { $stringtouse = 'environmentrecommendversion'; } /// We are checking installed & enabled things } else { if ($environment_result->getPart() == 'custom_check') { if ($environment_result->getLevel() == 'required') { $stringtouse = 'environmentrequirecustomcheck'; } else { $stringtouse = 'environmentrecommendcustomcheck'; } } else { if ($environment_result->getPart() == 'php_setting') { if ($status) { $stringtouse = 'environmentsettingok'; } else { if ($environment_result->getLevel() == 'required') { $stringtouse = 'environmentmustfixsetting'; } else { $stringtouse = 'environmentshouldfixsetting'; } } } else { if ($environment_result->getLevel() == 'required') { $stringtouse = 'environmentrequireinstall'; } else { $stringtouse = 'environmentrecommendinstall'; } } } } /// Calculate the status value if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning) $status = $strbypassed; $warningline = true; } else { if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error) $status = $strrestricted; $errorline = true; } else { if ($status) { //Handle ok result (ok) $status = $strok; } else { if ($environment_result->getLevel() == 'optional') { //Handle check result (warning) $status = $strcheck; $warningline = true; } else { //Handle error result (error) $status = $strcheck; $errorline = true; } } } } } /// Build the text $linkparts = array(); $linkparts[] = 'admin/environment'; $linkparts[] = $type; if (!empty($info)) { $linkparts[] = $info; } if (empty($CFG->docroot)) { $report = get_string($stringtouse, 'admin', $rec); } else { $report = $OUTPUT->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec)); } /// Format error or warning line if ($errorline || $warningline) { $messagetype = $errorline ? 'error' : 'warn'; } else { $messagetype = 'ok'; } $status = '<span class="' . $messagetype . '">' . $status . '</span>'; /// Here we'll store all the feedback found $feedbacktext = ''; ///Append the feedback if there is some $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype); ///Append the bypass if there is some $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn'); ///Append the restrict if there is some $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error'); $report .= $feedbacktext; /// Add the row to the table if ($environment_result->getPart() == 'custom_check') { $otherdata[$messagetype][] = array($info, $report, $status); } else { $serverdata[$messagetype][] = array($type, $info, $report, $status); } } } //put errors first in $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']); $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']); /// Print table echo $OUTPUT->heading(get_string('serverchecks', 'admin')); echo $OUTPUT->table($servertable); if (count($othertable->data)) { echo $OUTPUT->heading(get_string('customcheck', 'admin')); echo $OUTPUT->table($othertable); } /// Finally, if any error has happened, print the summary box if (!$result) { echo $OUTPUT->box($strenvironmenterrortodo, 'environmentbox errorbox'); } }
/// Check that we have at least one category defined if ($DB->count_records('user_info_category') == 0) { $defaultcategory = new object(); $defaultcategory->name = $strdefaultcategory; $defaultcategory->sortorder = 1; $DB->insert_record('user_info_category', $defaultcategory); redirect($redirect); } /// Show all categories $categories = $DB->get_records('user_info_category', null, 'sortorder ASC'); foreach ($categories as $category) { $table = new html_table(); $table->head = array(get_string('profilefield', 'admin'), get_string('edit')); $table->align = array('left', 'right'); $table->width = '95%'; $table->add_class('generaltable profilefield'); $table->data = array(); if ($fields = $DB->get_records('user_info_field', array('categoryid' => $category->id), 'sortorder ASC')) { foreach ($fields as $field) { $table->data[] = array($field->name, profile_field_icons($field)); } } echo $OUTPUT->heading(format_string($category->name) . ' ' . profile_category_icons($category)); if (count($table->data)) { echo $OUTPUT->table($table); } else { echo $OUTPUT->notification($strnofields); } } /// End of $categories foreach echo '<hr />';
print_header_simple(format_string($attemptobj->get_quiz_name()), '', $attemptobj->navigation($title), '', '', true, $attemptobj->update_module_button()); } /// Print tabs if they should be there. if ($attemptobj->is_preview_user()) { $currenttab = 'preview'; include 'tabs.php'; } /// Print heading. echo $OUTPUT->heading(format_string($attemptobj->get_quiz_name())); if ($attemptobj->is_preview_user()) { $attemptobj->print_restart_preview_button(); } echo $OUTPUT->heading($title); /// Prepare the summary table header $table = new html_table(); $table->add_class('generaltable quizsummaryofattempt boxaligncenter'); $table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz')); $table->align = array('left', 'left'); $table->size = array('', ''); $scorescolumn = $attemptobj->get_review_options()->scores; if ($scorescolumn) { $table->head[] = get_string('marks', 'quiz'); $table->align[] = 'left'; $table->size[] = ''; } $table->data = array(); /// Get the summary info for each question. $questionids = $attemptobj->get_question_ids(); foreach ($attemptobj->get_question_iterator() as $number => $question) { if ($question->length == 0) { continue;
$user = make_context_subobj($user); $context = get_context_instance(CONTEXT_COURSE, $course->id); if (isset($user->context->id)) { $usercontext = $user->context; } else { $usercontext = get_context_instance(CONTEXT_USER, $user->id); } $countries = get_list_of_countries(); /// Get the hidden field list if (has_capability('moodle/course:viewhiddenuserfields', $context)) { $hiddenfields = array(); } else { $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields)); } $table = new html_table(); $table->add_class('userinfobox'); $row = new html_table_row(); $row->cells[0] = new html_table_cell(); $row->cells[0]->add_class('left side'); $row->cells[0]->text = $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id)); $row->cells[1] = new html_table_cell(); $row->cells[1]->add_class('content'); $row->cells[1]->text = $OUTPUT->container(fullname($user, has_capability('moodle/site:viewfullnames', $context)), 'username'); $row->cells[1]->text .= $OUTPUT->container_start('info'); if (!empty($user->role)) { $row->cells[1]->text .= get_string('role') . ': ' . $user->role . '<br />'; } if ($user->maildisplay == 1 or $user->maildisplay == 2 and $course->id != SITEID and !isguest() or has_capability('moodle/course:viewhiddenuserfields', $context)) { $link = new html_link(); $link->url = "mailto:{$user->email}"; $link->text = $user->email;
case 'grade': // Grading form // Expects the following to be set: $attemptid, $answer, $user, $page, $attempt echo '<div class="grade"> <form id="essaygrade" method="post" action="' . $CFG->wwwroot . '/mod/lesson/essay.php"> <input type="hidden" name="id" value="' . $cm->id . '" /> <input type="hidden" name="mode" value="update" /> <input type="hidden" name="attemptid" value="' . $attemptid . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" />'; // All tables will have these settings $originaltable = new html_table(); $originaltable->align = array('left'); $originaltable->wrap = array(); $originaltable->width = '50%'; $originaltable->size = array('100%'); $originaltable->add_class('generaltable gradetable'); // Print the question $table = clone $originaltable; $table->head = array(get_string('question', 'lesson')); $options = new stdClass(); $options->noclean = true; $table->data[] = array(format_text($page->contents, FORMAT_MOODLE, $options)); echo $OUTPUT->table($table); // Now the user's answer $essayinfo = unserialize($attempt->useranswer); $table = clone $originaltable; $table = new html_table(); $table->head = array(get_string('studentresponse', 'lesson', fullname($user, true))); $table->data[] = array(s($essayinfo->answer)); echo $OUTPUT->table($table); // Now a response box and grade drop-down for grader
/// Display the form for giving a reason for rejecting the request. admin_externalpage_print_header($rejectform->focus()); $rejectform->display(); echo $OUTPUT->footer(); exit; } /// Print a list of all the pending requests. admin_externalpage_print_header(); $pending = $DB->get_records('course_request'); if (empty($pending)) { echo $OUTPUT->heading(get_string('nopendingcourses')); } else { echo $OUTPUT->heading(get_string('coursespending')); /// Build a table of all the requests. $table = new html_table(); $table->add_class('pendingcourserequests generaltable'); $table->align = array('center', 'center', 'center', 'center', 'center', 'center', 'center'); $table->head = array(' ', get_string('shortname'), get_string('fullname'), get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action')); $strrequireskey = get_string('requireskey'); /// Loop over requested courses. foreach ($pending as $course) { $requester = $DB->get_record('user', array('id' => $course->requester)); $row = array(); /// Check here for shortname collisions and warn about them. if ($DB->record_exists('course', array('shortname' => $course->shortname))) { $course->shortname .= ' [*]'; $collision = 1; } /// Show an enrolment key icon in the first column if applicable. if (!empty($course->password)) { $row[] = '<img hspace="1" alt="' . $strrequireskey . '" class="icon" src="' . $OUTPUT->old_icon_url('i/key') . '" />';