本文整理汇总了PHP中question_attempt_step::set_qt_var方法的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt_step::set_qt_var方法的具体用法?PHP question_attempt_step::set_qt_var怎么用?PHP question_attempt_step::set_qt_var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_attempt_step
的用法示例。
在下文中一共展示了question_attempt_step::set_qt_var方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
$this->stemorder = array_keys($this->stems);
if ($this->shufflestems) {
shuffle($this->stemorder);
}
$step->set_qt_var('_stemorder', implode(',', $this->stemorder));
$choiceorder = array_keys($this->choices);
shuffle($choiceorder);
$step->set_qt_var('_choiceorder', implode(',', $choiceorder));
$this->set_choiceorder($choiceorder);
}
示例2: start_attempt
public function start_attempt(question_attempt_step $step, $variant) {
$this->order = array_keys($this->answers);
if ($this->shuffleanswers) {
shuffle($this->order);
}
$step->set_qt_var('_order', implode(',', $this->order));
}
示例3: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
foreach ($this->choices as $group => $choices) {
$choiceorder = array_keys($choices);
if ($this->shufflechoices) {
shuffle($choiceorder);
}
$step->set_qt_var('_choiceorder' . $group, implode(',', $choiceorder));
$this->set_choiceorder($group, $choiceorder);
}
}
示例4: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
$saquestions = $this->questionsloader->load_questions();
foreach ($saquestions as $wrappedquestion) {
// Store and save stem text and format.
$this->stems[$wrappedquestion->id] = $wrappedquestion->questiontext;
$this->stemformat[$wrappedquestion->id] = $wrappedquestion->questiontextformat;
$step->set_qt_var('_stem_' . $wrappedquestion->id, $this->stems[$wrappedquestion->id]);
$step->set_qt_var('_stemformat_' . $wrappedquestion->id, $this->stemformat[$wrappedquestion->id]);
// Find, store and save right choice id.
$key = $this->find_right_answer($wrappedquestion);
$this->right[$wrappedquestion->id] = $key;
$step->set_qt_var('_right_' . $wrappedquestion->id, $key);
// No need to save saquestions, it will be saved by parent class in _stemorder.
}
// Save all the choices.
foreach ($this->choices as $key => $answer) {
$step->set_qt_var('_choice_' . $key, $answer);
}
parent::start_attempt($step, $variant);
}
示例5: start_attempt
/**
* Start a new attempt at this question, storing any information that will
* be needed later in the step.
*
* This is where the question can do any initialisation required on a
* per-attempt basis. For example, this is where the multiple choice
* question type randomly shuffles the choices (if that option is set).
*
* Any information about how the question has been set up for this attempt
* should be stored in the $step, by calling $step->set_qt_var(...).
*
* @param question_attempt_step The first step of the {@link question_attempt}
* being started. Can be used to store state.
* @param int $varant which variant of this question to start. Will be between
* 1 and {@link get_num_variants()} inclusive.
*/
public function start_attempt(\question_attempt_step $step, $variant)
{
// vars loaded by questiontype->initialize_question_instance()
foreach ($this->vars as $var) {
$values = programmedresp_get_random_value($var);
if (!$values) {
print_error('errordb', 'qtype_programmedresp');
}
$valuetodisplay = implode(', ', $values);
str_replace('{$' . $var->varname . '}', $valuetodisplay, $this->questiontext, $count);
// If $var->varname is found in questiontext ($count == true), then store it
$count && $step->set_qt_var('_var_' . $var->id, $valuetodisplay);
}
}
示例6: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
$this->answers = $this->get_ordering_answers();
$this->options = $this->get_ordering_options();
$countanswers = count($this->answers);
// sanitize "selecttype"
$selecttype = $this->options->selecttype;
$selecttype = max(0, $selecttype);
$selecttype = min(2, $selecttype);
// sanitize "selectcount"
$selectcount = $this->options->selectcount;
$selectcount = max(3, $selectcount);
$selectcount = min($countanswers, $selectcount);
// ensure consistency between "selecttype" and "selectcount"
switch (true) {
case $selecttype == 0:
$selectcount = $countanswers;
break;
case $selectcount == $countanswers:
$selecttype = 0;
break;
}
// extract answer ids
switch ($selecttype) {
case 0:
// all
$answerids = array_keys($this->answers);
break;
case 1:
// random subset
$answerids = array_rand($this->answers, $selectcount);
break;
case 2:
// contiguous subset
$answerids = array_keys($this->answers);
$offset = mt_rand(0, $countanswers - $selectcount);
$answerids = array_slice($answerids, $offset, $selectcount, true);
break;
}
$this->correctresponse = $answerids;
$step->set_qt_var('_correctresponse', implode(',', $this->correctresponse));
shuffle($answerids);
$this->currentresponse = $answerids;
$step->set_qt_var('_currentresponse', implode(',', $this->currentresponse));
}
示例7: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
shuffle($this->allanswers);
$step->set_qt_var('_allanswers', implode(',', $this->allanswers));
}
示例8: test_get_submitted_data
public function test_get_submitted_data()
{
$step = new question_attempt_step(array('x' => 1, '-y' => 'frog'));
$step->set_qt_var('_x', 1);
$step->set_behaviour_var('_x', 2);
$this->assertEquals(array('x' => 1, '-y' => 'frog'), $step->get_submitted_data());
}
示例9: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
$step->set_qt_var('_separators', $this->ap->get_point() . '$' . $this->ap->get_separator());
}
示例10: start_attempt
public static function start_attempt(
qtype_calculated_question_with_expressions $question,
question_attempt_step $step, $variant) {
$question->vs = new qtype_calculated_variable_substituter(
$question->datasetloader->get_values($variant),
get_string('decsep', 'langconfig'));
$question->calculate_all_expressions();
foreach ($question->vs->get_values() as $name => $value) {
$step->set_qt_var('_var_' . $name, $value);
}
}
示例11: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
// Work out the right seed to use.
if (!is_null($this->seed)) {
// Nasty hack, but if seed has already been set, then use that. This is
// used by the questiontestrun.php script to allow non-deployed
// variants to be browsed.
} else {
if (!$this->has_random_variants()) {
// Randomisation not used.
$this->seed = 1;
} else {
if (!empty($this->deployedseeds)) {
// Question has a fixed number of variants.
$this->seed = $this->deployedseeds[$variant - 1] + 0;
// Don't know why this is coming out as a string. + 0 converts to int.
} else {
// This question uses completely free randomisation.
$this->seed = $variant;
}
}
}
$step->set_qt_var('_seed', $this->seed);
$this->initialise_question_from_seed();
}