本文整理匯總了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;
}
}
}