本文整理汇总了PHP中question_usage_by_activity::load_from_records方法的典型用法代码示例。如果您正苦于以下问题:PHP question_usage_by_activity::load_from_records方法的具体用法?PHP question_usage_by_activity::load_from_records怎么用?PHP question_usage_by_activity::load_from_records使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_usage_by_activity
的用法示例。
在下文中一共展示了question_usage_by_activity::load_from_records方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_initial_test_state
protected function setup_initial_test_state($testdata)
{
$records = new question_test_recordset($testdata);
$this->quba = question_usage_by_activity::load_from_records($records, 1);
$this->slot = 1;
$this->observer = new testable_question_engine_unit_of_work($this->quba);
$this->quba->set_observer($this->observer);
}
示例2: test_load_data_no_qas
public function test_load_data_no_qas() {
// The code had a bug where if a question_usage had no question_attempts,
// load_from_records got stuck in an infinite loop. This test is to
// verify that no longer happens.
$scid = context_system::instance()->id;
$records = new question_test_recordset(array(
array('qubaid', 'contextid', 'component', 'preferredbehaviour',
'questionattemptid', 'questionusageid', 'slot',
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'flagged',
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
'attemptstepid', 'sequencenumber', 'state', 'fraction',
'timecreated', 'userid', 'name', 'value'),
array(1, $scid, 'unit_test', 'interactive', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null),
));
question_bank::start_unit_test();
$quba = question_usage_by_activity::load_from_records($records, 1);
question_bank::end_unit_test();
$this->assertEquals('unit_test', $quba->get_owning_component());
$this->assertEquals(1, $quba->get_id());
$this->assertInstanceOf('question_engine_unit_of_work', $quba->get_observer());
$this->assertEquals('interactive', $quba->get_preferred_behaviour());
$this->assertEquals(array(), $quba->get_slots());
}
示例3: load_questions_usage_by_activity
/**
* Load a {@link question_usage_by_activity} from the database, including
* all its {@link question_attempt}s and all their steps.
* @param int $qubaid the id of the usage to load.
* @param question_usage_by_activity the usage that was loaded.
*/
public function load_questions_usage_by_activity($qubaid)
{
$records = $this->db->get_recordset_sql("\nSELECT\n quba.id AS qubaid,\n quba.contextid,\n quba.component,\n quba.preferredbehaviour,\n qa.id AS questionattemptid,\n qa.questionusageid,\n qa.slot,\n qa.behaviour,\n qa.questionid,\n qa.variant,\n qa.maxmark,\n qa.minfraction,\n qa.maxfraction,\n qa.flagged,\n qa.questionsummary,\n qa.rightanswer,\n qa.responsesummary,\n qa.timemodified,\n qas.id AS attemptstepid,\n qas.sequencenumber,\n qas.state,\n qas.fraction,\n qas.timecreated,\n qas.userid,\n qasd.name,\n qasd.value\n\nFROM {question_usages} quba\nLEFT JOIN {question_attempts} qa ON qa.questionusageid = quba.id\nLEFT JOIN {question_attempt_steps} qas ON qas.questionattemptid = qa.id\nLEFT JOIN {question_attempt_step_data} qasd ON qasd.attemptstepid = qas.id\n\nWHERE\n quba.id = :qubaid\n\nORDER BY\n qa.slot,\n qas.sequencenumber\n ", array('qubaid' => $qubaid));
if (!$records->valid()) {
throw new coding_exception('Failed to load questions_usage_by_activity ' . $qubaid);
}
$quba = question_usage_by_activity::load_from_records($records, $qubaid);
$records->close();
return $quba;
}
示例4: test_load
public function test_load() {
$records = new question_test_recordset(array(
array('qubaid', 'contextid', 'component', 'preferredbehaviour',
'questionattemptid', 'contextid', 'questionusageid', 'slot',
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'flagged',
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
'attemptstepid', 'sequencenumber', 'state', 'fraction',
'timecreated', 'userid', 'name', 'value'),
array(1, 1, 'unit_test', 'interactive', 1, 123, 1, 1, 'interactive', -1, 1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, null, null),
array(1, 1, 'unit_test', 'interactive', 1, 123, 1, 1, 'interactive', -1, 1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 2, 1, 'todo', null, 1256233705, 1, 'answer', '1'),
array(1, 1, 'unit_test', 'interactive', 1, 123, 1, 1, 'interactive', -1, 1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 5, 2, 'gradedright', 1.0000000, 1256233720, 1, '-finish', '1'),
));
$question = test_question_maker::make_question('truefalse', 'true');
$question->id = -1;
question_bank::start_unit_test();
question_bank::load_test_question_data($question);
$quba = question_usage_by_activity::load_from_records($records, 1);
question_bank::end_unit_test();
$this->assertEquals('unit_test', $quba->get_owning_component());
$this->assertEquals(1, $quba->get_id());
$this->assertInstanceOf('question_engine_unit_of_work', $quba->get_observer());
$this->assertEquals('interactive', $quba->get_preferred_behaviour());
$qa = $quba->get_question_attempt(1);
$this->assertEquals($question->questiontext, $qa->get_question()->questiontext);
$this->assertEquals(3, $qa->get_num_steps());
$step = $qa->get_step(0);
$this->assertEquals(question_state::$todo, $step->get_state());
$this->assertNull($step->get_fraction());
$this->assertEquals(1256233700, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array(), $step->get_all_data());
$step = $qa->get_step(1);
$this->assertEquals(question_state::$todo, $step->get_state());
$this->assertNull($step->get_fraction());
$this->assertEquals(1256233705, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array('answer' => '1'), $step->get_all_data());
$step = $qa->get_step(2);
$this->assertEquals(question_state::$gradedright, $step->get_state());
$this->assertEquals(1, $step->get_fraction());
$this->assertEquals(1256233720, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array('-finish' => '1'), $step->get_all_data());
}