本文整理汇总了PHP中question_engine_data_mapper::question_attempt_latest_state_view方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine_data_mapper::question_attempt_latest_state_view方法的具体用法?PHP question_engine_data_mapper::question_attempt_latest_state_view怎么用?PHP question_engine_data_mapper::question_attempt_latest_state_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_engine_data_mapper
的用法示例。
在下文中一共展示了question_engine_data_mapper::question_attempt_latest_state_view方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dotest_question_attempt_latest_state_view
protected function dotest_question_attempt_latest_state_view() {
global $DB;
list($inlineview, $viewparams) = $this->dm->question_attempt_latest_state_view(
'lateststate', $this->bothusages);
$rawstates = $DB->get_records_sql("
SELECT lateststate.questionattemptid,
qu.id AS questionusageid,
lateststate.slot,
lateststate.questionid,
lateststate.maxmark,
lateststate.sequencenumber,
lateststate.state
FROM {question_usages} qu
LEFT JOIN $inlineview ON lateststate.questionusageid = qu.id
WHERE qu.id IN ({$this->usageids[0]}, {$this->usageids[1]})", $viewparams);
$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);
}
示例2: add_latest_state_join
/**
* Add the information about the latest state of the question with slot
* $slot to the query.
*
* The extra information is added as a join to a
* 'table' with alias qa$slot, with columns that are a union of
* the columns of the question_attempts and question_attempts_states tables.
*
* @param int $slot the question to add information for.
*/
protected function add_latest_state_join($slot) {
$alias = 'qa' . $slot;
$fields = $this->get_required_latest_state_fields($slot, $alias);
if (!$fields) {
return;
}
// This condition roughly filters the list of attempts to be considered.
// It is only used in a subselect to help crappy databases (see MDL-30122)
// therefore, it is better to use a very simple join, which may include
// too many records, than to do a super-accurate join.
$qubaids = new qubaid_join("{quiz_attempts} {$alias}quiza", "{$alias}quiza.uniqueid",
"{$alias}quiza.quiz = :{$alias}quizid", array("{$alias}quizid" => $this->sql->params['quizid']));
$dm = new question_engine_data_mapper();
list($inlineview, $viewparams) = $dm->question_attempt_latest_state_view($alias, $qubaids);
$this->sql->fields .= ",\n$fields";
$this->sql->from .= "\nLEFT JOIN $inlineview ON " .
"$alias.questionusageid = quiza.uniqueid AND $alias.slot = :{$alias}slot";
$this->sql->params[$alias . 'slot'] = $slot;
$this->sql->params = array_merge($this->sql->params, $viewparams);
}
示例3: add_latest_state_join
/**
* Add the information about the latest state of the question with slot
* $slot to the query.
*
* The extra information is added as a join to a
* 'table' with alias qa$slot, with columns that are a union of
* the columns of the question_attempts and question_attempts_states tables.
*
* @param int $slot the question to add information for.
*/
protected function add_latest_state_join($slot)
{
$alias = 'qa' . $slot;
$fields = $this->get_required_latest_state_fields($slot, $alias);
if (!$fields) {
return;
}
$dm = new question_engine_data_mapper();
$inlineview = $dm->question_attempt_latest_state_view($alias);
$this->sql->fields .= ",\n{$fields}";
$this->sql->from .= "\nLEFT JOIN {$inlineview} ON " . "{$alias}.questionusageid = quiza.uniqueid AND {$alias}.slot = :{$alias}slot";
$this->sql->params[$alias . 'slot'] = $slot;
}