本文整理汇总了PHP中question_engine_data_mapper::load_questions_usages_latest_steps方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine_data_mapper::load_questions_usages_latest_steps方法的具体用法?PHP question_engine_data_mapper::load_questions_usages_latest_steps怎么用?PHP question_engine_data_mapper::load_questions_usages_latest_steps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_engine_data_mapper
的用法示例。
在下文中一共展示了question_engine_data_mapper::load_questions_usages_latest_steps方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_latest_steps
public function load_latest_steps($attempts)
{
$qubaids = array();
foreach ($attempts as $attempt) {
$qubaids[] = $attempt->uniqueid;
}
$dm = new question_engine_data_mapper();
$qubaidcondition = new qubaid_list($qubaids);
$slots = array_filter(explode(',', $attempt->layout));
$lateststeps = $dm->load_questions_usages_latest_steps($qubaidcondition, $slots);
$this->lateststeps = array();
foreach ($lateststeps as $step) {
$this->lateststeps[$step->questionusageid][$step->slot] = $step;
}
}
开发者ID:advancingdesign,项目名称:moodle-mod_quiz_accessrule_gradebycategory,代码行数:15,代码来源:gradebycatcalculator.php
示例2: dotest_load_questions_usages_latest_steps
protected function dotest_load_questions_usages_latest_steps() {
$rawstates = $this->dm->load_questions_usages_latest_steps($this->bothusages, $this->allslots);
$states = array();
foreach ($rawstates as $state) {
$states[$state->questionusageid][$state->slot] = $state;
foreach (get_object_vars($state) as $name => $notused) {
if (!in_array($name, array('questionid', 'maxmark', 'sequencenumber', 'state'))) {
unset($state->$name);
}
}
}
$state = $states[$this->usageids[0]][$this->allslots[0]];
$this->assertEquals((object) array(
'questionid' => $this->sa->id,
'maxmark' => '5.0000000',
'sequencenumber' => 2,
'state' => (string) question_state::$gradedright,
), $state);
$state = $states[$this->usageids[0]][$this->allslots[1]];
$this->assertEquals((object) array(
'questionid' => $this->essay->id,
'maxmark' => '10.0000000',
'sequencenumber' => 2,
'state' => (string) question_state::$needsgrading,
), $state);
$state = $states[$this->usageids[1]][$this->allslots[0]];
$this->assertEquals((object) array(
'questionid' => $this->sa->id,
'maxmark' => '5.0000000',
'sequencenumber' => 2,
'state' => (string) question_state::$gradedwrong,
), $state);
$state = $states[$this->usageids[1]][$this->allslots[1]];
$this->assertEquals((object) array(
'questionid' => $this->essay->id,
'maxmark' => '10.0000000',
'sequencenumber' => 1,
'state' => (string) question_state::$gaveup,
), $state);
}
示例3: dotest_load_questions_usages_latest_steps
/**
* This test is executed by {@link test_reporting_queries()}.
*/
protected function dotest_load_questions_usages_latest_steps()
{
$rawstates = $this->dm->load_questions_usages_latest_steps($this->bothusages, $this->allslots, 'qa.id AS questionattemptid, qa.questionusageid, qa.slot, ' . 'qa.questionid, qa.maxmark, qas.sequencenumber, qas.state');
$states = array();
foreach ($rawstates as $state) {
$states[$state->questionusageid][$state->slot] = $state;
unset($state->questionattemptid);
unset($state->questionusageid);
unset($state->slot);
}
$state = $states[$this->usageids[0]][$this->allslots[0]];
$this->assertEquals((object) array('questionid' => $this->sa->id, 'maxmark' => '5.0000000', 'sequencenumber' => 2, 'state' => (string) question_state::$gradedright), $state);
$state = $states[$this->usageids[0]][$this->allslots[1]];
$this->assertEquals((object) array('questionid' => $this->essay->id, 'maxmark' => '10.0000000', 'sequencenumber' => 2, 'state' => (string) question_state::$needsgrading), $state);
$state = $states[$this->usageids[1]][$this->allslots[0]];
$this->assertEquals((object) array('questionid' => $this->sa->id, 'maxmark' => '5.0000000', 'sequencenumber' => 2, 'state' => (string) question_state::$gradedwrong), $state);
$state = $states[$this->usageids[1]][$this->allslots[1]];
$this->assertEquals((object) array('questionid' => $this->essay->id, 'maxmark' => '10.0000000', 'sequencenumber' => 1, 'state' => (string) question_state::$gaveup), $state);
}
示例4: load_question_latest_steps
/**
* Load information about the latest state of selected questions in selected attempts.
*
* The results are returned as an two dimensional array $qubaid => $slot => $dataobject
*
* @param qubaid_condition $qubaids used to restrict which usages are included
* in the query. See {@link qubaid_condition}.
* @return array of records. See the SQL in this function to see the fields available.
*/
protected function load_question_latest_steps(qubaid_condition $qubaids) {
$dm = new question_engine_data_mapper();
$latesstepdata = $dm->load_questions_usages_latest_steps(
$qubaids, array_keys($this->questions));
$lateststeps = array();
foreach ($latesstepdata as $step) {
$lateststeps[$step->questionusageid][$step->slot] = $step;
}
return $lateststeps;
}
示例5: get_latest_steps
/**
* Get the latest step data from the db, from which we will calculate stats.
*
* @param \qubaid_condition $qubaids Which question usages to get the latest steps for?
* @return array with two items
* - $lateststeps array of latest step data for the question usages
* - $summarks array of total marks for each usage, indexed by usage id
*/
protected function get_latest_steps($qubaids)
{
$dm = new \question_engine_data_mapper();
$fields = " qas.id,\n qa.questionusageid,\n qa.questionid,\n qa.variant,\n qa.slot,\n qa.maxmark,\n qas.fraction * qa.maxmark as mark";
$lateststeps = $dm->load_questions_usages_latest_steps($qubaids, $this->stats->get_all_slots(), $fields);
$summarks = array();
if ($lateststeps) {
foreach ($lateststeps as $step) {
if (!isset($summarks[$step->questionusageid])) {
$summarks[$step->questionusageid] = 0;
}
$summarks[$step->questionusageid] += $step->mark;
}
}
return array($lateststeps, $summarks);
}
示例6: get_latest_steps
/**
* @param $qubaids \qubaid_condition
* @return array with three items
* - $lateststeps array of latest step data for the question usages
* - $summarks array of total marks for each usage, indexed by usage id
* - $summarksavg the average of the total marks over all the usages
*/
protected function get_latest_steps($qubaids)
{
$dm = new \question_engine_data_mapper();
$fields = " qas.id,\n qa.questionusageid,\n qa.questionid,\n qa.slot,\n qa.maxmark,\n qas.fraction * qa.maxmark as mark";
$lateststeps = $dm->load_questions_usages_latest_steps($qubaids, array_keys($this->questionstats), $fields);
$summarks = array();
if ($lateststeps) {
foreach ($lateststeps as $step) {
if (!isset($summarks[$step->questionusageid])) {
$summarks[$step->questionusageid] = 0;
}
$summarks[$step->questionusageid] += $step->mark;
}
$summarksavg = array_sum($summarks) / count($summarks);
} else {
$summarksavg = null;
}
return array($lateststeps, $summarks, $summarksavg);
}