本文整理汇总了PHP中question_attempt_step::get_qt_data方法的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt_step::get_qt_data方法的具体用法?PHP question_attempt_step::get_qt_data怎么用?PHP question_attempt_step::get_qt_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_attempt_step
的用法示例。
在下文中一共展示了question_attempt_step::get_qt_data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: summarise_hint
public function summarise_hint(question_attempt_step $step, $hintkey)
{
$response = $step->get_qt_data();
$hintkey = $this->adjust_hintkey($hintkey);
$hintobj = $this->question->hint_object($hintkey, $step->get_qt_data());
$hintdescription = $hintobj->hint_description();
$a = new stdClass();
$a->hint = $hintdescription;
$a->response = $this->question->summarise_response($response);
return get_string('hintused', 'qbehaviour_adaptivehintsnopenalties', $a);
}
示例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;
$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');
}
}
}
}
}
示例3: summarise_submit
public function summarise_submit(question_attempt_step $step) {
return get_string('submitted', 'question',
$this->question->summarise_response($step->get_qt_data()));
}
示例4: test_constructor_given_params
public function test_constructor_given_params()
{
global $USER;
$step = new question_attempt_step(array(), 123, 5);
$this->assertEquals(123, $step->get_timecreated());
$this->assertEquals(5, $step->get_user_id());
$this->assertEquals(array(), $step->get_qt_data());
$this->assertEquals(array(), $step->get_behaviour_data());
}
示例5: apply_attempt_state
public static function apply_attempt_state(
qtype_calculated_question_with_expressions $question, question_attempt_step $step) {
$values = array();
foreach ($step->get_qt_data() as $name => $value) {
if (substr($name, 0, 5) === '_var_') {
$values[substr($name, 5)] = $value;
}
}
$question->vs = new qtype_calculated_variable_substituter(
$values, get_string('decsep', 'langconfig'));
$question->calculate_all_expressions();
}
示例6: do_grading
protected function do_grading(question_attempt_step $responsesstep,
question_attempt_pending_step $pendingstep) {
if (!$this->question->is_gradable_response($responsesstep->get_qt_data())) {
$pendingstep->set_state(question_state::$gaveup);
} else {
$response = $responsesstep->get_qt_data();
list($fraction, $state) = $this->question->grade_response($response);
if ($responsesstep->has_behaviour_var('certainty')) {
$certainty = $responsesstep->get_behaviour_var('certainty');
} else {
$certainty = question_cbm::default_certainty();
$pendingstep->set_behaviour_var('_assumedcertainty', $certainty);
}
$pendingstep->set_behaviour_var('_rawfraction', $fraction);
$pendingstep->set_fraction(question_cbm::adjust_fraction($fraction, $certainty));
$pendingstep->set_state($state);
$pendingstep->set_new_response_summary(question_cbm::summary_with_certainty(
$this->question->summarise_response($response),
$responsesstep->get_behaviour_var('certainty')));
}
return question_attempt::KEEP;
}
示例7: summarise_helpme
public function summarise_helpme(question_attempt_step $step)
{
return get_string('submittedwithhelp', 'qbehaviour_regexpadaptivewithhelp', $this->question->summarise_response_withhelp($step->get_qt_data()));
}