本文整理汇总了PHP中quiz_rescale_grade函数的典型用法代码示例。如果您正苦于以下问题:PHP quiz_rescale_grade函数的具体用法?PHP quiz_rescale_grade怎么用?PHP quiz_rescale_grade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quiz_rescale_grade函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: col_sumgrades
public function col_sumgrades($attempt)
{
if (!$attempt->timefinish) {
return '-';
}
$grade = quiz_rescale_grade($attempt->sumgrades, $this->quiz);
if ($this->is_downloading()) {
return $grade;
}
$gradehtml = '<a href="review.php?q=' . $this->quiz->id . '&attempt=' . $attempt->attempt . '">' . $grade . '</a>';
return $gradehtml;
}
示例2: prevent_new_attempt
public function prevent_new_attempt($numattempts, $lastattempt)
{
global $DB;
if ($numattempts == 0) {
return false;
}
// Check if preventonpass is set, and whether the student has passed the minimum passing grade.
$previousattempts = $DB->get_records_select('quiz_attempts', "quiz = :quizid AND userid = :userid AND timefinish > 0 and preview != 1", array('quizid' => $this->quiz->id, 'userid' => $lastattempt->userid));
if (quiz_rescale_grade(quiz_calculate_best_grade($this->quiz, $previousattempts), $this->quiz, false) >= $this->quiz->reattemptchecker) {
return get_string('accessprevented', 'quizaccess_reattemptchecker');
}
return false;
}
示例3: test_quiz_rescale_grade
public function test_quiz_rescale_grade()
{
$quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = 3;
$quiz->grade = 10;
$quiz->sumgrades = 10;
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, false), 0.12345678);
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.12, 2));
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, 'question'), format_float(0.123, 3));
$quiz->sumgrades = 5;
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, false), 0.24691356);
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.25, 2));
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, 'question'), format_float(0.247, 3));
}
示例4: quiz_format_average_grade_for_questions
function quiz_format_average_grade_for_questions($avggradebyq, $questions, $quiz, $download)
{
$row = array();
if (!$avggradebyq) {
$avggradebyq = array();
}
foreach (array_keys($questions) as $questionid) {
if (isset($avggradebyq[$questionid])) {
$grade = $avggradebyq[$questionid];
$grade = quiz_rescale_grade($grade, $quiz);
} else {
$grade = '--';
}
if (!$download) {
$grade = $grade . '/' . quiz_rescale_grade($questions[$questionid]->grade, $quiz);
}
$row['qsgrade' . $questionid] = $grade;
}
return $row;
}
示例5: view_table
/**
* Generates the table of data
*
* @param array $quiz Array contining quiz data
* @param int $context The page context ID
* @param mod_quiz_view_object $viewobj
*/
public function view_table($quiz, $context, $viewobj) {
$output = '';
if (!$viewobj->attempts) {
return $output;
}
$output .= $this->view_table_heading();
// Prepare table header
$table = new html_table();
$table->attributes['class'] = 'generaltable quizattemptsummary';
$table->head = array();
$table->align = array();
$table->size = array();
if ($viewobj->attemptcolumn) {
$table->head[] = get_string('attemptnumber', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
$table->head[] = get_string('timecompleted', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
if ($viewobj->markcolumn) {
$table->head[] = get_string('marks', 'quiz') . ' / ' .
quiz_format_grade($quiz, $quiz->sumgrades);
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->gradecolumn) {
$table->head[] = get_string('grade') . ' / ' .
quiz_format_grade($quiz, $quiz->grade);
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->canreviewmine) {
$table->head[] = get_string('review', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->feedbackcolumn) {
$table->head[] = get_string('feedback', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
}
if (isset($quiz->showtimetaken)) {
$table->head[] = get_string('timetaken', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
}
// One row for each attempt
foreach ($viewobj->attempts as $attempt) {
$attemptoptions = quiz_get_review_options($quiz, $attempt, $context);
$row = array();
// Add the attempt number, making it a link, if appropriate.
if ($viewobj->attemptcolumn) {
if ($attempt->preview) {
$row[] = get_string('preview', 'quiz');
} else {
$row[] = $attempt->attempt;
}
}
// prepare strings for time taken and date completed
$timetaken = '';
$datecompleted = '';
if ($attempt->timefinish > 0) {
// attempt has finished
$timetaken = format_time($attempt->timefinish - $attempt->timestart);
$datecompleted = userdate($attempt->timefinish);
} else if (!$quiz->timeclose || $viewobj->timenow < $quiz->timeclose) {
// The attempt is still in progress.
$timetaken = format_time($viewobj->timenow - $attempt->timestart);
$datecompleted = get_string('inprogress', 'quiz');
} else {
$timetaken = format_time($quiz->timeclose - $attempt->timestart);
$datecompleted = userdate($quiz->timeclose);
}
$row[] = $datecompleted;
if ($viewobj->markcolumn) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX &&
$attempt->timefinish > 0) {
$row[] = quiz_format_grade($quiz, $attempt->sumgrades);
} else {
$row[] = '';
}
}
// Ouside the if because we may be showing feedback but not grades.
$attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz, false);
if ($viewobj->gradecolumn) {
//.........这里部分代码省略.........
示例6: quiz_save_best_grade
/**
* Save the overall grade for a user at a quiz in the quiz_grades table
*
* @param object $quiz The quiz for which the best grade is to be calculated and then saved.
* @param int $userid The userid to calculate the grade for. Defaults to the current user.
* @param array $attempts The attempts of this user. Useful if you are
* looping through many users. Attempts can be fetched in one master query to
* avoid repeated querying.
* @return bool Indicates success or failure.
*/
function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
global $DB, $OUTPUT, $USER;
if (empty($userid)) {
$userid = $USER->id;
}
if (!$attempts) {
// Get all the attempts made by the user.
$attempts = quiz_get_user_attempts($quiz->id, $userid);
}
// Calculate the best grade.
$bestgrade = quiz_calculate_best_grade($quiz, $attempts);
$bestgrade = quiz_rescale_grade($bestgrade, $quiz, false);
// Save the best grade in the database.
if (is_null($bestgrade)) {
$DB->delete_records('quiz_grades', array('quiz' => $quiz->id, 'userid' => $userid));
} else if ($grade = $DB->get_record('quiz_grades',
array('quiz' => $quiz->id, 'userid' => $userid))) {
$grade->grade = $bestgrade;
$grade->timemodified = time();
$DB->update_record('quiz_grades', $grade);
} else {
$grade = new stdClass();
$grade->quiz = $quiz->id;
$grade->userid = $userid;
$grade->grade = $bestgrade;
$grade->timemodified = time();
$DB->insert_record('quiz_grades', $grade);
}
quiz_update_grades($quiz, $userid);
}
示例7: display
//.........这里部分代码省略.........
$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;
}
示例8: stdClass
if ($quiz->grade != $quiz->sumgrades) {
$a = new stdClass();
$a->grade = round($attempt->sumgrades, $CFG->quiz_decimalpoints);
$a->maxgrade = $quiz->sumgrades;
$rows[] = '<tr><th scope="row" class="cell">' . get_string('marks', 'quiz') . '</th><td class="cell">' . get_string('outofshort', 'quiz', $a) . '</td></tr>';
}
/// Now the scaled grade.
$a = new stdClass();
$a->grade = '<b>' . $grade . '</b>';
$a->maxgrade = $quiz->grade;
$a->percent = '<b>' . round($attempt->sumgrades / $quiz->sumgrades * 100, 0) . '</b>';
$rows[] = '<tr><th scope="row" class="cell">' . get_string('grade') . '</th><td class="cell">' . get_string('outofpercent', 'quiz', $a) . '</td></tr>';
}
}
/// Feedback if there is any, and the user is allowed to see it now.
$feedback = quiz_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $quiz, false), $attempt->quiz);
if ($options->overallfeedback && $feedback) {
$rows[] = '<tr><th scope="row" class="cell">' . get_string('feedback', 'quiz') . '</th><td class="cell">' . $feedback . '</td></tr>';
}
/// Now output the summary table, if there are any rows to be shown.
if (!empty($rows)) {
echo '<table class="generaltable generalbox quizreviewsummary"><tbody>', "\n";
echo implode("\n", $rows);
echo "\n</tbody></table>\n";
}
/// Print the navigation panel if required
$numpages = quiz_number_of_pages($attempt->layout);
if ($numpages > 1 and !$showall) {
print_paging_bar($numpages, $page, 1, 'review.php?attempt=' . $attempt->id . '&');
echo '<div class="controls"><a href="review.php?attempt=' . $attempt->id . '&showall=true">';
print_string('showall', 'quiz');
示例9: view_table
/**
* Generates the table of data
*
* @param array $quiz Array contining quiz data
* @param int $context The page context ID
* @param mod_quiz_view_object $viewobj
*/
public function view_table($quiz, $context, $viewobj) {
if (!$viewobj->attempts) {
return '';
}
// Prepare table header.
$table = new html_table();
$table->attributes['class'] = 'generaltable quizattemptsummary';
$table->head = array();
$table->align = array();
$table->size = array();
if ($viewobj->attemptcolumn) {
$table->head[] = get_string('attemptnumber', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
$table->head[] = get_string('attemptstate', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
if ($viewobj->markcolumn) {
$table->head[] = get_string('marks', 'quiz') . ' / ' .
quiz_format_grade($quiz, $quiz->sumgrades);
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->gradecolumn) {
$table->head[] = get_string('grade') . ' / ' .
quiz_format_grade($quiz, $quiz->grade);
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->canreviewmine) {
$table->head[] = get_string('review', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->feedbackcolumn) {
$table->head[] = get_string('feedback', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
}
// One row for each attempt.
foreach ($viewobj->attemptobjs as $attemptobj) {
$attemptoptions = $attemptobj->get_display_options(true);
$row = array();
// Add the attempt number.
if ($viewobj->attemptcolumn) {
if ($attemptobj->is_preview()) {
$row[] = get_string('preview', 'quiz');
} else {
$row[] = $attemptobj->get_attempt_number();
}
}
$row[] = $this->attempt_state($attemptobj);
if ($viewobj->markcolumn) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX &&
$attemptobj->is_finished()) {
$row[] = quiz_format_grade($quiz, $attemptobj->get_sum_marks());
} else {
$row[] = '';
}
}
// Ouside the if because we may be showing feedback but not grades.
$attemptgrade = quiz_rescale_grade($attemptobj->get_sum_marks(), $quiz, false);
if ($viewobj->gradecolumn) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX &&
$attemptobj->is_finished()) {
// Highlight the highest grade if appropriate.
if ($viewobj->overallstats && !$attemptobj->is_preview()
&& $viewobj->numattempts > 1 && !is_null($viewobj->mygrade)
&& $attemptgrade == $viewobj->mygrade
&& $quiz->grademethod == QUIZ_GRADEHIGHEST) {
$table->rowclasses[$attemptobj->get_attempt_number()] = 'bestrow';
}
$row[] = quiz_format_grade($quiz, $attemptgrade);
} else {
$row[] = '';
}
}
if ($viewobj->canreviewmine) {
$row[] = $viewobj->accessmanager->make_review_link($attemptobj->get_attempt(),
$attemptoptions, $this);
}
//.........这里部分代码省略.........
示例10: col_feedbacktext
function col_feedbacktext($attempt)
{
if ($attempt->timefinish) {
if (!$this->is_downloading()) {
return quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $this->quiz, false), $this->quiz->id);
} else {
return strip_tags(quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $this->quiz, false), $this->quiz->id));
}
} else {
return '-';
}
}
示例11: make_review_link
// Something weird happened.
$timetaken = '';
$datecompleted = '';
}
}
}
$row[] = $datecompleted;
if ($markcolumn && $attempt->timefinish > 0) {
if ($attemptoptions->scores) {
$row[] = make_review_link(round($attempt->sumgrades, $quiz->decimalpoints), $quiz, $attempt, $context);
} else {
$row[] = '';
}
}
// Ouside the if because we may be showing feedback but not grades.
$attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz);
if ($gradecolumn) {
if ($attemptoptions->scores && $attempt->timefinish > 0) {
$formattedgrade = $attemptgrade;
// highlight the highest grade if appropriate
if ($overallstats && $numattempts > 1 && !is_null($mygrade) && $attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
$table->rowclass[$attempt->attempt] = 'bestrow';
}
$row[] = make_review_link($formattedgrade, $quiz, $attempt, $context);
} else {
$row[] = '';
}
}
if ($feedbackcolumn && $attempt->timefinish > 0) {
if ($attemptoptions->overallfeedback) {
$row[] = quiz_feedback_for_grade($attemptgrade, $quiz->id);
示例12: col_feedbacktext
/**
* Generate the display of the feedback column.
* @param object $attempt the table row being output.
* @return string HTML content to go inside the td.
*/
public function col_feedbacktext($attempt) {
if ($attempt->state != quiz_attempt::FINISHED) {
return '-';
}
$feedback = quiz_report_feedback_for_grade(
quiz_rescale_grade($attempt->sumgrades, $this->quiz, false),
$this->quiz->id, $this->context);
if ($this->is_downloading()) {
$feedback = strip_tags($feedback);
}
return $feedback;
}
示例13: view_table
/**
* Generates the table of data
*
* @param array $quiz Array contining quiz data
* @param int $context The page context ID
* @param mod_quiz_view_object $viewobj
*/
public function view_table($quiz, $context, $viewobj)
{
// Most of the following code is unfortunately a duplicate of the existing renderer. There was no way to reuse the existing
// code and add the extra columns we wanted so I had to duplicate it.
// New parts of the code are marked with a comment // Grade by category code start. and // Grade by category code end.
global $DB;
// Grade by category code start.
// If gradebycategory setting is not on then just use the existing renderer.
if (!$quiz->gradebycategory) {
return parent::view_table($quiz, $context, $viewobj);
}
// Grade by category code end.
if (!$viewobj->attempts) {
return '';
}
// Prepare table header.
$table = new html_table();
$table->attributes['class'] = 'generaltable quizattemptsummary';
$table->head = array();
$table->align = array();
$table->size = array();
if ($viewobj->attemptcolumn) {
$table->head[] = get_string('attemptnumber', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
$table->head[] = get_string('attemptstate', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
if ($viewobj->markcolumn) {
$table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades);
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->gradecolumn) {
$table->head[] = get_string('grade') . ' / ' . quiz_format_grade($quiz, $quiz->grade);
$table->align[] = 'center';
$table->size[] = '';
}
// Grade by category code start.
$catgrades = new quizaccess_gradebycategory_calculator($quiz);
// $this->lateststeps may or may not already have been loaded depending if the reoprt
// is set to show question grades.
$catgrades->load_latest_steps($viewobj->attempts);
$categorynames = $catgrades->load_cat_data();
// Output column headings for category averages
foreach ($categorynames as $catname) {
$table->head[] = $catname . ' / ' . quiz_format_grade($quiz, 100);
$table->align[] = 'center';
$table->size[] = '';
}
// Grade by category code end.
if ($viewobj->canreviewmine) {
$table->head[] = get_string('review', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
if ($viewobj->feedbackcolumn) {
$table->head[] = get_string('feedback', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
}
// One row for each attempt.
foreach ($viewobj->attemptobjs as $attemptobj) {
$attemptoptions = $attemptobj->get_display_options(true);
$row = array();
// Add the attempt number.
if ($viewobj->attemptcolumn) {
if ($attemptobj->is_preview()) {
$row[] = get_string('preview', 'quiz');
} else {
$row[] = $attemptobj->get_attempt_number();
}
}
$row[] = $this->attempt_state($attemptobj);
if ($viewobj->markcolumn) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX && $attemptobj->is_finished()) {
$row[] = quiz_format_grade($quiz, $attemptobj->get_sum_marks());
} else {
$row[] = '';
}
}
// Outside the if because we may be showing feedback but not grades.
$attemptgrade = quiz_rescale_grade($attemptobj->get_sum_marks(), $quiz, false);
if ($viewobj->gradecolumn) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX && $attemptobj->is_finished()) {
// Highlight the highest grade if appropriate.
if ($viewobj->overallstats && !$attemptobj->is_preview() && $viewobj->numattempts > 1 && !is_null($viewobj->mygrade) && $attemptgrade == $viewobj->mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
$table->rowclasses[$attemptobj->get_attempt_number()] = 'bestrow';
}
$row[] = quiz_format_grade($quiz, $attemptgrade);
} else {
$row[] = '';
//.........这里部分代码省略.........
开发者ID:advancingdesign,项目名称:moodle-mod_quiz_accessrule_gradebycategory,代码行数:101,代码来源:mod_quiz_renderer.php
示例14: other_cols
/**
* @param string $colname the name of the column.
* @param object $attempt the row of data - see the SQL in display() in
* mod/quiz/report/overview/report.php to see what fields are present,
* and what they are called.
* @return string the contents of the cell.
*/
public function other_cols($colname, $attempt)
{
if (!preg_match('/^qsgrade(\\d+)$/', $colname, $matches)) {
return null;
}
$slot = $matches[1];
$question = $this->questions[$slot];
if (!isset($this->lateststeps[$attempt->usageid][$slot])) {
return '-';
}
$stepdata = $this->lateststeps[$attempt->usageid][$slot];
$state = question_state::get($stepdata->state);
if ($question->maxmark == 0) {
$grade = '-';
} else {
if (is_null($stepdata->fraction)) {
if ($state == question_state::$needsgrading) {
$grade = get_string('requiresgrading', 'question');
} else {
$grade = '-';
}
} else {
$grade = quiz_rescale_grade($stepdata->fraction * $question->maxmark, $this->quiz, 'question');
}
}
if ($this->is_downloading()) {
return $grade;
}
if (isset($this->regradedqs[$attempt->usageid][$slot])) {
$gradefromdb = $grade;
$newgrade = quiz_rescale_grade($this->regradedqs[$attempt->usageid][$slot]->newfraction * $question->maxmark, $this->quiz, 'question');
$oldgrade = quiz_rescale_grade($this->regradedqs[$attempt->usageid][$slot]->oldfraction * $question->maxmark, $this->quiz, 'question');
$grade = html_writer::tag('del', $oldgrade) . '/' . html_writer::empty_tag('br') . $newgrade;
}
return $this->make_review_link($grade, $attempt, $slot);
}
示例15: get_string
$attemptlist = $attemptobj->links_to_other_attempts($attemptobj->review_url(0, $page, $showall));
if ($attemptlist) {
$rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') . '</th><td class="cell">' . $attemptlist . '</td></tr>';
}
}
/// Timing information.
$rows[] = '<tr><th scope="row" class="cell">' . get_string('startedon', 'quiz') . '</th><td class="cell">' . userdate($attempt->timestart) . '</td></tr>';
if ($attempt->timefinish) {
$rows[] = '<tr><th scope="row" class="cell">' . get_string('completedon', 'quiz') . '</th><td class="cell">' . userdate($attempt->timefinish) . '</td></tr>';
$rows[] = '<tr><th scope="row" class="cell">' . get_string('timetaken', 'quiz') . '</th><td class="cell">' . $timetaken . '</td></tr>';
}
if (!empty($overtime)) {
$rows[] = '<tr><th scope="row" class="cell">' . get_string('overdue', 'quiz') . '</th><td class="cell">' . $overtime . '</td></tr>';
}
/// Show scores (if the user is allowed to see scores at the moment).
$grade = quiz_rescale_grade($attempt->sumgrades, $quiz, false);
if ($options->scores) {
if (quiz_has_grades($quiz)) {
if ($overtime) {
$result->sumgrades = "0";
$result->grade = "0.0";
}
/// Show raw marks only if they are different from the grade (like on the view page.
if ($quiz->grade != $quiz->sumgrades) {
$a = new stdClass();
$a->grade = quiz_format_grade($quiz, $attempt->sumgrades);
$a->maxgrade = quiz_format_grade($quiz, $quiz->sumgrades);
$rows[] = '<tr><th scope="row" class="cell">' . get_string('marks', 'quiz') . '</th><td class="cell">' . get_string('outofshort', 'quiz', $a) . '</td></tr>';
}
/// Now the scaled grade.
$a = new stdClass();