本文整理汇总了PHP中question_engine_data_mapper::load_questions_usages_where_question_in_state方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine_data_mapper::load_questions_usages_where_question_in_state方法的具体用法?PHP question_engine_data_mapper::load_questions_usages_where_question_in_state怎么用?PHP question_engine_data_mapper::load_questions_usages_where_question_in_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_engine_data_mapper
的用法示例。
在下文中一共展示了question_engine_data_mapper::load_questions_usages_where_question_in_state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dotest_load_questions_usages_where_question_in_state
protected function dotest_load_questions_usages_where_question_in_state() {
$this->assertEquals(
array(array($this->usageids[0], $this->usageids[1]), 2),
$this->dm->load_questions_usages_where_question_in_state($this->bothusages,
'all', $this->allslots[1], null, 'questionusageid'));
$this->assertEquals(
array(array($this->usageids[0], $this->usageids[1]), 2),
$this->dm->load_questions_usages_where_question_in_state($this->bothusages,
'autograded', $this->allslots[0], null, 'questionusageid'));
$this->assertEquals(
array(array($this->usageids[0]), 1),
$this->dm->load_questions_usages_where_question_in_state($this->bothusages,
'needsgrading', $this->allslots[1], null, 'questionusageid'));
}
示例2: get_usage_ids_where_question_in_state
/**
* Get a list of usage ids where the question with slot $slot, and optionally
* also with question id $questionid, is in summary state $summarystate. Also
* return the total count of such states.
*
* Only a subset of the ids can be returned by using $orderby, $limitfrom and
* $limitnum. A special value 'random' can be passed as $orderby, in which case
* $limitfrom is ignored.
*
* @param int $slot The slot for the questions you want to konw about.
* @param int $questionid (optional) Only return attempts that were of this specific question.
* @param string $summarystate 'all', 'needsgrading', 'autograded' or 'manuallygraded'.
* @param string $orderby 'random', 'date', 'student' or 'idnumber'.
* @param int $page implements paging of the results.
* Ignored if $orderby = random or $pagesize is null.
* @param int $pagesize implements paging of the results. null = all.
*/
protected function get_usage_ids_where_question_in_state($summarystate, $slot, $questionid = null, $orderby = 'random', $page = 0, $pagesize = null)
{
global $CFG, $DB;
$dm = new question_engine_data_mapper();
if ($pagesize && $orderby != 'random') {
$limitfrom = $page * $pagesize;
} else {
$limitfrom = 0;
}
$qubaids = $this->get_qubaids_condition();
$params = array();
if ($orderby == 'date') {
list($statetest, $params) = $dm->in_summary_state_test('manuallygraded', false, 'mangrstate');
$orderby = "(\n SELECT MAX(sortqas.timecreated)\n FROM {question_attempt_steps} sortqas\n WHERE sortqas.questionattemptid = qa.id\n AND sortqas.state {$statetest}\n )";
} else {
if ($orderby == 'studentfirstname' || $orderby == 'studentlastname' || $orderby == 'idnumber') {
$qubaids->from .= " JOIN {user} u ON quiza.userid = u.id ";
// For name sorting, map orderby form value to
// actual column names; 'idnumber' maps naturally
switch ($orderby) {
case "studentlastname":
$orderby = "u.lastname, u.firstname";
break;
case "studentfirstname":
$orderby = "u.firstname, u.lastname";
break;
}
}
}
return $dm->load_questions_usages_where_question_in_state($qubaids, $summarystate, $slot, $questionid, $orderby, $params, $limitfrom, $pagesize);
}
示例3: get_usage_ids_where_question_in_state
/**
* Get a list of usage ids where the question with slot $slot, and optionally
* also with question id $questionid, is in summary state $summarystate. Also
* return the total count of such states.
*
* Only a subset of the ids can be returned by using $orderby, $limitfrom and
* $limitnum. A special value 'random' can be passed as $orderby, in which case
* $limitfrom is ignored.
*
* @param int $slot The slot for the questions you want to konw about.
* @param int $questionid (optional) Only return attempts that were of this specific question.
* @param string $summarystate 'all', 'needsgrading', 'autograded' or 'manuallygraded'.
* @param string $orderby 'random', 'date', 'student' or 'idnumber'.
* @param int $page implements paging of the results.
* Ignored if $orderby = random or $pagesize is null.
* @param int $pagesize implements paging of the results. null = all.
*/
protected function get_usage_ids_where_question_in_state($summarystate, $slot,
$questionid = null, $orderby = 'random', $page = 0, $pagesize = null) {
global $CFG, $DB;
$dm = new question_engine_data_mapper();
if ($pagesize && $orderby != 'random') {
$limitfrom = $page * $pagesize;
} else {
$limitfrom = 0;
}
$qubaids = $this->get_qubaids_condition();
$params = array();
if ($orderby == 'date') {
list($statetest, $params) = $dm->in_summary_state_test(
'manuallygraded', false, 'mangrstate');
$orderby = "(
SELECT MAX(sortqas.timecreated)
FROM {question_attempt_steps} sortqas
WHERE sortqas.questionattemptid = qa.id
AND sortqas.state $statetest
)";
} else if ($orderby == 'student' || $orderby == 'idnumber') {
$qubaids->from .= " JOIN {user} u ON quiza.userid = u.id ";
if ($orderby == 'student') {
$orderby = $DB->sql_fullname('u.firstname', 'u.lastname');
}
}
return $dm->load_questions_usages_where_question_in_state($qubaids, $summarystate,
$slot, $questionid, $orderby, $params, $limitfrom, $pagesize);
}