本文整理汇总了PHP中question_attempt_step类的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt_step类的具体用法?PHP question_attempt_step怎么用?PHP question_attempt_step使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了question_attempt_step类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
}
}
}
}
开发者ID:fontinixxl,项目名称:moodle-qtype_linkerdesc,代码行数:39,代码来源:question.php
示例2: summarise_action
public function summarise_action(question_attempt_step $step) {
if ($step->has_behaviour_var('comment')) {
return $this->summarise_manual_comment($step);
} else if ($step->has_behaviour_var('finish')) {
return $this->summarise_finish($step);
} else {
return $this->summarise_save($step);
}
}
开发者ID:JP-Git,项目名称:moodle,代码行数:9,代码来源:behaviour.php
示例3: 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);
}
开发者ID:saylordotorg,项目名称:moodle-qbehaviour_adaptivehintsnopenalties,代码行数:11,代码来源:behaviour.php
示例4: apply_attempt_state
public function apply_attempt_state(question_attempt_step $step)
{
$saquestions = explode(',', $step->get_qt_var('_stemorder'));
foreach ($saquestions as $questionid) {
$this->stems[$questionid] = $step->get_qt_var('_stem_' . $questionid);
$this->stemformat[$questionid] = $step->get_qt_var('_stemformat_' . $questionid);
$key = $step->get_qt_var('_right_' . $questionid);
$this->right[$questionid] = $key;
$this->choices[$key] = $step->get_qt_var('_choice_' . $key);
}
parent::apply_attempt_state($step);
}
开发者ID:evltuma,项目名称:moodle,代码行数:12,代码来源:question.php
示例5: apply_attempt_state
public function apply_attempt_state(question_attempt_step $step)
{
$this->stemorder = explode(',', $step->get_qt_var('_stemorder'));
$this->set_choiceorder(explode(',', $step->get_qt_var('_choiceorder')));
// Add any missing subquestions. Sometimes people edit questions after they
// have been attempted which breaks things.
foreach ($this->stemorder as $stemid) {
if (!isset($this->stems[$stemid])) {
$this->stems[$stemid] = html_writer::span(get_string('deletedsubquestion', 'qtype_match'), 'notifyproblem');
$this->stemformat[$stemid] = FORMAT_HTML;
$this->right[$stemid] = 0;
}
}
// Add any missing choices. Sometimes people edit questions after they
// have been attempted which breaks things.
foreach ($this->choiceorder as $choiceid) {
if (!isset($this->choices[$choiceid])) {
$this->choices[$choiceid] = get_string('deletedchoice', 'qtype_match');
}
}
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:21,代码来源:question.php
示例6: summarise_action
public function summarise_action(question_attempt_step $step)
{
if ($step->has_behaviour_var('comment')) {
return $this->summarise_manual_comment($step);
} else {
if ($step->has_behaviour_var('finish')) {
return $this->summarise_finish($step);
} else {
if ($step->has_behaviour_var('tryagain')) {
return get_string('tryagain', 'qbehaviour_interactive');
} else {
if ($step->has_behaviour_var('submit')) {
return $this->summarise_submit($step);
} else {
return $this->summarise_save($step);
}
}
}
}
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:behaviour.php
示例7: load_question_attempt_step
/**
* Load a {@link question_attempt_step} from the database.
* @param int $stepid the id of the step to load.
* @param question_attempt_step the step that was loaded.
*/
public function load_question_attempt_step($stepid)
{
$records = $this->db->get_recordset_sql("\nSELECT\n quba.contextid,\n COALLESCE(q.qtype, 'missingtype') AS qtype,\n qas.id AS attemptstepid,\n qas.questionattemptid,\n qas.sequencenumber,\n qas.state,\n qas.fraction,\n qas.timecreated,\n qas.userid,\n qasd.name,\n qasd.value\n\nFROM {question_attempt_steps} qas\nJOIN {question_attempts} qa ON qa.id = qas.questionattemptid\nJOIN {question_usages} quba ON quba.id = qa.questionusageid\nLEFT JOIN {question} q ON q.id = qa.questionid\nLEFT JOIN {question_attempt_step_data} qasd ON qasd.attemptstepid = qas.id\n\nWHERE\n qas.id = :stepid\n ", array('stepid' => $stepid));
if (!$records->valid()) {
throw new coding_exception('Failed to load question_attempt_step ' . $stepid);
}
$step = question_attempt_step::load_from_records($records, $stepid);
$records->close();
return $step;
}
开发者ID:covex-nn,项目名称:moodle,代码行数:15,代码来源:datalib.php
示例8: 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());
}
开发者ID:jackdaniels79,项目名称:moodle,代码行数:9,代码来源:questionattemptstep_test.php
示例9: adaptive_mark_details_from_step
/**
* Actually populate the qbehaviour_adaptive_mark_details object.
* @param question_attempt_step $gradedstep the step that holds the relevant mark details.
* @param question_state $state the state corresponding to $gradedstep.
* @param unknown_type $maxmark the maximum mark for this question_attempt.
* @param unknown_type $penalty the penalty for this question, as a fraction.
*/
protected function adaptive_mark_details_from_step(question_attempt_step $gradedstep,
question_state $state, $maxmark, $penalty) {
$details = new qbehaviour_adaptive_mark_details($state);
$details->maxmark = $maxmark;
$details->actualmark = $gradedstep->get_fraction() * $details->maxmark;
$details->rawmark = $gradedstep->get_behaviour_var('_rawfraction') * $details->maxmark;
$details->currentpenalty = $penalty * $details->maxmark;
$details->totalpenalty = $details->currentpenalty * $this->qa->get_last_behaviour_var('_try', 0);
$details->improvable = $this->is_state_improvable($gradedstep->get_state());
return $details;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:22,代码来源:behaviour.php
示例10: apply_attempt_state
public function apply_attempt_state(question_attempt_step $step)
{
$this->answers = $this->get_ordering_answers();
$this->options = $this->get_ordering_options();
$this->currentresponse = array_filter(explode(',', $step->get_qt_var('_currentresponse')));
$this->correctresponse = array_filter(explode(',', $step->get_qt_var('_correctresponse')));
}
开发者ID:Kathrin84,项目名称:moodle-qtype_ordering,代码行数:7,代码来源:question.php
示例11: load_from_records
/**
* Create a question_attempt_step from records loaded from the database.
*
* For internal use only.
*
* @param Iterator $records Raw records loaded from the database.
* @param int $questionattemptid The id of the question_attempt to extract.
* @return question_attempt The newly constructed question_attempt.
*/
public static function load_from_records($records, $questionattemptid, question_usage_observer $observer, $preferredbehaviour)
{
$record = $records->current();
while ($record->questionattemptid != $questionattemptid) {
$record = $records->next();
if (!$records->valid()) {
throw new coding_exception("Question attempt {$questionattemptid} not found in the database.");
}
$record = $records->current();
}
try {
$question = question_bank::load_question($record->questionid);
} catch (Exception $e) {
// The question must have been deleted somehow. Create a missing
// question to use in its place.
$question = question_bank::get_qtype('missingtype')->make_deleted_instance($record->questionid, $record->maxmark + 0);
}
$qa = new question_attempt($question, $record->questionusageid, null, $record->maxmark + 0);
$qa->set_database_id($record->questionattemptid);
$qa->set_slot($record->slot);
$qa->variant = $record->variant + 0;
$qa->minfraction = $record->minfraction + 0;
$qa->maxfraction = $record->maxfraction + 0;
$qa->set_flagged($record->flagged);
$qa->questionsummary = $record->questionsummary;
$qa->rightanswer = $record->rightanswer;
$qa->responsesummary = $record->responsesummary;
$qa->timemodified = $record->timemodified;
$qa->behaviour = question_engine::make_behaviour($record->behaviour, $qa, $preferredbehaviour);
$qa->observer = $observer;
// If attemptstepid is null (which should not happen, but has happened
// due to corrupt data, see MDL-34251) then the current pointer in $records
// will not be advanced in the while loop below, and we get stuck in an
// infinite loop, since this method is supposed to always consume at
// least one record. Therefore, in this case, advance the record here.
if (is_null($record->attemptstepid)) {
$records->next();
}
$i = 0;
$autosavedstep = null;
$autosavedsequencenumber = null;
while ($record && $record->questionattemptid == $questionattemptid && !is_null($record->attemptstepid)) {
$sequencenumber = $record->sequencenumber;
$nextstep = question_attempt_step::load_from_records($records, $record->attemptstepid, $qa->get_question()->get_type_name());
if ($sequencenumber < 0) {
if (!$autosavedstep) {
$autosavedstep = $nextstep;
$autosavedsequencenumber = -$sequencenumber;
} else {
// Old redundant data. Mark it for deletion.
$qa->observer->notify_step_deleted($nextstep, $qa);
}
} else {
$qa->steps[$i] = $nextstep;
if ($i == 0) {
$question->apply_attempt_state($qa->steps[0]);
}
$i++;
}
if ($records->valid()) {
$record = $records->current();
} else {
$record = false;
}
}
if ($autosavedstep) {
if ($autosavedsequencenumber >= $i) {
$qa->autosavedstep = $autosavedstep;
$qa->steps[$i] = $qa->autosavedstep;
} else {
$qa->observer->notify_step_deleted($autosavedstep, $qa);
}
}
return $qa;
}
开发者ID:evltuma,项目名称:moodle,代码行数:84,代码来源:questionattempt.php
示例12: apply_attempt_state
public function apply_attempt_state(question_attempt_step $step)
{
if ($step->has_behaviour_var('_applypenalties')) {
$this->applypenalties = (bool) $step->get_behaviour_var('_applypenalties');
}
parent::apply_attempt_state($step);
}
开发者ID:sanyaade-teachings,项目名称:moodle-qbehaviour_adaptivemultipart,代码行数:7,代码来源:behaviour.php
示例13: 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()));
}
开发者ID:rezeau,项目名称:moodle-qbehaviour_regexpadaptivewithhelp,代码行数:4,代码来源:behaviour.php
示例14: load_from_records
/**
* Create a question_attempt_step from records loaded from the database.
*
* For internal use only.
*
* @param Iterator $records Raw records loaded from the database.
* @param int $questionattemptid The id of the question_attempt to extract.
* @return question_attempt The newly constructed question_attempt.
*/
public static function load_from_records($records, $questionattemptid,
question_usage_observer $observer, $preferredbehaviour) {
$record = $records->current();
while ($record->questionattemptid != $questionattemptid) {
$record = $records->next();
if (!$records->valid()) {
throw new coding_exception("Question attempt $questionattemptid not found in the database.");
}
$record = $records->current();
}
try {
$question = question_bank::load_question($record->questionid);
} catch (Exception $e) {
// The question must have been deleted somehow. Create a missing
// question to use in its place.
$question = question_bank::get_qtype('missingtype')->make_deleted_instance(
$record->questionid, $record->maxmark + 0);
}
$qa = new question_attempt($question, $record->questionusageid,
null, $record->maxmark + 0);
$qa->set_database_id($record->questionattemptid);
$qa->set_slot($record->slot);
$qa->variant = $record->variant + 0;
$qa->minfraction = $record->minfraction + 0;
$qa->set_flagged($record->flagged);
$qa->questionsummary = $record->questionsummary;
$qa->rightanswer = $record->rightanswer;
$qa->responsesummary = $record->responsesummary;
$qa->timemodified = $record->timemodified;
$qa->behaviour = question_engine::make_behaviour(
$record->behaviour, $qa, $preferredbehaviour);
$i = 0;
while ($record && $record->questionattemptid == $questionattemptid && !is_null($record->attemptstepid)) {
$qa->steps[$i] = question_attempt_step::load_from_records($records, $record->attemptstepid);
if ($i == 0) {
$question->apply_attempt_state($qa->steps[0]);
}
$i++;
if ($records->valid()) {
$record = $records->current();
} else {
$record = false;
}
}
$qa->observer = $observer;
return $qa;
}
开发者ID:numbas,项目名称:moodle,代码行数:62,代码来源:questionattempt.php
示例15: 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;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:25,代码来源:behaviour.php
示例16: 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;
}
}
}
开发者ID:r9loic,项目名称:JavaunittestV2,代码行数:22,代码来源:question.php
示例17: apply_attempt_state
public function apply_attempt_state(question_attempt_step $step)
{
$this->order = explode(',', $step->get_qt_var('_order'));
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:4,代码来源:question.php
示例18: apply_attempt_state
public function apply_attempt_state(question_attempt_step $step)
{
$this->seed = (int) $step->get_qt_var('_seed');
$this->initialise_question_from_seed();
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:5,代码来源:question.php
示例19: 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);
}
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:missingtype_test.php
示例20: start_attempt
public function start_attempt(question_attempt_step $step, $variant)
{
shuffle($this->allanswers);
$step->set_qt_var('_allanswers', implode(',', $this->allanswers));
}
开发者ID:dthies,项目名称:moodle-qtype_gapfill,代码行数:5,代码来源:question.php
注:本文中的question_attempt_step类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论