本文整理汇总了PHP中question_engine::can_questions_finish_during_the_attempt方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine::can_questions_finish_during_the_attempt方法的具体用法?PHP question_engine::can_questions_finish_during_the_attempt怎么用?PHP question_engine::can_questions_finish_during_the_attempt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_engine
的用法示例。
在下文中一共展示了question_engine::can_questions_finish_during_the_attempt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_can_questions_finish_during_the_attempt
public function test_can_questions_finish_during_the_attempt()
{
$this->assertFalse(question_engine::can_questions_finish_during_the_attempt('deferredfeedback'));
$this->assertTrue(question_engine::can_questions_finish_during_the_attempt('interactive'));
}
示例2: can_finish_during_the_attempt
/**
* Whether it is possible for another question to depend on this one finishing.
* Note that the answer is not exact, because of random questions, and sometimes
* questions cannot be depended upon because of quiz options.
* @param int $slotnumber the index of the slot in question.
* @return bool can this question finish naturally during the attempt?
*/
public function can_finish_during_the_attempt($slotnumber)
{
if ($this->quizobj->get_navigation_method() == QUIZ_NAVMETHOD_SEQ) {
return false;
}
if ($this->slotsinorder[$slotnumber]->section->shufflequestions) {
return false;
}
if ($this->get_question_type_for_slot($slotnumber) == 'random') {
return \question_engine::can_questions_finish_during_the_attempt($this->quizobj->get_quiz()->preferredbehaviour);
}
if (isset($this->slotsinorder[$slotnumber]->canfinish)) {
return $this->slotsinorder[$slotnumber]->canfinish;
}
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $this->quizobj->get_context());
$tempslot = $quba->add_question(\question_bank::load_question($this->slotsinorder[$slotnumber]->questionid));
$quba->set_preferred_behaviour($this->quizobj->get_quiz()->preferredbehaviour);
$quba->start_all_questions();
$this->slotsinorder[$slotnumber]->canfinish = $quba->can_question_finish_during_attempt($tempslot);
return $this->slotsinorder[$slotnumber]->canfinish;
}
示例3: definition
//.........这里部分代码省略.........
}
$mform->addGroup($pagegroup, 'questionsperpagegrp', get_string('newpage', 'quiz'), null, false);
$mform->addHelpButton('questionsperpagegrp', 'newpage', 'quiz');
$mform->setAdvanced('questionsperpagegrp', $quizconfig->questionsperpage_adv);
// Navigation method.
$mform->addElement('select', 'navmethod', get_string('navmethod', 'quiz'), quiz_get_navigation_options());
$mform->addHelpButton('navmethod', 'navmethod', 'quiz');
$mform->setAdvanced('navmethod', $quizconfig->navmethod_adv);
$mform->setDefault('navmethod', $quizconfig->navmethod);
// -------------------------------------------------------------------------------
$mform->addElement('header', 'interactionhdr', get_string('questionbehaviour', 'quiz'));
// Shuffle within questions.
$mform->addElement('selectyesno', 'shuffleanswers', get_string('shufflewithin', 'quiz'));
$mform->addHelpButton('shuffleanswers', 'shufflewithin', 'quiz');
$mform->setAdvanced('shuffleanswers', $quizconfig->shuffleanswers_adv);
$mform->setDefault('shuffleanswers', $quizconfig->shuffleanswers);
// How questions behave (question behaviour).
if (!empty($this->current->preferredbehaviour)) {
$currentbehaviour = $this->current->preferredbehaviour;
} else {
$currentbehaviour = '';
}
$behaviours = question_engine::get_behaviour_options($currentbehaviour);
$mform->addElement('select', 'preferredbehaviour', get_string('howquestionsbehave', 'question'), $behaviours);
$mform->addHelpButton('preferredbehaviour', 'howquestionsbehave', 'question');
$mform->setDefault('preferredbehaviour', $quizconfig->preferredbehaviour);
// Can redo completed questions.
$redochoices = array(0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz'));
$mform->addElement('select', 'canredoquestions', get_string('canredoquestions', 'quiz'), $redochoices);
$mform->addHelpButton('canredoquestions', 'canredoquestions', 'quiz');
$mform->setAdvanced('canredoquestions', $quizconfig->canredoquestions_adv);
$mform->setDefault('canredoquestions', $quizconfig->canredoquestions);
foreach ($behaviours as $behaviour => $notused) {
if (!question_engine::can_questions_finish_during_the_attempt($behaviour)) {
$mform->disabledIf('canredoquestions', 'preferredbehaviour', 'eq', $behaviour);
}
}
// Each attempt builds on last.
$mform->addElement('selectyesno', 'attemptonlast', get_string('eachattemptbuildsonthelast', 'quiz'));
$mform->addHelpButton('attemptonlast', 'eachattemptbuildsonthelast', 'quiz');
$mform->setAdvanced('attemptonlast', $quizconfig->attemptonlast_adv);
$mform->setDefault('attemptonlast', $quizconfig->attemptonlast);
if ($this->get_max_attempts_for_any_override() < 2) {
$mform->disabledIf('attemptonlast', 'attempts', 'eq', 1);
}
// -------------------------------------------------------------------------------
$mform->addElement('header', 'reviewoptionshdr', get_string('reviewoptionsheading', 'quiz'));
$mform->addHelpButton('reviewoptionshdr', 'reviewoptionsheading', 'quiz');
// Review options.
$this->add_review_options_group($mform, $quizconfig, 'during', mod_quiz_display_options::DURING, true);
$this->add_review_options_group($mform, $quizconfig, 'immediately', mod_quiz_display_options::IMMEDIATELY_AFTER);
$this->add_review_options_group($mform, $quizconfig, 'open', mod_quiz_display_options::LATER_WHILE_OPEN);
$this->add_review_options_group($mform, $quizconfig, 'closed', mod_quiz_display_options::AFTER_CLOSE);
foreach ($behaviours as $behaviour => $notused) {
$unusedoptions = question_engine::get_behaviour_unused_display_options($behaviour);
foreach ($unusedoptions as $unusedoption) {
$mform->disabledIf($unusedoption . 'during', 'preferredbehaviour', 'eq', $behaviour);
}
}
$mform->disabledIf('attemptduring', 'preferredbehaviour', 'neq', 'wontmatch');
$mform->disabledIf('overallfeedbackduring', 'preferredbehaviour', 'neq', 'wontmatch');
// -------------------------------------------------------------------------------
$mform->addElement('header', 'display', get_string('appearance'));
// Show user picture.
$mform->addElement('select', 'showuserpicture', get_string('showuserpicture', 'quiz'), quiz_get_user_image_options());
$mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz');
示例4: can_finish_during_the_attempt
/**
* Whether it is possible for another question to depend on this one finishing.
* Note that the answer is not exact, because of random questions, and sometimes
* questions cannot be depended upon because of quiz options.
* @param int $slotnumber the index of the slot in question.
* @return bool can this question finish naturally during the attempt?
*/
public function can_finish_during_the_attempt($slotnumber)
{
if ($this->quizobj->get_navigation_method() == QUIZ_NAVMETHOD_SEQ) {
return false;
}
if ($this->slotsinorder[$slotnumber]->section->shufflequestions) {
return false;
}
if (in_array($this->get_question_type_for_slot($slotnumber), array('random', 'missingtype'))) {
return \question_engine::can_questions_finish_during_the_attempt($this->quizobj->get_quiz()->preferredbehaviour);
}
if (isset($this->slotsinorder[$slotnumber]->canfinish)) {
return $this->slotsinorder[$slotnumber]->canfinish;
}
try {
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $this->quizobj->get_context());
$tempslot = $quba->add_question(\question_bank::load_question($this->slotsinorder[$slotnumber]->questionid));
$quba->set_preferred_behaviour($this->quizobj->get_quiz()->preferredbehaviour);
$quba->start_all_questions();
$this->slotsinorder[$slotnumber]->canfinish = $quba->can_question_finish_during_attempt($tempslot);
return $this->slotsinorder[$slotnumber]->canfinish;
} catch (\Exception $e) {
// If the question fails to start, this should not block editing.
return false;
}
}