Línea 15... |
Línea 15... |
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
Línea 16... |
Línea 16... |
16 |
|
16 |
|
Línea 17... |
Línea 17... |
17 |
namespace mod_quiz\question\bank;
|
17 |
namespace mod_quiz\question\bank;
|
- |
|
18 |
|
18 |
|
19 |
use context_module;
|
19 |
use context_module;
|
20 |
use core_question\local\bank\version_options;
|
20 |
use core_question\local\bank\question_version_status;
|
21 |
use core_question\local\bank\question_version_status;
|
21 |
use core_question\local\bank\random_question_loader;
|
22 |
use core_question\local\bank\random_question_loader;
|
22 |
use core_question\question_reference_manager;
|
23 |
use core_question\question_reference_manager;
|
Línea 44... |
Línea 45... |
44 |
*
|
45 |
*
|
45 |
* @param int $questionid id of a question.
|
46 |
* @param int $questionid id of a question.
|
46 |
* @return stdClass[] other versions of this question. Each object has fields versionid,
|
47 |
* @return stdClass[] other versions of this question. Each object has fields versionid,
|
47 |
* version and questionid. Array is returned most recent version first.
|
48 |
* version and questionid. Array is returned most recent version first.
|
48 |
*/
|
49 |
*/
|
- |
|
50 |
#[\core\attribute\deprecated(
|
- |
|
51 |
'core_question\local\bank::get_version_options',
|
- |
|
52 |
since: 5.0,
|
- |
|
53 |
mdl: 'MDL-77713')
|
- |
|
54 |
]
|
49 |
public static function get_version_options(int $questionid): array {
|
55 |
public static function get_version_options(int $questionid): array {
|
50 |
global $DB;
|
- |
|
51 |
|
- |
|
52 |
return $DB->get_records_sql("
|
- |
|
53 |
SELECT allversions.id AS versionid,
|
- |
|
54 |
allversions.version,
|
- |
|
55 |
allversions.questionid
|
- |
|
56 |
|
- |
|
57 |
FROM {question_versions} allversions
|
- |
|
58 |
|
- |
|
59 |
WHERE allversions.questionbankentryid = (
|
- |
|
60 |
SELECT givenversion.questionbankentryid
|
- |
|
61 |
FROM {question_versions} givenversion
|
56 |
\core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
|
62 |
WHERE givenversion.questionid = ?
|
57 |
return version_options::get_version_options($questionid);
|
63 |
)
|
- |
|
64 |
AND allversions.status <> ?
|
- |
|
65 |
|
- |
|
66 |
ORDER BY allversions.version DESC
|
- |
|
67 |
", [$questionid, question_version_status::QUESTION_STATUS_DRAFT]);
|
- |
|
68 |
}
|
58 |
}
|
Línea 69... |
Línea 59... |
69 |
|
59 |
|
70 |
/**
|
60 |
/**
|
71 |
* Get the information about which questions should be used to create a quiz attempt.
|
61 |
* Get the information about which questions should be used to create a quiz attempt.
|
Línea 83... |
Línea 73... |
83 |
* @param context_module $quizcontext the context of this quiz.
|
73 |
* @param context_module $quizcontext the context of this quiz.
|
84 |
* @param int|null $slotid optional, if passed only load the data for this one slot (if it is in this quiz).
|
74 |
* @param int|null $slotid optional, if passed only load the data for this one slot (if it is in this quiz).
|
85 |
* @return array indexed by slot, with information about the content of each slot.
|
75 |
* @return array indexed by slot, with information about the content of each slot.
|
86 |
*/
|
76 |
*/
|
87 |
public static function get_question_structure(int $quizid, context_module $quizcontext,
|
77 |
public static function get_question_structure(int $quizid, context_module $quizcontext,
|
88 |
int $slotid = null): array {
|
78 |
?int $slotid = null): array {
|
89 |
global $DB;
|
79 |
global $DB;
|
Línea 90... |
Línea 80... |
90 |
|
80 |
|
91 |
$params = [
|
81 |
$params = [
|
92 |
'draft' => question_version_status::QUESTION_STATUS_DRAFT,
|
82 |
'draft' => question_version_status::QUESTION_STATUS_DRAFT,
|
Línea 137... |
Línea 127... |
137 |
-- than we would like, but the simpler SQL did not work in Oracle 11.2.
|
127 |
-- than we would like, but the simpler SQL did not work in Oracle 11.2.
|
138 |
-- (It did work fine in Oracle 19.x, so once we have updated our min supported
|
128 |
-- (It did work fine in Oracle 19.x, so once we have updated our min supported
|
139 |
-- version we could consider digging the old code out of git history from
|
129 |
-- version we could consider digging the old code out of git history from
|
140 |
-- just before the commit that added this comment.
|
130 |
-- just before the commit that added this comment.
|
141 |
-- For relevant question_bank_entries, this gets the latest non-draft slot number.
|
131 |
-- For relevant question_bank_entries, this gets the latest non-draft slot number.
|
- |
|
132 |
-- TODO: Optimise the query, as Oracle-specific constraints no longer apply.
|
142 |
LEFT JOIN (
|
133 |
LEFT JOIN (
|
143 |
SELECT lv.questionbankentryid,
|
134 |
SELECT lv.questionbankentryid,
|
144 |
MAX(CASE WHEN lv.status <> :draft THEN lv.version END) AS usableversion,
|
135 |
MAX(CASE WHEN lv.status <> :draft THEN lv.version END) AS usableversion,
|
145 |
MAX(lv.version) AS anyversion
|
136 |
MAX(lv.version) AS anyversion
|
146 |
FROM {quiz_slots} lslot
|
137 |
FROM {quiz_slots} lslot
|
Línea 196... |
Línea 187... |
196 |
$slot->questiontext = ' ';
|
187 |
$slot->questiontext = ' ';
|
197 |
$slot->questiontextformat = FORMAT_HTML;
|
188 |
$slot->questiontextformat = FORMAT_HTML;
|
198 |
$slot->length = 1;
|
189 |
$slot->length = 1;
|
199 |
} else if (!\question_bank::qtype_exists($slot->qtype)) {
|
190 |
} else if (!\question_bank::qtype_exists($slot->qtype)) {
|
200 |
// Question of unknown type found in the database. Set to placeholder question types instead.
|
191 |
// Question of unknown type found in the database. Set to placeholder question types instead.
|
- |
|
192 |
$slot->originalqtype = $slot->qtype;
|
201 |
$slot->qtype = 'missingtype';
|
193 |
$slot->qtype = 'missingtype';
|
202 |
} else {
|
194 |
} else {
|
203 |
$slot->_partiallyloaded = 1;
|
195 |
$slot->_partiallyloaded = 1;
|
204 |
}
|
196 |
}
|
205 |
}
|
197 |
}
|