本文整理匯總了PHP中question_attempt_step::set_state方法的典型用法代碼示例。如果您正苦於以下問題:PHP question_attempt_step::set_state方法的具體用法?PHP question_attempt_step::set_state怎麽用?PHP question_attempt_step::set_state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類question_attempt_step
的用法示例。
在下文中一共展示了question_attempt_step::set_state方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: start
/**
* Start this question attempt.
*
* You should not call this method directly. Call
* {@link question_usage_by_activity::start_question()} instead.
*
* @param string|question_behaviour $preferredbehaviour the name of the
* desired archetypal behaviour, or an actual model instance.
* @param int $variant the variant of the question to start. Between 1 and
* $this->get_question()->get_num_variants() inclusive.
* @param array $submitteddata optional, used when re-starting to keep the same initial state.
* @param int $timestamp optional, the timstamp to record for this action. Defaults to now.
* @param int $userid optional, the user to attribute this action to. Defaults to the current user.
* @param int $existingstepid optional, if this step is going to replace an existing step
* (for example, during a regrade) this is the id of the previous step we are replacing.
*/
public function start($preferredbehaviour, $variant, $submitteddata = array(), $timestamp = null, $userid = null, $existingstepid = null)
{
if ($this->get_num_steps() > 0) {
throw new coding_exception('Cannot start a question that is already started.');
}
// Initialise the behaviour.
$this->variant = $variant;
if (is_string($preferredbehaviour)) {
$this->behaviour = $this->question->make_behaviour($this, $preferredbehaviour);
} else {
$class = get_class($preferredbehaviour);
$this->behaviour = new $class($this, $preferredbehaviour);
}
// Record the minimum and maximum fractions.
$this->minfraction = $this->behaviour->get_min_fraction();
$this->maxfraction = $this->behaviour->get_max_fraction();
// Initialise the first step.
$firststep = new question_attempt_step($submitteddata, $timestamp, $userid, $existingstepid);
if ($submitteddata) {
$firststep->set_state(question_state::$complete);
$this->behaviour->apply_attempt_state($firststep);
} else {
$this->behaviour->init_first_step($firststep, $variant);
}
$this->add_step($firststep);
// Record questionline and correct answer.
$this->questionsummary = $this->behaviour->get_question_summary();
$this->rightanswer = $this->behaviour->get_right_answer_summary();
}
示例2: test_get_set_state
public function test_get_set_state()
{
$step = new question_attempt_step();
$step->set_state(question_state::$gradedright);
$this->assertEquals(question_state::$gradedright, $step->get_state());
}
示例3: test_render_missing
public function test_render_missing()
{
$questiondata = $this->get_unknown_questiondata();
$q = question_bank::make_question($questiondata);
$qa = new testable_question_attempt($q, 0);
$step = new question_attempt_step(array('answer' => 'frog'));
$step->set_state(question_state::$todo);
$qa->add_step($step);
$qa->set_behaviour(new qbehaviour_deferredfeedback($qa, 'deferredfeedback'));
$output = $qa->render(new question_display_options(), '1');
$this->assertRegExp('/' . preg_quote($qa->get_question()->questiontext, '/') . '/', $output);
$this->assertRegExp('/' . preg_quote(get_string('missingqtypewarning', 'qtype_missingtype'), '/') . '/', $output);
$this->assert(new question_contains_tag_with_attribute('div', 'class', 'warning missingqtypewarning'), $output);
}
示例4: start
/**
* Start this question attempt.
*
* You should not call this method directly. Call
* {@link question_usage_by_activity::start_question()} instead.
*
* @param string|question_behaviour $preferredbehaviour the name of the
* desired archetypal behaviour, or an actual model instance.
* @param int $variant the variant of the question to start. Between 1 and
* $this->get_question()->get_num_variants() inclusive.
* @param array $submitteddata optional, used when re-starting to keep the same initial state.
* @param int $timestamp optional, the timstamp to record for this action. Defaults to now.
* @param int $userid optional, the user to attribute this action to. Defaults to the current user.
* @param int $existingstepid optional, if this step is going to replace an existing step
* (for example, during a regrade) this is the id of the previous step we are replacing.
*/
public function start($preferredbehaviour, $variant, $submitteddata = array(),
$timestamp = null, $userid = null, $existingstepid = null) {
// Initialise the behaviour.
$this->variant = $variant;
if (is_string($preferredbehaviour)) {
$this->behaviour =
$this->question->make_behaviour($this, $preferredbehaviour);
} else {
$class = get_class($preferredbehaviour);
$this->behaviour = new $class($this, $preferredbehaviour);
}
// Record the minimum fraction.
$this->minfraction = $this->behaviour->get_min_fraction();
// Initialise the first step.
$firststep = new question_attempt_step($submitteddata, $timestamp, $userid, $existingstepid);
$firststep->set_state(question_state::$todo);
if ($submitteddata) {
$this->question->apply_attempt_state($firststep);
} else {
$this->behaviour->init_first_step($firststep, $variant);
}
$this->add_step($firststep);
// Record questionline and correct answer.
$this->questionsummary = $this->behaviour->get_question_summary();
$this->rightanswer = $this->behaviour->get_right_answer_summary();
}