本文整理汇总了PHP中lesson::get_next_page方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson::get_next_page方法的具体用法?PHP lesson::get_next_page怎么用?PHP lesson::get_next_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lesson
的用法示例。
在下文中一共展示了lesson::get_next_page方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: record_attempt
/**
* Records an attempt at this page
*
* @final
* @global moodle_database $DB
* @param stdClass $context
* @return stdClass Returns the result of the attempt
*/
public final function record_attempt($context)
{
global $DB, $USER, $OUTPUT;
/**
* This should be overridden by each page type to actually check the response
* against what ever custom criteria they have defined
*/
$result = $this->check_answer();
$result->attemptsremaining = 0;
$result->maxattemptsreached = false;
if ($result->noanswer) {
$result->newpageid = $this->properties->id;
// display same page again
$result->feedback = get_string('noanswer', 'lesson');
} else {
if (!has_capability('mod/lesson:manage', $context)) {
$nretakes = $DB->count_records("lesson_grades", array("lessonid" => $this->lesson->id, "userid" => $USER->id));
// record student's attempt
$attempt = new stdClass();
$attempt->lessonid = $this->lesson->id;
$attempt->pageid = $this->properties->id;
$attempt->userid = $USER->id;
$attempt->answerid = $result->answerid;
$attempt->retry = $nretakes;
$attempt->correct = $result->correctanswer;
if ($result->userresponse !== null) {
$attempt->useranswer = $result->userresponse;
}
$attempt->timeseen = time();
// if allow modattempts, then update the old attempt record, otherwise, insert new answer record
$userisreviewing = false;
if (isset($USER->modattempts[$this->lesson->id])) {
$attempt->retry = $nretakes - 1;
// they are going through on review, $nretakes will be too high
$userisreviewing = true;
}
// Only insert a record if we are not reviewing the lesson.
if (!$userisreviewing) {
if ($this->lesson->retake || !$this->lesson->retake && $nretakes == 0) {
$DB->insert_record("lesson_attempts", $attempt);
}
}
// "number of attempts remaining" message if $this->lesson->maxattempts > 1
// displaying of message(s) is at the end of page for more ergonomic display
if (!$result->correctanswer && $result->newpageid == 0) {
// wrong answer and student is stuck on this page - check how many attempts
// the student has had at this page/question
$nattempts = $DB->count_records("lesson_attempts", array("pageid" => $this->properties->id, "userid" => $USER->id, "retry" => $attempt->retry));
// retreive the number of attempts left counter for displaying at bottom of feedback page
if ($nattempts >= $this->lesson->maxattempts) {
if ($this->lesson->maxattempts > 1) {
// don't bother with message if only one attempt
$result->maxattemptsreached = true;
}
$result->newpageid = LESSON_NEXTPAGE;
} else {
if ($this->lesson->maxattempts > 1) {
// don't bother with message if only one attempt
$result->attemptsremaining = $this->lesson->maxattempts - $nattempts;
}
}
}
}
// TODO: merge this code with the jump code below. Convert jumpto page into a proper page id
if ($result->newpageid == 0) {
$result->newpageid = $this->properties->id;
} elseif ($result->newpageid == LESSON_NEXTPAGE) {
$result->newpageid = $this->lesson->get_next_page($this->properties->nextpageid);
}
// Determine default feedback if necessary
if (empty($result->response)) {
if (!$this->lesson->feedback && !$result->noanswer && !($this->lesson->review & !$result->correctanswer && !$result->isessayquestion)) {
// These conditions have been met:
// 1. The lesson manager has not supplied feedback to the student
// 2. Not displaying default feedback
// 3. The user did provide an answer
// 4. We are not reviewing with an incorrect answer (and not reviewing an essay question)
$result->nodefaultresponse = true;
// This will cause a redirect below
} else {
if ($result->isessayquestion) {
$result->response = get_string('defaultessayresponse', 'lesson');
} else {
if ($result->correctanswer) {
$result->response = get_string('thatsthecorrectanswer', 'lesson');
} else {
$result->response = get_string('thatsthewronganswer', 'lesson');
}
}
}
}
if ($result->response) {
//.........这里部分代码省略.........