本文整理汇总了PHP中question_attempt_step::get_id方法的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt_step::get_id方法的具体用法?PHP question_attempt_step::get_id怎么用?PHP question_attempt_step::get_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_attempt_step
的用法示例。
在下文中一共展示了question_attempt_step::get_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply_attempt_state
/**
* When an in-progress {@link question_attempt} is re-loaded from the
* database, this method is called so that the question can re-initialise
* its internal state as needed by this attempt.
*
* For example, the multiple choice question type needs to set the order
* of the choices to the order that was set up when start_attempt was called
* originally. All the information required to do this should be in the
* $step object, which is the first step of the question_attempt being loaded.
*
* @param question_attempt_step The first step of the {@link question_attempt}
* being loaded.
*/
public function apply_attempt_state(\question_attempt_step $step)
{
global $DB;
$attemptid = $this->get_attemptid_by_stepid($step->get_id());
$this->usageid = $this->get_question_usageid($attemptid);
// Retrive all vars initialized in start_attempt().
foreach ($step->get_qt_data() as $name => $value) {
if (substr($name, 0, 5) === '_var_') {
$varid = substr($name, 5);
$varname = $this->vars[$varid]->varname;
$this->questiontext = str_replace('{$' . $varname . '}', $value, $this->questiontext);
// Store vars (as array form) to be used later to get the correct response
$this->varvalues[$varid] = explode(',', $value);
if (!($values = $DB->get_field('qtype_programmedresp_val', 'varvalues', array('attemptid' => $this->usageid, 'varid' => $varid)))) {
// Add a new random value
$val = new stdClass();
$val->attemptid = $this->usageid;
$val->varid = $varid;
$val->varvalues = programmedresp_serialize($this->varvalues[$varid]);
if (!$DB->insert_record('qtype_programmedresp_val', $val)) {
print_error('errordb', 'qtype_programmedresp');
}
}
}
}
}
示例2: apply_attempt_state
/**
* When an in-progress {@link question_attempt} is re-loaded from the database, this method is called so that the
* question can re-initialise its internal state as needed by this attempt. For example, the multiple choice
* question type needs to set the order of the choices to the order that was set up when start_attempt was called
* originally. All the information required to do this should be in the $step object, which is the first step of the
* question_attempt being loaded.
*
* @param question_attempt_step The first step of the {@link question_attempt} being loaded.
*/
public function apply_attempt_state(question_attempt_step $step)
{
global $DB;
$stepid = $step->get_id();
// We need a place to store the feedback generated by JUnit.
// Therefore we want to know the questionattemptid.
if (!empty($stepid)) {
$record = $DB->get_record('question_attempt_steps', array('id' => $stepid), 'questionattemptid');
if ($record) {
$this->questionattemptid = $record->questionattemptid;
}
}
}