本文整理汇总了PHP中question_state_is_graded函数的典型用法代码示例。如果您正苦于以下问题:PHP question_state_is_graded函数的具体用法?PHP question_state_is_graded怎么用?PHP question_state_is_graded使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了question_state_is_graded函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_question
function print_question(&$question, &$state, $number, $cmoptions, $options)
{
global $CFG;
$isfinished = question_state_is_graded($state->last_graded) || $state->event == QUESTION_EVENTCLOSE;
if (!empty($cmoptions->id)) {
$cm = get_coursemodule_from_instance('quiz', $cmoptions->id);
$cmorcourseid = '&cmid=' . $cm->id;
} else {
if (!empty($cmoptions->course)) {
$cmorcourseid = '&courseid=' . $cmoptions->course;
} else {
error('Need to provide courseid or cmid to print_question.');
}
}
// For editing teachers print a link to an editing popup window
$editlink = '';
if (question_has_capability_on($question, 'edit')) {
$stredit = get_string('edit');
$linktext = '<img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . $stredit . '" />';
$editlink = link_to_popup_window('/question/question.php?id=' . $question->id . $cmorcourseid, $stredit, $linktext, 450, 550, $stredit, '', true);
}
$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
$image = get_question_image($question);
$generalfeedback = '';
if ($isfinished && $options->generalfeedback) {
$generalfeedback = $this->format_text($question->generalfeedback, $question->questiontextformat, $cmoptions);
}
include "{$CFG->dirroot}/question/type/description/question.html";
}
示例2: print_question
function print_question(&$question, &$state, $number, $cmoptions, $options)
{
global $CFG;
$isfinished = question_state_is_graded($state->last_graded) || $state->event == QUESTION_EVENTCLOSE;
// For editing teachers print a link to an editing popup window
$editlink = $this->get_question_edit_link($question, $cmoptions, $options);
$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
$generalfeedback = '';
if ($isfinished && $options->generalfeedback) {
$generalfeedback = $this->format_text($question->generalfeedback, $question->generalfeedbackformat, $cmoptions);
}
include "{$CFG->dirroot}/question/type/description/question.html";
}
示例3: print_question
function print_question(&$question, &$state, $number, $cmoptions, $options)
{
global $CFG;
$isfinished = question_state_is_graded($state->last_graded) || $state->event == QUESTION_EVENTCLOSE;
// For editing teachers print a link to an editing popup window
$editlink = $this->get_question_edit_link($question, $cmoptions, $options);
$context = $this->get_context_by_category_id($question->category);
$question->questiontext = quiz_rewrite_question_urls($question->questiontext, 'pluginfile.php', $context->id, 'question', 'questiontext', array($state->attempt, $state->question), $question->id);
$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
$generalfeedback = '';
if ($isfinished && $options->generalfeedback) {
$question->generalfeedback = quiz_rewrite_question_urls($question->generalfeedback, 'pluginfile.php', $context->id, 'question', 'generalfeedback', array($state->attempt, $state->question), $question->id);
$generalfeedback = $this->format_text($question->generalfeedback, $question->generalfeedbackformat, $cmoptions);
}
include "{$CFG->dirroot}/question/type/description/question.html";
}
示例4: print_question
function print_question(&$question, &$state, $number, $cmoptions, $options)
{
global $CFG;
$isfinished = question_state_is_graded($state->last_graded) || $state->event == QUESTION_EVENTCLOSE;
// For editing teachers print a link to an editing popup window
$editlink = '';
if (has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $cmoptions->course))) {
$stredit = get_string('edit');
$linktext = '<img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . $stredit . '" />';
$editlink = link_to_popup_window('/question/question.php?id=' . $question->id, $stredit, $linktext, 450, 550, $stredit, '', true);
}
$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
$image = get_question_image($question, $cmoptions->course);
$generalfeedback = '';
if ($isfinished && $options->generalfeedback) {
$generalfeedback = $this->format_text($question->generalfeedback, $question->questiontextformat, $cmoptions);
}
include "{$CFG->dirroot}/question/type/description/question.html";
}
示例5: question_process_responses
/**
* Processes an array of student responses, grading and saving them as appropriate
*
* @param object $question Full question object, passed by reference
* @param object $state Full state object, passed by reference
* @param object $action object with the fields ->responses which
* is an array holding the student responses,
* ->action which specifies the action, e.g., QUESTION_EVENTGRADE,
* and ->timestamp which is a timestamp from when the responses
* were submitted by the student.
* @param object $cmoptions
* @param object $attempt The attempt is passed by reference so that
* during grading its ->sumgrades field can be updated
* @return boolean Indicates success/failure
*/
function question_process_responses(&$question, &$state, $action, $cmoptions, &$attempt)
{
global $QTYPES;
// if no responses are set initialise to empty response
if (!isset($action->responses)) {
$action->responses = array('' => '');
}
// make sure these are gone!
unset($action->responses['submit'], $action->responses['validate']);
// Check the question session is still open
if (question_state_is_closed($state)) {
return true;
}
// If $action->event is not set that implies saving
if (!isset($action->event)) {
debugging('Ambiguous action in question_process_responses.', DEBUG_DEVELOPER);
$action->event = QUESTION_EVENTSAVE;
}
// If submitted then compare against last graded
// responses, not last given responses in this case
if (question_isgradingevent($action->event)) {
$state->responses = $state->last_graded->responses;
}
// Check for unchanged responses (exactly unchanged, not equivalent).
// We also have to catch questions that the student has not yet attempted
$sameresponses = $QTYPES[$question->qtype]->compare_responses($question, $action, $state);
if (!empty($state->last_graded) && $state->last_graded->event == QUESTION_EVENTOPEN && question_isgradingevent($action->event)) {
$sameresponses = false;
}
// If the response has not been changed then we do not have to process it again
// unless the attempt is closing or validation is requested
if ($sameresponses and QUESTION_EVENTCLOSE != $action->event and QUESTION_EVENTVALIDATE != $action->event) {
return true;
}
// Roll back grading information to last graded state and set the new
// responses
$newstate = clone $state->last_graded;
$newstate->responses = $action->responses;
$newstate->seq_number = $state->seq_number + 1;
$newstate->changed = true;
// will assure that it gets saved to the database
$newstate->last_graded = clone $state->last_graded;
$newstate->timestamp = $action->timestamp;
$state = $newstate;
// Set the event to the action we will perform. The question type specific
// grading code may override this by setting it to QUESTION_EVENTCLOSE if the
// attempt at the question causes the session to close
$state->event = $action->event;
if (!question_isgradingevent($action->event)) {
// Grade the response but don't update the overall grade
if (!$QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions)) {
return false;
}
// Temporary hack because question types are not given enough control over what is going
// on. Used by Opaque questions.
// TODO fix this code properly.
if (!empty($state->believeevent)) {
// If the state was graded we need to ...
if (question_state_is_graded($state)) {
question_apply_penalty_and_timelimit($question, $state, $attempt, $cmoptions);
// update the attempt grade
$attempt->sumgrades -= (double) $state->last_graded->grade;
$attempt->sumgrades += (double) $state->grade;
// and update the last_graded field.
unset($state->last_graded);
$state->last_graded = clone $state;
unset($state->last_graded->changed);
}
} else {
// Don't allow the processing to change the event type
$state->event = $action->event;
}
} else {
// grading event
// Unless the attempt is closing, we want to work out if the current responses
// (or equivalent responses) were already given in the last graded attempt.
if (QUESTION_EVENTCLOSE != $action->event && QUESTION_EVENTOPEN != $state->last_graded->event && $QTYPES[$question->qtype]->compare_responses($question, $state, $state->last_graded)) {
$state->event = QUESTION_EVENTDUPLICATE;
}
// If we did not find a duplicate or if the attempt is closing, perform grading
if (!$sameresponses and QUESTION_EVENTDUPLICATE != $state->event or QUESTION_EVENTCLOSE == $action->event) {
if (!$QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions)) {
return false;
}
// Calculate overall grade using correct penalty method
//.........这里部分代码省略.........
示例6: quiz_get_renderoptions
/**
* Determine render options
*
* @param int $reviewoptions
* @param object $state
*/
function quiz_get_renderoptions($quiz, $attempt, $context, $state)
{
$reviewoptions = $quiz->review;
$options = new stdClass();
$options->flags = quiz_get_flag_option($attempt, $context);
// Show the question in readonly (review) mode if the question is in
// the closed state
$options->readonly = question_state_is_closed($state);
// Show feedback once the question has been graded (if allowed by the quiz)
$options->feedback = question_state_is_graded($state) && $reviewoptions & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY;
// Show correct responses in readonly mode if the quiz allows it
$options->correct_responses = $options->readonly && $reviewoptions & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY;
// Show general feedback if the question has been graded and the quiz allows it.
$options->generalfeedback = question_state_is_graded($state) && $reviewoptions & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY;
// Show overallfeedback once the attempt is over.
$options->overallfeedback = false;
// Always show responses and scores
$options->responses = true;
$options->scores = true;
$options->quizstate = QUIZ_STATE_DURING;
$options->history = false;
return $options;
}
示例7: is_graded
/**
* Checks to see if a question in a particular attempt is graded
*
* @return boolean
* @todo Finnish documenting this function
**/
function is_graded($question, $attempt)
{
global $CFG;
if (!($state = get_record_sql("SELECT state.id, state.event FROM\n {$CFG->prefix}question_states state, {$CFG->prefix}question_sessions sess\n WHERE sess.newest = state.id AND\n sess.attemptid = {$attempt->uniqueid} AND\n sess.questionid = {$question->id}"))) {
error('Could not find question state');
}
return question_state_is_graded($state);
}
示例8: other_cols
function other_cols($colname, $attempt)
{
global $QTYPES, $OUTPUT;
static $states = array();
if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)) {
if ($attempt->uniqueid == 0) {
return '-';
}
$questionid = $matches[1];
if (isset($this->gradedstatesbyattempt[$attempt->uniqueid][$questionid])) {
$stateforqinattempt = $this->gradedstatesbyattempt[$attempt->uniqueid][$questionid];
} else {
return '-';
}
$question = $this->questions[$questionid];
restore_question_state($question, $stateforqinattempt);
if (!$this->is_downloading() || $this->is_downloading() == 'xhtml') {
$formathtml = true;
} else {
$formathtml = false;
}
$summary = $QTYPES[$question->qtype]->response_summary($question, $stateforqinattempt, QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY, $formathtml);
if (!$this->is_downloading()) {
if ($summary) {
$link = html_link::make("/mod/quiz/reviewquestion.php?attempt={$attempt->attempt}&question={$question->id}", $summary);
$link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650)));
$link->title = $question->formattedname;
$summary = $OUTPUT->link($link);
if (question_state_is_graded($stateforqinattempt) && $question->maxgrade > 0) {
$grade = $stateforqinattempt->grade / $question->maxgrade;
$qclass = question_get_feedback_class($grade);
$feedbackimg = question_get_feedback_image($grade);
$questionclass = "que";
return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $summary . "</span></span>{$feedbackimg}";
} else {
return $summary;
}
} else {
return '';
}
} else {
return $summary;
}
} else {
return NULL;
}
}
示例9: question_print_comment_box
function question_print_comment_box($question, $state, $attempt, $url)
{
global $CFG, $QTYPES;
$prefix = 'response';
$usehtmleditor = can_use_richtext_editor();
if (!question_state_is_graded($state) && $QTYPES[$question->qtype]->is_question_manual_graded($question, $attempt->layout)) {
$grade = '';
} else {
$grade = round($state->last_graded->grade, 3);
}
echo '<form method="post" action="' . $url . '">';
include $CFG->dirroot . '/question/comment.html';
echo '<input type="hidden" name="attempt" value="' . $attempt->uniqueid . '" />';
echo '<input type="hidden" name="question" value="' . $question->id . '" />';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
echo '<input type="submit" name="submit" value="' . get_string('save', 'quiz') . '" />';
echo '</form>';
if ($usehtmleditor) {
use_html_editor();
}
}
示例10: print_questions_and_form
/**
* Prints questions with comment and grade form underneath each question
*
* @return void
* @todo Finish documenting this function
**/
function print_questions_and_form($quiz, $question, $userid, $attemptid, $gradeungraded, $gradenextungraded, $ungraded)
{
global $CFG;
// TODO get the context, and put in proper roles an permissions checks.
$context = NULL;
$questions[$question->id] =& $question;
$usehtmleditor = can_use_richtext_editor();
list($select, $from, $where) = $this->attempts_sql($quiz->id, false, $question->id, $userid, $attemptid, $gradeungraded, $gradenextungraded);
$sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
if ($gradenextungraded) {
$attempts = get_records_sql($select . $from . $where . $sort, 0, QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE);
} else {
$attempts = get_records_sql($select . $from . $where . $sort);
}
if ($attempts) {
$firstattempt = current($attempts);
$fullname = fullname($firstattempt);
if ($gradeungraded) {
// getting all ungraded attempts
print_heading(get_string('gradingungraded', 'quiz_grading', $ungraded), '', 3);
} else {
if ($gradenextungraded) {
// getting next ungraded attempts
print_heading(get_string('gradingnextungraded', 'quiz_grading', QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE), '', 3);
} else {
if ($userid) {
print_heading(get_string('gradinguser', 'quiz_grading', $fullname), '', 3);
} else {
if ($attemptid) {
$a = new object();
$a->fullname = $fullname;
$a->attempt = $firstattempt->attempt;
print_heading(get_string('gradingattempt', 'quiz_grading', $a), '', 3);
} else {
print_heading(get_string('gradingall', 'quiz_grading', count($attempts)), '', 3);
}
}
}
}
// Display the form with one part for each selected attempt
echo '<form method="post" action="report.php">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
foreach ($attempts as $attempt) {
// Load the state for this attempt (The questions array was created earlier)
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state =& $states[$question->id];
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
unset($options->questioncommentlink);
$options->noeditlink = true;
$copy = $state->manualcomment;
$state->manualcomment = '';
$options->readonly = 1;
$gradedclass = question_state_is_graded($state) ? ' class="highlightgraded" ' : '';
$gradedstring = question_state_is_graded($state) ? ' ' . get_string('graded', 'quiz_grading') : '';
$a = new object();
$a->fullname = fullname($attempt, true);
$a->attempt = $attempt->attempt;
// print the user name, attempt count, the question, and some more hidden fields
echo '<div class="boxaligncenter" width="80%" style="clear:left;padding:15px;">';
echo "<span{$gradedclass}>" . get_string('gradingattempt', 'quiz_grading', $a);
echo $gradedstring . "</span>";
print_question($question, $state, '', $quiz, $options);
$prefix = "manualgrades[{$attempt->uniqueid}]";
if (!question_state_is_graded($state)) {
$grade = '';
} else {
$grade = round($state->last_graded->grade, 3);
}
$state->manualcomment = $copy;
include $CFG->dirroot . '/question/comment.html';
echo '</div>';
}
echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
if ($usehtmleditor) {
use_html_editor();
}
} else {
notify(get_string('noattemptstoshow', 'quiz'));
}
}
示例11: 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.
*/
function other_cols($colname, $attempt)
{
if (preg_match('/^qsgrade([0-9]+)$/', $colname, $matches)) {
$questionid = $matches[1];
$question = $this->questions[$questionid];
if (isset($this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid])) {
$stateforqinattempt = $this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
} else {
$stateforqinattempt = false;
}
if ($stateforqinattempt && question_state_is_graded($stateforqinattempt)) {
$grade = quiz_rescale_grade($stateforqinattempt->grade, $this->quiz, 'question');
if (!$this->is_downloading()) {
if (isset($this->regradedqs[$attempt->attemptuniqueid][$questionid])) {
$gradefromdb = $grade;
$newgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->newgrade, $this->quiz, 'question');
$oldgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->oldgrade, $this->quiz, 'question');
$grade = '<del>' . $oldgrade . '</del><br />' . $newgrade;
}
$linktopopup = link_to_popup_window('/mod/quiz/reviewquestion.php?attempt=' . $attempt->attempt . '&question=' . $question->id, 'reviewquestion', $grade, 450, 650, get_string('reviewresponse', 'quiz'), 'none', true);
if ($this->questions[$questionid]->maxgrade != 0) {
$fractionofgrade = $stateforqinattempt->grade / $this->questions[$questionid]->maxgrade;
$qclass = question_get_feedback_class($fractionofgrade);
$feedbackimg = question_get_feedback_image($fractionofgrade);
$questionclass = "que";
return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $linktopopup . "</span></span>{$feedbackimg}";
} else {
return $linktopopup;
}
} else {
return $grade;
}
} else {
return '--';
}
} else {
return NULL;
}
}
示例12: 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.
*/
function other_cols($colname, $attempt)
{
global $OUTPUT;
if (preg_match('/^qsgrade([0-9]+)$/', $colname, $matches)) {
$questionid = $matches[1];
$question = $this->questions[$questionid];
if (isset($this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid])) {
$stateforqinattempt = $this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
} else {
$stateforqinattempt = false;
}
if ($stateforqinattempt && question_state_is_graded($stateforqinattempt)) {
$grade = quiz_rescale_grade($stateforqinattempt->grade, $this->quiz, 'question');
if (!$this->is_downloading()) {
if (isset($this->regradedqs[$attempt->attemptuniqueid][$questionid])) {
$gradefromdb = $grade;
$newgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->newgrade, $this->quiz, 'question');
$oldgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->oldgrade, $this->quiz, 'question');
$grade = '<del>' . $oldgrade . '</del><br />' . $newgrade;
}
$link = new moodle_url("/mod/quiz/reviewquestion.php?attempt={$attempt->attempt}&question={$question->id}");
$action = new popup_action('click', $link, 'reviewquestion', array('height' => 450, 'width' => 650));
$linktopopup = $OUTPUT->action_link($link, $grade, $action, array('title' => get_string('reviewresponsetoq', 'quiz', $question->formattedname)));
if ($this->questions[$questionid]->maxgrade != 0) {
$fractionofgrade = $stateforqinattempt->grade / $this->questions[$questionid]->maxgrade;
$qclass = question_get_feedback_class($fractionofgrade);
$feedbackimg = question_get_feedback_image($fractionofgrade);
$questionclass = "que";
return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $linktopopup . "</span></span>{$feedbackimg}";
} else {
return $linktopopup;
}
} else {
return $grade;
}
} else {
if ($stateforqinattempt && question_state_is_closed($stateforqinattempt)) {
$text = get_string('requiresgrading', 'quiz_overview');
if (!$this->is_downloading()) {
$link = new moodle_url("/mod/quiz/reviewquestion.php?attempt={$attempt->attempt}&question={$question->id}");
$action = new popup_action('click', $link, 'reviewquestion', array('height' => 450, 'width' => 650));
return $OUTPUT->action_link($link, $text, $action, array('title' => get_string('reviewresponsetoq', 'quiz', $question->formattedname)));
} else {
return $text;
}
} else {
return '--';
}
}
} else {
return NULL;
}
}
示例13: wrsqz_print_question_grading_details
/**
* This is a copy & paste of original shortanswer/questiontype.php print_question_grading_details() but
* filters correct answers before printing.
*/
function wrsqz_print_question_grading_details($questionType, $dbType, &$question, &$state, $cmoptions, $options){
if($questionType=='shortanswer'){
global $QTYPES ;
// MDL-7496 show correct answer after "Incorrect"
$correctanswer = '';
if ($correctanswers = wrsqz_get_correct_responses('shortanswer', 'wshanprom', null, $question, $state, 'W')) {
if ($options->readonly && $options->correct_responses) {
$delimiter = '';
if ($correctanswers) {
foreach ($correctanswers as $ca) {
$correctanswer .= $delimiter.$ca;
$delimiter = ', ';
}
}
}
}
if (QUESTION_EVENTDUPLICATE == $state->event) {
echo ' ';
print_string('duplicateresponse', 'quiz');
}
if (!empty($question->maxgrade) && $options->scores) {
if (question_state_is_graded($state->last_graded)) {
// Display the grading details from the last graded state
$grade = new stdClass;
$grade->cur = round($state->last_graded->grade, $cmoptions->decimalpoints);
$grade->max = $question->maxgrade;
$grade->raw = round($state->last_graded->raw_grade, $cmoptions->decimalpoints);
// let student know wether the answer was correct
echo '<div class="correctness ';
if ($state->last_graded->raw_grade >= $question->maxgrade/1.01) { // We divide by 1.01 so that rounding errors dont matter.
echo ' correct">';
print_string('correct', 'quiz');
} else if ($state->last_graded->raw_grade > 0) {
echo ' partiallycorrect">';
print_string('partiallycorrect', 'quiz');
// MDL-7496
if ($correctanswer) {
echo ('<div class="correctness">');
$format_options = new StdClass();
$format_options->filter=true;
$format_options->smiley=false;
$format_options->para=false;
$format_options->newlines=false;
$filtered_correct_answer = format_text($correctanswer, $question->questiontextformat, $format_options, $cmoptions->course);
print_string('correctansweris', 'quiz', $filtered_correct_answer);
echo ('</div>');
}
} else {
echo ' incorrect">';
// MDL-7496
print_string('incorrect', 'quiz');
if ($correctanswer) {
echo ('<div class="correctness">');
$format_options = new StdClass();
$format_options->filter=true;
$format_options->smiley=false;
$format_options->para=false;
$format_options->newlines=false;
$filtered_correct_answer = format_text($correctanswer, FORMAT_MOODLE, $format_options, $cmoptions->course);
print_string('correctansweris', 'quiz', $filtered_correct_answer);
echo ('</div>');
}
}
echo '</div>';
echo '<div class="gradingdetails">';
// print grade for this submission
print_string('gradingdetails', 'quiz', $grade);
if ($cmoptions->penaltyscheme) {
// print details of grade adjustment due to penalties
if ($state->last_graded->raw_grade > $state->last_graded->grade){
echo ' ';
print_string('gradingdetailsadjustment', 'quiz', $grade);
}
// print info about new penalty
// penalty is relevant only if the answer is not correct and further attempts are possible
if (($state->last_graded->raw_grade < $question->maxgrade) and (QUESTION_EVENTCLOSEANDGRADE != $state->event)) {
if ('' !== $state->last_graded->penalty && ((float)$state->last_graded->penalty) > 0.0) {
// A penalty was applied so display it
echo ' ';
print_string('gradingdetailspenalty', 'quiz', $state->last_graded->penalty);
} else {
/* No penalty was applied even though the answer was
not correct (eg. a syntax error) so tell the student
that they were not penalised for the attempt */
echo ' ';
print_string('gradingdetailszeropenalty', 'quiz');
}
}
}
echo '</div>';
}
}
}
//.........这里部分代码省略.........
示例14: other_cols
function other_cols($colname, $attempt)
{
global $QTYPES;
static $states = array();
if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)) {
if ($attempt->uniqueid == 0) {
return '-';
}
$questionid = $matches[1];
if (isset($this->gradedstatesbyattempt[$attempt->uniqueid][$questionid])) {
$stateforqinattempt = $this->gradedstatesbyattempt[$attempt->uniqueid][$questionid];
} else {
return '-';
}
$question = $this->questions[$questionid];
restore_question_state($question, $stateforqinattempt);
if (!$this->is_downloading() || $this->is_downloading() == 'xhtml') {
$formathtml = true;
} else {
$formathtml = false;
}
$summary = $QTYPES[$question->qtype]->response_summary($question, $stateforqinattempt, QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY, $formathtml);
if (!$this->is_downloading()) {
if ($summary) {
$summary = link_to_popup_window('/mod/quiz/reviewquestion.php?attempt=' . $attempt->attempt . '&question=' . $question->id, 'reviewquestion', $summary, 450, 650, get_string('reviewresponse', 'quiz'), 'none', true);
if (question_state_is_graded($stateforqinattempt) && $question->maxgrade > 0) {
$grade = $stateforqinattempt->grade / $question->maxgrade;
$qclass = question_get_feedback_class($grade);
$feedbackimg = question_get_feedback_image($grade);
$questionclass = "que";
return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $summary . "</span></span>{$feedbackimg}";
} else {
return $summary;
}
} else {
return '';
}
} else {
return $summary;
}
} else {
return NULL;
}
}
示例15: display
//.........这里部分代码省略.........
$row[] = '-';
$row[] = get_string('unfinished', 'quiz');
}
} else {
$row[] = '-';
$row[] = '-';
$row[] = '-';
}
// Grades columns.
if ($showgrades) {
if ($attempt->timefinish) {
$grade = quiz_rescale_grade($attempt->sumgrades, $quiz);
if (!$download) {
$gradehtml = '<a href="review.php?q=' . $quiz->id . '&attempt=' . $attempt->attempt . '">' . $grade . '</a>';
if ($qmsubselect && $attempt->gradedattempt) {
$gradehtml = '<div class="highlight">' . $gradehtml . '</div>';
}
$row[] = $gradehtml;
} else {
$row[] = $grade;
}
} else {
$row[] = '-';
}
}
if ($detailedmarks) {
if (empty($attempt->attempt)) {
foreach ($questions as $question) {
$row[] = '-';
}
} else {
foreach ($questions as $questionid => $question) {
$stateforqinattempt = $gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
if (question_state_is_graded($stateforqinattempt)) {
$grade = quiz_rescale_grade($stateforqinattempt->grade, $quiz);
} else {
$grade = '--';
}
if (!$download) {
$grade = $grade . '/' . quiz_rescale_grade($question->grade, $quiz);
$row[] = link_to_popup_window('/mod/quiz/reviewquestion.php?state=' . $stateforqinattempt->id . '&number=' . $question->number, 'reviewquestion', $grade, 450, 650, $strreviewquestion, 'none', true);
} else {
$row[] = $grade;
}
}
}
}
// Feedback column.
if ($hasfeedback) {
if ($attempt->timefinish) {
$row[] = quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $quiz), $quiz->id);
} else {
$row[] = '-';
}
}
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 {