MDL-71696 core_question: Implement question status change
This commit implements the status change pop up for a question in the base view. This feature update will allow the change of status of a question without creating a new version. This commit also implements the status as a char rather than an int value.
This commit is contained in:
+2
-2
@@ -42,8 +42,8 @@ $qtypes = question_bank::get_all_qtypes();
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$hiddenstatus = \core_question\local\bank\constants::QUESTION_STATUS_HIDDEN;
|
||||
$draftstatus = \core_question\local\bank\constants::QUESTION_STATUS_DRAFT;
|
||||
$hiddenstatus = \core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN;
|
||||
$draftstatus = \core_question\local\bank\question_version_status::QUESTION_STATUS_DRAFT;
|
||||
|
||||
$sql = "SELECT result.qtype,
|
||||
SUM(result.numquestions) AS numquestions,
|
||||
|
||||
@@ -4905,7 +4905,11 @@ class restore_create_categories_and_questions extends restore_structure_step {
|
||||
$versiondata->version = 1;
|
||||
// Question id is updated after inserting the question.
|
||||
$versiondata->questionid = 0;
|
||||
$versiondata->status = $data->hidden;
|
||||
$versionstatus = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
if ((int)$data->hidden === 1) {
|
||||
$versionstatus = \core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN;
|
||||
}
|
||||
$versiondata->status = $versionstatus;
|
||||
$newversionid = $DB->insert_record('question_versions', $versiondata);
|
||||
$this->set_mapping('question_version_created', $oldid, $newversionid);
|
||||
}
|
||||
|
||||
+17
-8
@@ -2003,7 +2003,7 @@ function core_question_find_next_unused_idnumber(?string $oldidnumber, int $cate
|
||||
/**
|
||||
* Get the question_bank_entry object given a question id.
|
||||
*
|
||||
* @param $questionid int Question id.
|
||||
* @param int $questionid Question id.
|
||||
* @return false|mixed
|
||||
* @throws dml_exception
|
||||
*/
|
||||
@@ -2024,7 +2024,7 @@ function get_question_bank_entry(int $questionid): object {
|
||||
/**
|
||||
* Get the question versions given a question id in a descending sort .
|
||||
*
|
||||
* @param $questionid int Question id.
|
||||
* @param int $questionid Question id.
|
||||
* @return array
|
||||
* @throws dml_exception
|
||||
*/
|
||||
@@ -2040,7 +2040,7 @@ function get_question_version($questionid): array {
|
||||
/**
|
||||
* Get the next version number to create base on a Question bank entry id.
|
||||
*
|
||||
* @param $questionbankentryid int Question bank entry id.
|
||||
* @param int $questionbankentryid Question bank entry id.
|
||||
* @return int next version number.
|
||||
* @throws dml_exception
|
||||
*/
|
||||
@@ -2109,7 +2109,9 @@ function question_preview_url($questionid, $preferredbehaviour = null,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array that can be passed as $params to the {@link popup_action} constructor.
|
||||
* Popup params for the question preview.
|
||||
*
|
||||
* @return array that can be passed as $params to the {@see popup_action()} constructor.
|
||||
* @deprecated since Moodle 4.0
|
||||
* @see qbank_previewquestion\previewquestion_helper::question_preview_popup_params()
|
||||
* @todo Final deprecation on Moodle 4.4 MDL-72438
|
||||
@@ -2146,7 +2148,7 @@ function question_hash($question) {
|
||||
* @param string $withcategories
|
||||
* @param string $withcontexts
|
||||
* @param string $filename
|
||||
* @param moodle_url export file url
|
||||
* @return moodle_url export file url
|
||||
* @deprecated since Moodle 4.0 MDL-71573
|
||||
* @see qbank_exportquestions\exportquestions_helper
|
||||
* @todo Final deprecation on Moodle 4.4 MDL-72438
|
||||
@@ -2218,6 +2220,7 @@ function question_remove_stale_questions_from_category($categoryid) {
|
||||
* performance only. It is not modfied.
|
||||
* @param int $id the category to start the indenting process from.
|
||||
* @param int $depth the indent depth. Used in recursive calls.
|
||||
* @param int $nochildrenof
|
||||
* @return array a new array of categories, in the right order for the tree.
|
||||
* @deprecated since Moodle 4.0 MDL-71585
|
||||
* @see qbank_managecategories\helper
|
||||
@@ -2233,6 +2236,7 @@ function flatten_category_tree(&$categories, $id, $depth = 0, $nochildrenof = -1
|
||||
* Format categories into an indented list reflecting the tree structure.
|
||||
*
|
||||
* @param array $categories An array of category objects, for example from the.
|
||||
* @param int $nochildrenof
|
||||
* @return array The formatted list of categories.
|
||||
* @deprecated since Moodle 4.0 MDL-71585
|
||||
* @see qbank_managecategories\helper
|
||||
@@ -2249,11 +2253,12 @@ function add_indented_names($categories, $nochildrenof = -1) {
|
||||
* Categories from this course and (optionally) published categories from other courses
|
||||
* are included. Optionally, only categories the current user may edit can be included.
|
||||
*
|
||||
* @param integer $courseid the id of the course to get the categories for.
|
||||
* @param integer $published if true, include publised categories from other courses.
|
||||
* @param integer $only_editable if true, exclude categories this user is not allowed to edit.
|
||||
* @param array $contexts
|
||||
* @param bool $top
|
||||
* @param int $currentcat
|
||||
* @param integer $selected optionally, the id of a category to be selected by
|
||||
* default in the dropdown.
|
||||
* @param int $nochildrenof
|
||||
* @deprecated since Moodle 4.0 MDL-71585
|
||||
* @see qbank_managecategories\helper
|
||||
* @todo Final deprecation on Moodle 4.4 MDL-72438
|
||||
@@ -2306,6 +2311,10 @@ function question_category_options($contexts, $top = false, $currentcat = 0,
|
||||
}
|
||||
|
||||
/**
|
||||
* Add context in categories key.
|
||||
*
|
||||
* @param array $categories The list of categories.
|
||||
* @return array
|
||||
* @deprecated since Moodle 4.0 MDL-71585
|
||||
* @see qbank_managecategories\helper
|
||||
* @todo Final deprecation on Moodle 4.4 MDL-72438
|
||||
|
||||
@@ -116,7 +116,7 @@ class core_questionlib_testcase extends advanced_testcase {
|
||||
* @param int $numberofquestions Number of question in a category.
|
||||
* @return void Questions in a category.
|
||||
*/
|
||||
function assert_category_contains_questions(int $categoryid, int $numberofquestions): void {
|
||||
protected function assert_category_contains_questions(int $categoryid, int $numberofquestions): void {
|
||||
$questionsid = question_bank::get_finder()->get_questions_from_categories([$categoryid], null);
|
||||
$this->assertEquals($numberofquestions, count($questionsid));
|
||||
}
|
||||
@@ -268,10 +268,13 @@ class core_questionlib_testcase extends advanced_testcase {
|
||||
|
||||
// Check that there are two questions in the restored to course's context.
|
||||
$this->assertEquals(2, $DB->get_record_sql('SELECT COUNT(q.id) as questioncount
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv ON qv.questionid = q.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
|
||||
WHERE qbe.questioncategoryid = ?', [$restoredcategory->id])->questioncount);
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv
|
||||
ON qv.questionid = q.id
|
||||
JOIN {question_bank_entries} qbe
|
||||
ON qbe.id = qv.questionbankentryid
|
||||
WHERE qbe.questioncategoryid = ?',
|
||||
[$restoredcategory->id])->questioncount);
|
||||
$rc->destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
define ("mod_quiz/question_slot",["exports","core/ajax","core/notification"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;c=function(a){return a&&a.__esModule?a:{default:a}}(c);var d=function(a,c){return(0,b.call)([{methodname:"mod_quiz_set_question_version",args:{slotid:a,newversion:c}}])[0]},e=function(){document.addEventListener("change",function(a){if(!a.target.matches("[data-action=\"mod_quiz-select_slot\"][data-slot-id]")){return}var b=a.target.dataset.slotId,e=parseInt(a.target.value);d(b,e).then(function(){location.reload()}).catch(c.default.exception)})};a.init=function init(){if(!1){return}e()}});
|
||||
//# sourceMappingURL=question_slot.min.js.map
|
||||
{"version":3,"sources":["../src/question_slot.js"],"names":["setQuestionVersion","slotId","newVersion","methodname","args","slotid","newversion","registerEventListeners","document","addEventListener","e","target","matches","dataset","parseInt","value","then","location","reload","catch","Notification","exception","init"],"mappings":"yKAyBA,uD,GASMA,CAAAA,CAAkB,CAAG,SAACC,CAAD,CAASC,CAAT,QAAwB,WAAU,CAAC,CAC1DC,UAAU,CAAE,+BAD8C,CAE1DC,IAAI,CAAE,CACFC,MAAM,CAAEJ,CADN,CAEFK,UAAU,CAAEJ,CAFV,CAFoD,CAAD,CAAV,EAM/C,CAN+C,CAAxB,C,CAWrBK,CAAsB,CAAG,UAAM,CACjCC,QAAQ,CAACC,gBAAT,CAA0B,QAA1B,CAAoC,SAAAC,CAAC,CAAI,CACrC,GAAI,CAACA,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiB,sDAAjB,CAAL,CAA6E,CACzE,MACH,CAHoC,GAK/BX,CAAAA,CAAM,CAAGS,CAAC,CAACC,MAAF,CAASE,OAAT,CAAiBZ,MALK,CAM/BC,CAAU,CAAGY,QAAQ,CAACJ,CAAC,CAACC,MAAF,CAASI,KAAV,CANU,CAQrCf,CAAkB,CAACC,CAAD,CAASC,CAAT,CAAlB,CACKc,IADL,CACU,UAAM,CACRC,QAAQ,CAACC,MAAT,EAEH,CAJL,EAKKC,KALL,CAKWC,UAAaC,SALxB,CAMH,CAdD,CAeH,C,QAQmB,QAAPC,CAAAA,IAAO,EAAM,CACtB,MAAsB,CAClB,MACH,CAEDf,CAAsB,EACzB,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Render the question slot template for each question in the quiz edit view.\n *\n * @module mod_quiz/question_slot\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Guillermo Gomez Arias <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {call as fetchMany} from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Set the question version for the slot.\n *\n * @param {Number} slotId\n * @param {Number} newVersion\n * @return {Array} The modified question version\n */\nconst setQuestionVersion = (slotId, newVersion) => fetchMany([{\n methodname: 'mod_quiz_set_question_version',\n args: {\n slotid: slotId,\n newversion: newVersion,\n }\n}])[0];\n\n/**\n * Replace the container with a new version.\n */\nconst registerEventListeners = () => {\n document.addEventListener('change', e => {\n if (!e.target.matches('[data-action=\"mod_quiz-select_slot\"][data-slot-id]')) {\n return;\n }\n\n const slotId = e.target.dataset.slotId;\n const newVersion = parseInt(e.target.value);\n\n setQuestionVersion(slotId, newVersion)\n .then(() => {\n location.reload();\n return;\n })\n .catch(Notification.exception);\n });\n};\n\n/** @property {Boolean} eventsRegistered If the event has been registered or not */\nlet eventsRegistered = false;\n\n/**\n * Entrypoint of the js.\n */\nexport const init = () => {\n if (eventsRegistered) {\n return;\n }\n\n registerEventListeners();\n};\n"],"file":"question_slot.min.js"}
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* Render the question slot template for each question in the quiz edit view.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @module mod_quiz/question_slot
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Guillermo Gomez Arias <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
|
||||
@@ -1798,7 +1798,7 @@ class quiz_attempt {
|
||||
$question->length = $replacedquestion->length;
|
||||
$question->penalty = 0;
|
||||
$question->stamp = '';
|
||||
$question->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$question->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$question->timecreated = null;
|
||||
$question->timemodified = null;
|
||||
$question->createdby = null;
|
||||
|
||||
@@ -57,7 +57,7 @@ class mod_quiz_local_structure_slot_random_test extends advanced_testcase {
|
||||
$form->includesubcategories = true;
|
||||
$form->fromtags = [];
|
||||
$form->defaultmark = 1;
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_HIDDEN;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN;
|
||||
$form->stamp = make_unique_id_code();
|
||||
|
||||
// Set the filter conditions.
|
||||
@@ -371,7 +371,7 @@ class mod_quiz_local_structure_slot_random_test extends advanced_testcase {
|
||||
$form->includesubcategories = true;
|
||||
$form->fromtags = [];
|
||||
$form->defaultmark = 1;
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_HIDDEN;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN;
|
||||
$form->stamp = make_unique_id_code();
|
||||
|
||||
// Prepare 2 tags.
|
||||
|
||||
@@ -39,7 +39,7 @@ class helper {
|
||||
$sql = "SELECT q.*, c.contextid
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv ON qv.questionid = q.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
|
||||
JOIN {question_categories} c ON c.id = qbe.questioncategoryid
|
||||
WHERE q.id
|
||||
{$usql}";
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace qbank_deletequestion;
|
||||
|
||||
use core_question\local\bank\constants;
|
||||
use core_question\local\bank\question_version_status;
|
||||
use core_question\local\bank\menu_action_column_base;
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ class delete_action_column extends menu_action_column_base {
|
||||
if (!question_has_capability_on($question, 'edit')) {
|
||||
return [null, null, null];
|
||||
}
|
||||
if ((int) $question->status === constants::QUESTION_STATUS_HIDDEN) {
|
||||
if ($question->status === question_version_status::QUESTION_STATUS_HIDDEN) {
|
||||
$hiddenparams = array(
|
||||
'unhide' => $question->id,
|
||||
'sesskey' => sesskey());
|
||||
|
||||
@@ -62,7 +62,8 @@ $PAGE->set_heading($COURSE->fullname);
|
||||
// Unhide a question.
|
||||
if (($unhide = optional_param('unhide', '', PARAM_INT)) and confirm_sesskey()) {
|
||||
question_require_capability_on($unhide, 'edit');
|
||||
$DB->set_field('question_versions', 'status', 0, ['questionid' => $unhide]);
|
||||
$DB->set_field('question_versions', 'status',
|
||||
\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, ['questionid' => $unhide]);
|
||||
|
||||
// Purge these questions from the cache.
|
||||
\question_bank::notify_question_edited($unhide);
|
||||
@@ -81,7 +82,8 @@ if ($deleteselected && ($confirm = optional_param('confirm', '', PARAM_ALPHANUM)
|
||||
$questionid = (int)$questionid;
|
||||
question_require_capability_on($questionid, 'edit');
|
||||
if (questions_in_use(array($questionid))) {
|
||||
$DB->set_field('question_versions', 'status', 1, ['questionid' => $questionid]);
|
||||
$DB->set_field('question_versions', 'status',
|
||||
\core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN, ['questionid' => $questionid]);
|
||||
} else {
|
||||
question_delete_question($questionid);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("qbank_editquestion/question_status",["exports","core/fragment","core/str","core/modal_factory","core/notification","core/modal_events","core/ajax"],function(a,b,c,d,e,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=j(b);c=i(c);d=j(d);e=j(e);f=j(f);g=j(g);function h(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;h=function(){return a};return a}function i(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=h();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function j(a){return a&&a.__esModule?a:{default:a}}var k=function(a,c){return b.default.loadFragment("qbank_editquestion","question_status",c,a)},l=function(a,b){return g.default.call([{methodname:"qbank_editquestion_set_status",args:{questionid:a,formdata:b}}])[0]},m=function(a,b,c){var d=a.getBody().find("form").serialize();l(b,d).then(function(a){if(a.status){c.innerText=a.statusname}}).catch(e.default.exception)},n=function(a,b,c){o({questionid:a},b).then(function(b){b.show();var d=b.getRoot();d.on(f.default.save,function(d){d.preventDefault();d.stopPropagation();m(b,a,c);b.hide()});return b}).catch(e.default.exception)},o=function(a,b){return d.default.create({type:d.default.types.SAVE_CANCEL,title:c.get_string("questionstatusheader","qbank_editquestion"),body:k(a,b),large:!1})};a.init=function init(a,b){var c=document.querySelector(a),d=c.getAttribute("data-questionid");c.addEventListener("click",function(){n(d,b,c)})}});
|
||||
//# sourceMappingURL=question_status.min.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,135 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Status column selector js.
|
||||
*
|
||||
* @module qbank_editquestion/question_status
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Fragment from 'core/fragment';
|
||||
import * as Str from 'core/str';
|
||||
import ModalFactory from 'core/modal_factory';
|
||||
import Notification from 'core/notification';
|
||||
import ModalEvents from 'core/modal_events';
|
||||
import Ajax from 'core/ajax';
|
||||
|
||||
/**
|
||||
* Get the fragment.
|
||||
*
|
||||
* @method getFragment
|
||||
* @param {{questioned: Number}} args
|
||||
* @param {Number} contextId
|
||||
* @return {String}
|
||||
*/
|
||||
const getFragment = (args, contextId) => {
|
||||
return Fragment.loadFragment('qbank_editquestion', 'question_status', contextId, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the question status.
|
||||
*
|
||||
* @param {Number} questionId The question id.
|
||||
* @param {String} formData The question tag form data in a URI encoded param string
|
||||
* @return {Array} The modified question status
|
||||
*/
|
||||
const setQuestionStatus = (questionId, formData) => Ajax.call([{
|
||||
methodname: 'qbank_editquestion_set_status',
|
||||
args: {
|
||||
questionid: questionId,
|
||||
formdata: formData
|
||||
}
|
||||
}])[0];
|
||||
|
||||
/**
|
||||
* Save the status.
|
||||
*
|
||||
* @method getFragment
|
||||
* @param {object} modal
|
||||
* @param {Number} questionId
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
const save = (modal, questionId, target) => {
|
||||
const formData = modal.getBody().find('form').serialize();
|
||||
|
||||
setQuestionStatus(questionId, formData)
|
||||
.then(result => {
|
||||
if (result.status) {
|
||||
target.innerText = result.statusname;
|
||||
}
|
||||
return;
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listeners for the module.
|
||||
*
|
||||
* @method clickEvent
|
||||
* @param {Number} questionId
|
||||
* @param {Number} contextId
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
const statusEvent = (questionId, contextId, target) => {
|
||||
let args = {
|
||||
questionid: questionId
|
||||
};
|
||||
getStatusModal(args, contextId)
|
||||
.then((modal) => {
|
||||
modal.show();
|
||||
let root = modal.getRoot();
|
||||
root.on(ModalEvents.save, function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
save(modal, questionId, target);
|
||||
modal.hide();
|
||||
});
|
||||
return modal;
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the status modal to display.
|
||||
*
|
||||
* @param {{questionid: Number}} args
|
||||
* @param {Number} contextId
|
||||
* @return {HTMLElement}
|
||||
*/
|
||||
const getStatusModal = (args, contextId) => ModalFactory.create({
|
||||
type: ModalFactory.types.SAVE_CANCEL,
|
||||
title: Str.get_string('questionstatusheader', 'qbank_editquestion'),
|
||||
body: getFragment(args, contextId),
|
||||
large: false,
|
||||
});
|
||||
|
||||
/**
|
||||
* Entrypoint of the js.
|
||||
*
|
||||
* @method init
|
||||
* @param {String} questionSelector the question status identifier.
|
||||
* @param {Number} contextId The context id of the question.
|
||||
*/
|
||||
export const init = (questionSelector, contextId) => {
|
||||
let target = document.querySelector(questionSelector);
|
||||
let questionId = target.getAttribute('data-questionid');
|
||||
target.addEventListener('click', () => {
|
||||
// Call for the event listener to listed for clicks in any usage count row.
|
||||
statusEvent(questionId, contextId, target);
|
||||
});
|
||||
};
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace qbank_editquestion;
|
||||
|
||||
use core_question\local\bank\constants;
|
||||
use core_question\local\bank\question_version_status;
|
||||
|
||||
/**
|
||||
* Class editquestion_helper for methods related to add/edit/copy
|
||||
@@ -89,20 +89,11 @@ class editquestion_helper {
|
||||
/**
|
||||
* Get the string for the status of the question.
|
||||
*
|
||||
* @param int $status
|
||||
* @param string $status
|
||||
* @return string
|
||||
*/
|
||||
public static function get_question_status_string($status): string {
|
||||
if ((int)$status == constants::QUESTION_STATUS_READY) {
|
||||
$statusstring = get_string('questionstatusready', 'qbank_editquestion');
|
||||
} else if ((int)$status == constants::QUESTION_STATUS_HIDDEN) {
|
||||
$statusstring = get_string('questionstatushidden', 'qbank_editquestion');
|
||||
} else if ((int)$status == constants::QUESTION_STATUS_DRAFT) {
|
||||
$statusstring = get_string('questionstatusdraft', 'qbank_editquestion');
|
||||
} else {
|
||||
$statusstring = get_string('questionstatusunknown', 'qbank_editquestion');
|
||||
}
|
||||
return $statusstring;
|
||||
return get_string('questionstatus' . $status, 'qbank_editquestion');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,8 +103,8 @@ class editquestion_helper {
|
||||
*/
|
||||
public static function get_question_status_list(): array {
|
||||
$statuslist = [];
|
||||
$statuslist[constants::QUESTION_STATUS_READY] = get_string('questionstatusready', 'qbank_editquestion');
|
||||
$statuslist[constants::QUESTION_STATUS_DRAFT] = get_string('questionstatusdraft', 'qbank_editquestion');
|
||||
$statuslist[question_version_status::QUESTION_STATUS_READY] = get_string('questionstatusready', 'qbank_editquestion');
|
||||
$statuslist[question_version_status::QUESTION_STATUS_DRAFT] = get_string('questionstatusdraft', 'qbank_editquestion');
|
||||
return $statuslist;
|
||||
}
|
||||
|
||||
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qbank_editquestion\external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/externallib.php');
|
||||
require_once($CFG->dirroot . '/question/engine/bank.php');
|
||||
|
||||
use external_api;
|
||||
use external_function_parameters;
|
||||
use external_single_structure;
|
||||
use external_value;
|
||||
use qbank_editquestion\editquestion_helper;
|
||||
use question_bank;
|
||||
|
||||
/**
|
||||
* Update question status external api.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class update_question_version_status extends \external_api {
|
||||
|
||||
/**
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
* @return external_function_parameters.
|
||||
*/
|
||||
public static function execute_parameters() {
|
||||
return new external_function_parameters([
|
||||
'questionid' => new external_value(PARAM_INT, 'The question id'),
|
||||
'formdata' => new external_value(PARAM_RAW, 'The data from the status form'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the status form submission.
|
||||
*
|
||||
* @param int $questionid The question id.
|
||||
* @param string $formdata The question tag form data in a URI encoded param string
|
||||
* @return array The created or modified question tag
|
||||
*/
|
||||
public static function execute($questionid, $formdata) {
|
||||
global $DB;
|
||||
|
||||
$data = [];
|
||||
$result = [
|
||||
'status' => false,
|
||||
'statusname' => ''
|
||||
];
|
||||
|
||||
// Parameter validation.
|
||||
$params = self::validate_parameters(self::execute_parameters(), [
|
||||
'questionid' => $questionid,
|
||||
'formdata' => $formdata
|
||||
]);
|
||||
|
||||
parse_str($params['formdata'], $data);
|
||||
|
||||
$question = question_bank::load_question($params['questionid']);
|
||||
$editingcontext = \context::instance_by_id($question->contextid);
|
||||
self::validate_context($editingcontext);
|
||||
$canedit = question_has_capability_on($question, 'edit');
|
||||
$mform = new \qbank_editquestion\form\question_status_form(null, null, 'post', '', null, $canedit, $data);
|
||||
if ($validateddata = $mform->get_data()) {
|
||||
if ($canedit && isset($validateddata->status)) {
|
||||
$versionrecord = $DB->get_record('question_versions', ['questionid' => $params['questionid']]);
|
||||
$versionrecord->status = $validateddata->status;
|
||||
$DB->update_record('question_versions', $versionrecord);
|
||||
question_bank::notify_question_edited($question->id);
|
||||
$result = [
|
||||
'status' => true,
|
||||
'statusname' => editquestion_helper::get_question_status_string($versionrecord->status)
|
||||
];
|
||||
$event = \core\event\question_updated::create_from_question_instance($question, $editingcontext);
|
||||
$event->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value.
|
||||
*/
|
||||
public static function execute_returns() {
|
||||
return new external_single_structure([
|
||||
'status' => new external_value(PARAM_BOOL, 'status: true if success'),
|
||||
'statusname' => new external_value(PARAM_RAW, 'statusname: name of the status')
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qbank_editquestion\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/lib/formslib.php');
|
||||
|
||||
/**
|
||||
* Class question_status_form to change the question status using a modal.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class question_status_form extends \moodleform {
|
||||
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
$mform->disable_form_change_checker();
|
||||
$mform->addElement('select', 'status', get_string('status', 'qbank_editquestion'),
|
||||
\qbank_editquestion\editquestion_helper::get_question_status_list());
|
||||
}
|
||||
}
|
||||
@@ -14,23 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* A column to show the status of the question.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qbank_editquestion;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core_question\local\bank\column_base;
|
||||
use core_question\local\bank\question_version_status;
|
||||
|
||||
/**
|
||||
* Class question_status_column.
|
||||
* A column to show the status of the question.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
@@ -48,9 +38,22 @@ class question_status_column extends column_base {
|
||||
}
|
||||
|
||||
protected function display_content($question, $rowclasses): void {
|
||||
global $DB;
|
||||
$version = $DB->get_record('question_versions', ['questionid' => $question->id], 'status');
|
||||
echo \html_writer::tag('a', editquestion_helper::get_question_status_string($version->status));
|
||||
global $PAGE;
|
||||
$attributes = [];
|
||||
if (question_has_capability_on($question, 'edit')
|
||||
&& $question->status !== question_version_status::QUESTION_STATUS_HIDDEN) {
|
||||
$target = 'questionstatus_' . $question->id;
|
||||
$datatarget = '[data-target="' . $target . '"]';
|
||||
$PAGE->requires->js_call_amd('qbank_editquestion/question_status', 'init', [$datatarget, $question->contextid]);
|
||||
$attributes = [
|
||||
'data-target' => $target,
|
||||
'data-questionid' => $question->id,
|
||||
'data-courseid' => $this->qbank->course->id,
|
||||
'class' => 'link-primary comment-pointer',
|
||||
'href' => '#'
|
||||
];
|
||||
}
|
||||
echo \html_writer::tag('a', editquestion_helper::get_question_status_string($question->status), $attributes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External services definition for qbank_editquestion.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$functions = [
|
||||
'qbank_editquestion_set_status' => [
|
||||
'classname' => 'qbank_editquestion\external\update_question_version_status',
|
||||
'description' => 'Update the question status.',
|
||||
'type' => 'write',
|
||||
'ajax' => true,
|
||||
],
|
||||
];
|
||||
@@ -31,7 +31,7 @@ $string['questionstatus'] = 'Status';
|
||||
$string['questionstatusready'] = 'Ready';
|
||||
$string['questionstatushidden'] = 'Hidden';
|
||||
$string['questionstatusdraft'] = 'Draft';
|
||||
$string['questionstatusunknown'] = 'Unknown';
|
||||
$string['questionstatusheader'] = 'Change question status';
|
||||
|
||||
// Edit form.
|
||||
$string['versioninfo'] = 'Version';
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Helper functions and callbacks.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Question status fragment callback.
|
||||
*
|
||||
* @param array $args
|
||||
* @return string rendered output
|
||||
*/
|
||||
function qbank_editquestion_output_fragment_question_status($args): string {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/engine/bank.php');
|
||||
$question = question_bank::load_question($args['questionid']);
|
||||
$mform = new \qbank_editquestion\form\question_status_form();
|
||||
$data = ['status' => $question->status];
|
||||
$mform->set_data($data);
|
||||
|
||||
return $mform->render();
|
||||
}
|
||||
@@ -218,7 +218,7 @@ if (isset($question->id)) {
|
||||
$toform->status = $questionobject->status;
|
||||
$toform->idnumber = $questionobject->idnumber;
|
||||
} else {
|
||||
$toform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$toform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
}
|
||||
if ($makecopy) {
|
||||
$toform->idnumber = core_question_find_next_unused_idnumber($toform->idnumber, $category->id);
|
||||
@@ -249,7 +249,8 @@ if ($mform->is_cancelled()) {
|
||||
// If we are saving as a copy, break the connection to the old question.
|
||||
if ($makecopy) {
|
||||
$question->id = 0;
|
||||
$question->status = \core_question\local\bank\constants::QUESTION_STATUS_READY; // Copies should not be hidden.
|
||||
// Copies should not be hidden.
|
||||
$question->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
}
|
||||
|
||||
// If is will be added directly to a module send the module name to be referenced.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
{
|
||||
"elements": [
|
||||
{"pluginhtml":"<div>Version: 1</div>"},
|
||||
{"pluginhtml":"<div>Usage: 1</div>"},
|
||||
{"pluginhtml":"<div>Usage: 1</div>"}
|
||||
]
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
|
||||
require_once(__DIR__ . '/../../../../tests/behat/behat_question_base.php');
|
||||
|
||||
use Behat\Mink\Exception\ExpectationException as ExpectationException,
|
||||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
|
||||
/**
|
||||
* Steps definitions to deal with the usage in question.
|
||||
*
|
||||
* @package qbank_usage
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_qbank_editquestion extends behat_question_base {
|
||||
|
||||
/**
|
||||
* Looks for a table, then looks for a row that contains the given text.
|
||||
* Once it finds the right row, it clicks a link in that row.
|
||||
*
|
||||
* @When I click :arg1 on the status column
|
||||
* @param string $linkname
|
||||
*/
|
||||
public function i_click_on_the_status_column($linkname) {
|
||||
$exception = new ElementNotFoundException($this->getSession(),
|
||||
'Cannot find any row on the page containing the text ' . $linkname);
|
||||
$row = $this->find('css', sprintf('table tbody tr td.questionstatus a:contains("%s")', $linkname), $exception);
|
||||
$row->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for the appropriate usage count in the column.
|
||||
*
|
||||
* @Then I should see :arg1 on the status column
|
||||
* @param string $linkdata
|
||||
*/
|
||||
public function i_should_see_on_the_status_column($linkdata) {
|
||||
$exception = new ElementNotFoundException($this->getSession(),
|
||||
'Cannot find any row with the usage count of ' . $linkdata . ' on the column named Status');
|
||||
$this->find('css', sprintf('table tbody tr td.questionstatus a:contains("%s")', $linkdata), $exception);
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,9 @@ Feature: Use the qbank base view to test the status change using
|
||||
And I navigate to "Question bank > Questions" in current page administration
|
||||
And I set the field "Select a category" to "Test questions"
|
||||
And I should see "Test questions"
|
||||
And I should see "Ready" on the status column
|
||||
When I click "Ready" on the status column
|
||||
And I should see "Ready" in the "First question" "table_row"
|
||||
When I click on "Ready" "link" in the "First question" "table_row"
|
||||
Then I should see "Change question status"
|
||||
And I should see "Question status"
|
||||
And I click on "Close" "button" in the ".modal-dialog" "css_element"
|
||||
And I should see "Ready" on the status column
|
||||
And I should see "Ready" in the "First question" "table_row"
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qbank_editquestion;
|
||||
|
||||
use qbank_editquestion\external\update_question_version_status;
|
||||
|
||||
/**
|
||||
* Submit status external api test.
|
||||
*
|
||||
* @package qbank_editquestion
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @coversDefaultClass \core_question\local\bank\question_version_status
|
||||
* @coversDefaultClass \qbank_editquestion\form\question_status_form
|
||||
* @coversDefaultClass \qbank_editquestion\editquestion_helper
|
||||
*/
|
||||
class update_question_version_status_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Called before every test.
|
||||
*/
|
||||
public function setUp(): void {
|
||||
global $USER;
|
||||
parent::setUp();
|
||||
$this->setAdminUser();
|
||||
$this->course = $this->getDataGenerator()->create_course();
|
||||
$this->user = $USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the submit status webservice changes the status of the question.
|
||||
*
|
||||
* @covers ::mock_generate_submit_keys
|
||||
* @covers ::execute
|
||||
* @covers ::get_question_status_string
|
||||
*/
|
||||
public function test_submit_status_updates_the_question_status() {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $questiongenerator->create_question_category();
|
||||
$numq = $questiongenerator->create_question('essay', null,
|
||||
['category' => $cat->id, 'name' => 'This is the first version']);
|
||||
$data = ['status' => 2];
|
||||
$mform = \qbank_editquestion\form\question_status_form::mock_generate_submit_keys($data);
|
||||
$this->expectException('moodle_exception');
|
||||
list($result, $statusname) = update_question_version_status::execute($numq->id, http_build_query($mform, '', '&'));
|
||||
// Test if the version actually changed.
|
||||
$currentstatus = $DB->get_record('question_versions', ['questionid' => $numq->id]);
|
||||
$this->assertEquals($data['status'], $currentstatus->status);
|
||||
$this->assertEquals(editquestion_helper::get_question_status_string($currentstatus->status), $statusname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that updating the status does not create a new version.
|
||||
*
|
||||
* @covers ::mock_generate_submit_keys
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function test_submit_status_does_not_create_a_new_version() {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $questiongenerator->create_question_category();
|
||||
$numq = $questiongenerator->create_question('essay', null,
|
||||
['category' => $cat->id, 'name' => 'This is the first version']);
|
||||
$countcurrentrecords = $DB->count_records('question_versions');
|
||||
$this->assertEquals(1, $countcurrentrecords);
|
||||
$data = ['status' => 2];
|
||||
$mform = \qbank_editquestion\form\question_status_form::mock_generate_submit_keys($data);
|
||||
$this->expectException('moodle_exception');
|
||||
list($result, $statusname) = update_question_version_status::execute($numq->id, http_build_query($mform, '', '&'));
|
||||
$countafterupdate = $DB->count_records('question_versions');
|
||||
$this->assertEquals($countcurrentrecords, $countafterupdate);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = 'qbank_editquestion';
|
||||
$plugin->version = 2021062800;
|
||||
$plugin->version = 2021110800;
|
||||
$plugin->requires = 2021052500;
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
namespace qbank_managecategories;
|
||||
|
||||
use context;
|
||||
use core_question\local\bank\constants;
|
||||
use core_question\local\bank\question_version_status;
|
||||
use moodle_exception;
|
||||
use html_writer;
|
||||
|
||||
@@ -61,14 +61,14 @@ class helper {
|
||||
public static function question_remove_stale_questions_from_category(int $categoryid): void {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT q.id
|
||||
$sql = "SELECT q.id
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv ON qv.questionid = q.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
|
||||
WHERE qbe.questioncategoryid = :categoryid
|
||||
AND (q.qtype = :qtype OR qv.status = :status)';
|
||||
AND (q.qtype = :qtype OR qv.status = :status)";
|
||||
|
||||
$params = ['categoryid' => $categoryid, 'qtype' => 'random', 'status' => 1];
|
||||
$params = ['categoryid' => $categoryid, 'qtype' => 'random', 'status' => question_version_status::QUESTION_STATUS_HIDDEN];
|
||||
$questions = $DB->get_records_sql($sql, $params);
|
||||
foreach ($questions as $question) {
|
||||
// The function question_delete_question does not delete questions in use.
|
||||
@@ -246,17 +246,15 @@ class helper {
|
||||
* Get all the category objects, including a count of the number of questions in that category,
|
||||
* for all the categories in the lists $contexts.
|
||||
*
|
||||
* @param $contexts
|
||||
* @param context $contexts
|
||||
* @param string $sortorder used as the ORDER BY clause in the select statement.
|
||||
* @param bool $top Whether to return the top categories or not.
|
||||
* @param int $showallversions 1 to show all versions not only the latest.
|
||||
* @param int|null $statustocount The version status to count. If null will get all except hidden.
|
||||
* @return array of category objects.
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
public static function get_categories_for_contexts($contexts, string $sortorder = 'parent, sortorder, name ASC',
|
||||
bool $top = false, int $showallversions = 0,
|
||||
?int $statustocount = null): array {
|
||||
bool $top = false, int $showallversions = 0): array {
|
||||
global $DB;
|
||||
$topwhere = $top ? '' : 'AND c.parent <> 0';
|
||||
$statuscondition = "AND (qv.status = '". question_version_status::QUESTION_STATUS_READY . "' " .
|
||||
|
||||
@@ -72,13 +72,13 @@ class helper_test extends \advanced_testcase {
|
||||
|
||||
$qcat1 = $this->qgenerator->create_question_category(['contextid' => $this->context->id]);
|
||||
$q1a = $this->qgenerator->create_question('shortanswer', null, ['category' => $qcat1->id]); // Will be hidden.
|
||||
$DB->set_field('question_versions', 'status', 1, ['questionid' => $q1a->id]);
|
||||
$DB->set_field('question_versions', 'status', 'hidden', ['questionid' => $q1a->id]);
|
||||
|
||||
$qcat2 = $this->qgenerator->create_question_category(['contextid' => $this->context->id]);
|
||||
$q2a = $this->qgenerator->create_question('shortanswer', null, ['category' => $qcat2->id]); // Will be hidden.
|
||||
$q2b = $this->qgenerator->create_question('shortanswer', null, ['category' => $qcat2->id]); // Will be hidden but used.
|
||||
$DB->set_field('question_versions', 'status', 1, ['questionid' => $q2a->id]);
|
||||
$DB->set_field('question_versions', 'status', 1, ['questionid' => $q2b->id]);
|
||||
$DB->set_field('question_versions', 'status', 'hidden', ['questionid' => $q2a->id]);
|
||||
$DB->set_field('question_versions', 'status', 'hidden', ['questionid' => $q2b->id]);
|
||||
quiz_add_quiz_question($q2b->id, $this->quiz);
|
||||
|
||||
// Adding a new random question does not add a new question, adds a question_set_references record.
|
||||
|
||||
@@ -79,7 +79,8 @@ class helper_test extends \advanced_testcase {
|
||||
$cat = question_make_default_categories($contexts->all());
|
||||
$this->questiondata = $questiongenerator->create_question('numerical', null,
|
||||
['name' => 'Example question', 'category' => $cat->id]);
|
||||
$this->quba = question_engine::make_questions_usage_by_activity('core_question_preview', \context_user::instance($USER->id));
|
||||
$this->quba = question_engine::make_questions_usage_by_activity('core_question_preview',
|
||||
\context_user::instance($USER->id));
|
||||
$this->options = new question_preview_options($this->questiondata);
|
||||
$this->options->load_user_defaults();
|
||||
$this->options->set_from_request();
|
||||
|
||||
@@ -62,7 +62,7 @@ class helper {
|
||||
qz.course as courseid
|
||||
FROM {quiz_slots} slot
|
||||
JOIN {quiz} qz ON qz.id = slot.quizid
|
||||
JOIN {question_references} qr ON qr.itemid = slot.id
|
||||
JOIN {question_references} qr ON qr.itemid = slot.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qr.questionbankentryid
|
||||
JOIN {question_versions} qv ON qv.questionbankentryid = qbe.id
|
||||
WHERE qv.questionbankentryid = ?)";
|
||||
|
||||
@@ -84,7 +84,7 @@ class question_usage_table extends table_sql {
|
||||
}
|
||||
|
||||
$sql = helper::question_usage_sql();
|
||||
$params = [$this->question->id, $this->question->id];
|
||||
$params = [$this->question->id, $this->question->questionbankentryid];
|
||||
|
||||
if (!$this->is_downloading()) {
|
||||
$this->rawdata = $DB->get_records_sql($sql, $params, $this->get_page_start(), $this->get_page_size());
|
||||
|
||||
@@ -39,7 +39,7 @@ function qbank_viewcreator_edit_form_display($question): string {
|
||||
$a->time = userdate($question->timecreated);
|
||||
$a->user = fullname($DB->get_record('user', ['id' => $question->createdby]));
|
||||
$versiondata['createdby'] = get_string('created', 'question') . ' ' .
|
||||
get_string('byandon', 'question', $a) ;
|
||||
get_string('byandon', 'question', $a);
|
||||
}
|
||||
return $PAGE->get_renderer('qbank_viewcreator')->render_version_info($versiondata);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace core_question\bank\search;
|
||||
|
||||
use core_question\local\bank\constants;
|
||||
use core_question\local\bank\question_version_status;
|
||||
|
||||
/**
|
||||
* This class controls whether hidden / deleted questions are hidden in the list.
|
||||
@@ -48,8 +48,8 @@ class hidden_condition extends condition {
|
||||
public function __construct($hide = true) {
|
||||
$this->hide = $hide;
|
||||
if ($hide) {
|
||||
$this->where = 'qv.status = ' . constants::QUESTION_STATUS_READY .
|
||||
' OR qv.status = ' . constants::QUESTION_STATUS_DRAFT;
|
||||
$this->where = "qv.status = '" . question_version_status::QUESTION_STATUS_READY . "' " .
|
||||
" OR qv.status = '" . question_version_status::QUESTION_STATUS_DRAFT . "' ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -290,13 +290,13 @@ class random_question_loader {
|
||||
$fieldsstring = implode(',', $fields);
|
||||
}
|
||||
|
||||
// Create the query to get the questions (validate that at least we have a question id. If not, do not execute the sql.)
|
||||
// Create the query to get the questions (validate that at least we have a question id. If not, do not execute the sql).
|
||||
$hasquestions = false;
|
||||
if (!empty($questionids)) {
|
||||
$hasquestions = true;
|
||||
}
|
||||
if ($hasquestions) {
|
||||
list($condition, $param) = $DB->get_in_or_equal($questionids,SQL_PARAMS_NAMED, 'questionid');
|
||||
list($condition, $param) = $DB->get_in_or_equal($questionids, SQL_PARAMS_NAMED, 'questionid');
|
||||
$condition = 'WHERE q.id ' . $condition;
|
||||
$sql = "SELECT {$fieldsstring}
|
||||
FROM (SELECT q.*, qbe.questioncategoryid as category
|
||||
|
||||
@@ -1159,7 +1159,7 @@ class view {
|
||||
*/
|
||||
protected function get_row_classes($question, $rowcount): array {
|
||||
$classes = [];
|
||||
if ((int)$question->status === 1) {
|
||||
if ($question->status === question_version_status::QUESTION_STATUS_HIDDEN) {
|
||||
$classes[] = 'dimmed_text';
|
||||
}
|
||||
if ($question->id == $this->lastchangedid) {
|
||||
|
||||
@@ -58,6 +58,7 @@ function get_module_from_cmid($cmid) {
|
||||
* @param bool $noparent if true only questions with NO parent will be selected
|
||||
* @param bool $recurse include subdirectories
|
||||
* @param bool $export set true if this is called by questionbank export
|
||||
* @param bool $latestversion if only the latest versions needed
|
||||
* @return array
|
||||
*/
|
||||
function get_questions_category(object $category, bool $noparent, bool $recurse = true, bool $export = true,
|
||||
@@ -67,7 +68,7 @@ function get_questions_category(object $category, bool $noparent, bool $recurse
|
||||
// Build sql bit for $noparent.
|
||||
$npsql = '';
|
||||
if ($noparent) {
|
||||
$npsql = " and q.parent='0' ";
|
||||
$npsql = " and q.parent='0' ";
|
||||
}
|
||||
|
||||
// Get list of categories.
|
||||
|
||||
@@ -550,7 +550,7 @@ class question_finder implements cache_data_source {
|
||||
|
||||
list($qcsql, $qcparams) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'qc');
|
||||
|
||||
$readystatus = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$readystatus = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$select = "q.id, (SELECT COUNT(1)
|
||||
FROM " . $qubaids->from_question_attempts('qa') . "
|
||||
WHERE qa.questionid = q.id AND " . $qubaids->where() . "
|
||||
@@ -561,7 +561,7 @@ class question_finder implements cache_data_source {
|
||||
$from = $from . " " . $join;
|
||||
$where = "qbe.questioncategoryid {$qcsql}
|
||||
AND q.parent = 0
|
||||
AND qv.status = " . $readystatus . "
|
||||
AND qv.status = '$readystatus'
|
||||
AND qv.version = (SELECT MAX(v.version)
|
||||
FROM {question_versions} v
|
||||
JOIN {question_bank_entries} be
|
||||
|
||||
@@ -179,7 +179,7 @@ class test_question_maker {
|
||||
$q->penalty = 0.3333333;
|
||||
$q->length = 1;
|
||||
$q->stamp = make_unique_id_code();
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->version = 1;
|
||||
$q->timecreated = time();
|
||||
$q->timemodified = time();
|
||||
@@ -201,7 +201,7 @@ class test_question_maker {
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->length = 1;
|
||||
$qdata->stamp = make_unique_id_code();
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->version = 1;
|
||||
$qdata->timecreated = time();
|
||||
$qdata->timemodified = time();
|
||||
|
||||
+6
-1
@@ -437,7 +437,7 @@ class qformat_default {
|
||||
$questionversion->questionbankentryid = $questionbankentry->id;
|
||||
$questionversion->questionid = $question->id;
|
||||
$questionversion->version = 1;
|
||||
$questionversion->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$questionversion->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$questionversion->id = $DB->insert_record('question_versions', $questionversion);
|
||||
|
||||
$event = \core\event\question_created::create_from_question_instance($question, $this->importcontext);
|
||||
@@ -924,6 +924,11 @@ class qformat_default {
|
||||
$contextid = $DB->get_field('question_categories', 'contextid', ['id' => $qcategory]);
|
||||
$question->contextid = $contextid;
|
||||
$question->idnumber = $questionbankentry->idnumber;
|
||||
if ($question->status === \core_question\local\bank\question_version_status::QUESTION_STATUS_READY) {
|
||||
$question->status = 0;
|
||||
} else {
|
||||
$question->status = 1;
|
||||
}
|
||||
|
||||
// do not export hidden questions
|
||||
if (!empty($question->hidden)) {
|
||||
|
||||
@@ -67,7 +67,7 @@ class qformat_multianswer extends qformat_default {
|
||||
$question->generalfeedbackformat = FORMAT_MOODLE;
|
||||
$question->length = 1;
|
||||
$question->penalty = 0.3333333;
|
||||
$question->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$question->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$question->version = 1;
|
||||
$question->versionid = 0;
|
||||
$question->questionbankentryid = 0;
|
||||
|
||||
@@ -1182,6 +1182,7 @@ class qformat_xml extends qformat_default {
|
||||
$invalidquestion = false;
|
||||
$fs = get_file_storage();
|
||||
$contextid = $question->contextid;
|
||||
$question->status = 0;
|
||||
// Get files used by the questiontext.
|
||||
$question->questiontextfiles = $fs->get_area_files(
|
||||
$contextid, 'question', 'questiontext', $question->id);
|
||||
|
||||
@@ -57,7 +57,7 @@ class qformat_xml_test extends question_testcase {
|
||||
$q->penalty = 0.3333333;
|
||||
$q->length = 1;
|
||||
$q->stamp = make_unique_id_code();
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->timecreated = time();
|
||||
$q->timemodified = time();
|
||||
$q->createdby = $USER->id;
|
||||
@@ -341,7 +341,7 @@ END;
|
||||
$qdata->defaultmark = 0;
|
||||
$qdata->length = 0;
|
||||
$qdata->penalty = 0;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
|
||||
$exporter = new qformat_xml();
|
||||
@@ -569,7 +569,7 @@ END;
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->id = 456;
|
||||
@@ -741,7 +741,7 @@ END;
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
@@ -974,7 +974,7 @@ END;
|
||||
$qdata->defaultmark = 2;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
@@ -1151,7 +1151,7 @@ END;
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.1;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
@@ -1283,7 +1283,7 @@ END;
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
@@ -1459,7 +1459,7 @@ END;
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 1;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = null;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
@@ -1519,7 +1519,7 @@ END;
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 1;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->idnumber = 'TestIDNum2';
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
|
||||
@@ -22,9 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use core_question\local\bank\constants;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
use core_question\local\bank\question_version_status;
|
||||
|
||||
/**
|
||||
* Class core_question_generator for generating question data.
|
||||
@@ -97,7 +95,7 @@ class core_question_generator extends component_generator_base {
|
||||
$question->qtype = $qtype;
|
||||
$question->createdby = 0;
|
||||
$question->idnumber = null;
|
||||
$question->status = constants::QUESTION_STATUS_READY;
|
||||
$question->status = question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $this->update_question($question, $which, $overrides);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ class random_question_loader_testcase extends advanced_testcase {
|
||||
|
||||
$cat = $generator->create_question_category();
|
||||
$question1 = $generator->create_question('shortanswer', null, ['category' => $cat->id]);
|
||||
$DB->set_field('question_versions', 'status', 1, ['questionid' => $question1->id]);
|
||||
$DB->set_field('question_versions', 'status',
|
||||
\core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN, ['questionid' => $question1->id]);
|
||||
$loader = new \core_question\local\bank\random_question_loader(new qubaid_list([]));
|
||||
|
||||
$this->assertNull($loader->get_next_question_id($cat->id, 0));
|
||||
|
||||
@@ -190,7 +190,8 @@ class version_test extends \advanced_testcase {
|
||||
global $DB;
|
||||
|
||||
$qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]);
|
||||
$qcategorychild = $this->qgenerator->create_question_category(['contextid' => $this->context->id, 'parent' => $qcategory->id]);
|
||||
$qcategorychild = $this->qgenerator->create_question_category(['contextid' => $this->context->id,
|
||||
'parent' => $qcategory->id]);
|
||||
$systemcontext = \context_system::instance();
|
||||
$qcategorysys = $this->qgenerator->create_question_category(['contextid' => $systemcontext->id]);
|
||||
$question = $this->qgenerator->create_question('shortanswer', null, ['category' => $qcategorychild->id]);
|
||||
|
||||
@@ -97,7 +97,7 @@ class qtype_calculated_test_helper extends question_test_helper {
|
||||
$qdata->name = 'Simple sum';
|
||||
$qdata->questiontext = 'What is {a} + {b}?';
|
||||
$qdata->generalfeedback = 'Generalfeedback: {={a} + {b}} is the right answer.';
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->unitgradingtype = 0;
|
||||
@@ -187,7 +187,7 @@ class qtype_calculated_test_helper extends question_test_helper {
|
||||
$fromform->feedback[2]['format'] = FORMAT_HTML;
|
||||
$fromform->feedback[2]['text'] = 'Completely wrong.';
|
||||
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
$this->assertEquals(0, $questiondata->penalty);
|
||||
$this->assertEquals('calculated', $questiondata->qtype);
|
||||
$this->assertEquals(1, $questiondata->length);
|
||||
$this->assertEquals(0, $questiondata->status);
|
||||
$this->assertEquals(\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, $questiondata->status);
|
||||
$this->assertEquals($question->createdby, $questiondata->createdby);
|
||||
$this->assertEquals($question->createdby, $questiondata->modifiedby);
|
||||
$this->assertEquals('', $questiondata->idnumber);
|
||||
|
||||
@@ -205,7 +205,7 @@ class qtype_calculatedsimple_test_helper extends question_test_helper {
|
||||
$form->definition[19] = '1-0-b';
|
||||
$form->definition[20] = '1-0-a';
|
||||
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ class qtype_calculatedsimple_test_helper extends question_test_helper {
|
||||
$q->penalty = 0.3333333;
|
||||
$q->qtype = 'calculatedsimple';
|
||||
$q->length = '1';
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->version = 1;
|
||||
$q->options = new stdClass();
|
||||
$q->options->synchronize = 0;
|
||||
|
||||
@@ -246,7 +246,7 @@ class qtype_ddimageortext_test_helper extends question_test_helper {
|
||||
$fromform->hintclearwrong = array(1, 0, 1, 0);
|
||||
$fromform->hintshownumcorrect = array(1, 1, 1, 1);
|
||||
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class qtype_ddmarker_test_helper extends question_test_helper {
|
||||
$fromform->hintclearwrong = array(0, 1);
|
||||
$fromform->hintoptions = array(0, 1);
|
||||
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -260,7 +260,7 @@ class qtype_ddmarker_test_helper extends question_test_helper {
|
||||
$fromform->hintclearwrong = array(0, 1);
|
||||
$fromform->hintoptions = array(0, 1);
|
||||
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class qtype_ddwtos_test_helper extends question_test_helper {
|
||||
test_question_maker::set_standard_combined_feedback_form_data($fromform);
|
||||
$fromform->shownumcorrect = 0;
|
||||
$fromform->penalty = 0.3333333;
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class qtype_ddwtos_test_helper extends question_test_helper {
|
||||
test_question_maker::set_standard_combined_feedback_form_data($fromform);
|
||||
$fromform->shownumcorrect = 0;
|
||||
$fromform->penalty = 0.3333333;
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class qtype_ddwtos_test_helper extends question_test_helper {
|
||||
test_question_maker::set_standard_combined_feedback_form_data($fromform);
|
||||
$fromform->shownumcorrect = 0;
|
||||
$fromform->penalty = 0.3333333;
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ class qtype_ddwtos_test_helper extends question_test_helper {
|
||||
test_question_maker::set_standard_combined_feedback_form_data($fromform);
|
||||
$fromform->shownumcorrect = 0;
|
||||
$fromform->penalty = 0.3333333;
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
$dd->penalty = 0.3333333;
|
||||
$dd->length = 1;
|
||||
$dd->stamp = make_unique_id_code();
|
||||
$dd->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$dd->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$dd->version = 1;
|
||||
$dd->versionid = 0;
|
||||
$dd->questionbankentryid = 0;
|
||||
@@ -285,7 +285,7 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
$qdata->defaultmark = 3;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->shuffleanswers = 1;
|
||||
|
||||
@@ -83,7 +83,7 @@ class qtype_description_test_helper extends question_test_helper {
|
||||
$qdata->defaultmark = 0;
|
||||
$qdata->length = 0;
|
||||
$qdata->penalty = 0;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->hints = array();
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->answers = array();
|
||||
@@ -104,7 +104,7 @@ class qtype_description_test_helper extends question_test_helper {
|
||||
'format' => FORMAT_HTML);
|
||||
$form->generalfeedback = array('text' => 'And here is some more text shown only on the review page.',
|
||||
'format' => FORMAT_HTML);
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class qtype_essay_test_helper extends question_test_helper {
|
||||
$fromform->filetypeslist = ''; // Although once saved in the DB, this becomes null, the form returns '' here.
|
||||
$fromform->graderinfo = array('text' => '', 'format' => FORMAT_HTML);
|
||||
$fromform->responsetemplate = array('text' => '', 'format' => FORMAT_HTML);
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class qtype_essay_test_helper extends question_test_helper {
|
||||
$fromform->filetypeslist = ''; // Although once saved in the DB, this becomes null, the form returns '' here.
|
||||
$fromform->graderinfo = array('text' => '', 'format' => FORMAT_HTML);
|
||||
$fromform->responsetemplate = array('text' => '', 'format' => FORMAT_HTML);
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class qtype_essay_test_helper extends question_test_helper {
|
||||
$fromform->filetypeslist = ''; // Although once saved in the DB, this becomes null, the form returns '' here.
|
||||
$fromform->graderinfo = array('text' => '', 'format' => FORMAT_HTML);
|
||||
$fromform->responsetemplate = array('text' => '', 'format' => FORMAT_HTML);
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class qtype_gapselect_test_helper extends question_test_helper {
|
||||
$gapselect->penalty = 0.3333333;
|
||||
$gapselect->length = 1;
|
||||
$gapselect->stamp = make_unique_id_code();
|
||||
$gapselect->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$gapselect->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$gapselect->versionid = 0;
|
||||
$gapselect->version = 1;
|
||||
$gapselect->questionbankentryid = 0;
|
||||
@@ -110,7 +110,7 @@ class qtype_gapselect_test_helper extends question_test_helper {
|
||||
test_question_maker::set_standard_combined_feedback_form_data($fromform);
|
||||
$fromform->shownumcorrect = 0;
|
||||
$fromform->penalty = 0.3333333;
|
||||
$fromform->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$fromform->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $fromform;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class qtype_gapselect_test_helper extends question_test_helper {
|
||||
$gapselect->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
|
||||
$gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
|
||||
$gapselect->qtype = question_bank::get_qtype('gapselect');
|
||||
$gapselect->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$gapselect->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$gapselect->shufflechoices = true;
|
||||
|
||||
@@ -169,7 +169,7 @@ class qtype_gapselect_test_helper extends question_test_helper {
|
||||
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
|
||||
$gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
|
||||
$gapselect->qtype = question_bank::get_qtype('gapselect');
|
||||
$gapselect->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$gapselect->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$gapselect->shufflechoices = true;
|
||||
|
||||
@@ -205,7 +205,7 @@ class qtype_gapselect_test_helper extends question_test_helper {
|
||||
'<span lang="en" class="multilang">sat on the</span><span lang="ru" class="multilang">сидела на</span> [[2]].';
|
||||
$gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
|
||||
$gapselect->qtype = question_bank::get_qtype('gapselect');
|
||||
$gapselect->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$gapselect->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$gapselect->shufflechoices = true;
|
||||
|
||||
@@ -246,7 +246,7 @@ class qtype_gapselect_test_helper extends question_test_helper {
|
||||
$gapselect->questiontext = 'The price of the ball is [[1]] approx.';
|
||||
$gapselect->generalfeedback = 'The choice is yours';
|
||||
$gapselect->qtype = question_bank::get_qtype('gapselect');
|
||||
$gapselect->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$gapselect->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$gapselect->shufflechoices = true;
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ class qtype_gapselect_test extends question_testcase {
|
||||
$qdata->defaultmark = 3;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->shuffleanswers = 1;
|
||||
|
||||
@@ -59,7 +59,7 @@ class qtype_match_test_helper extends question_test_helper {
|
||||
$q->defaultmark = 1;
|
||||
$q->penalty = 0.3333333;
|
||||
$q->length = 1;
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->versionid = 0;
|
||||
$q->version = 1;
|
||||
$q->questionbankentryid = 0;
|
||||
@@ -108,7 +108,7 @@ class qtype_match_test_helper extends question_test_helper {
|
||||
$q->generalfeedback = array('text' => 'General feedback.', 'format' => FORMAT_HTML);
|
||||
$q->defaultmark = 1;
|
||||
$q->penalty = 0.3333333;
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->versionid = 0;
|
||||
$q->version = 1;
|
||||
$q->questionbankentryid = 0;
|
||||
@@ -187,7 +187,7 @@ class qtype_match_test_helper extends question_test_helper {
|
||||
$q->defaultmark = 1;
|
||||
$q->penalty = 0.3333333;
|
||||
$q->length = 1;
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->versionid = 0;
|
||||
$q->version = 1;
|
||||
$q->questionbankentryid = 0;
|
||||
@@ -231,7 +231,7 @@ class qtype_match_test_helper extends question_test_helper {
|
||||
$q->generalfeedback = ['text' => 'Java has some advantages over PHP I guess!', 'format' => FORMAT_HTML];
|
||||
$q->defaultmark = 1;
|
||||
$q->penalty = 0.3333333;
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->versionid = 0;
|
||||
$q->version = 1;
|
||||
$q->questionbankentryid = 0;
|
||||
|
||||
@@ -66,7 +66,7 @@ class qtype_match_test extends advanced_testcase {
|
||||
$q->penalty = 0.3333333;
|
||||
$q->length = 1;
|
||||
$q->stamp = make_unique_id_code();
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->version = 1;
|
||||
$q->versionid = 0;
|
||||
$q->questionbankentryid = 0;
|
||||
|
||||
@@ -75,7 +75,7 @@ class qtype_missingtype extends question_type {
|
||||
$question->length = 1;
|
||||
$question->penalty = 0;
|
||||
$question->stamp = '';
|
||||
$question->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$question->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$question->timecreated = null;
|
||||
$question->timemodified = null;
|
||||
$question->createdby = null;
|
||||
|
||||
@@ -56,7 +56,7 @@ class qtype_missing_test extends question_testcase {
|
||||
$questiondata->qtype = 'strange_unknown';
|
||||
$questiondata->length = 1;
|
||||
$questiondata->stamp = make_unique_id_code();
|
||||
$questiondata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$questiondata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$questiondata->version = 1;
|
||||
$questiondata->versionid = 0;
|
||||
$questiondata->questionbankentryid = 0;
|
||||
|
||||
@@ -131,7 +131,7 @@ class qtype_multianswer_test_helper extends question_test_helper {
|
||||
|
||||
$qdata->defaultmark = 2.0;
|
||||
$qdata->qtype = 'multianswer';
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$sa = new stdClass();
|
||||
test_question_maker::initialise_question_data($sa);
|
||||
@@ -141,7 +141,7 @@ class qtype_multianswer_test_helper extends question_test_helper {
|
||||
$sa->generalfeedback = '';
|
||||
$sa->penalty = 0.0;
|
||||
$sa->qtype = 'shortanswer';
|
||||
$sa->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$sa->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$sa->options = new stdClass();
|
||||
$sa->options->usecase = 0;
|
||||
@@ -161,7 +161,7 @@ class qtype_multianswer_test_helper extends question_test_helper {
|
||||
$mc->generalfeedback = '';
|
||||
$mc->penalty = 0.0;
|
||||
$mc->qtype = 'multichoice';
|
||||
$mc->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$mc->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$mc->options = new stdClass();
|
||||
$mc->options->layout = 0;
|
||||
@@ -217,7 +217,7 @@ class qtype_multianswer_test_helper extends question_test_helper {
|
||||
|
||||
$qdata->defaultmark = 1.0;
|
||||
$qdata->qtype = 'multianswer';
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$mc = new stdClass();
|
||||
test_question_maker::initialise_question_data($mc);
|
||||
@@ -227,7 +227,7 @@ class qtype_multianswer_test_helper extends question_test_helper {
|
||||
$mc->generalfeedback = '';
|
||||
$mc->penalty = 0.0;
|
||||
$mc->qtype = 'multichoice';
|
||||
$mc->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$mc->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$mc->options = new stdClass();
|
||||
$mc->options->layout = 0;
|
||||
@@ -279,7 +279,7 @@ class qtype_multianswer_test_helper extends question_test_helper {
|
||||
1 => array('text' => 'Hint 2', 'format' => FORMAT_HTML, 'itemid' => 0),
|
||||
);
|
||||
|
||||
$formdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$formdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $formdata;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
$q->generalfeedbackformat = FORMAT_HTML;
|
||||
$q->defaultmark = 2;
|
||||
$q->penalty = 0.3333333;
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->versionid = 0;
|
||||
$q->version = 1;
|
||||
$q->questionbankentryid = 0;
|
||||
@@ -155,7 +155,7 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
$this->assertEquals(0, $questiondata->penalty);
|
||||
$this->assertEquals('multianswer', $questiondata->qtype);
|
||||
$this->assertEquals(1, $questiondata->length);
|
||||
$this->assertEquals(0, $questiondata->status);
|
||||
$this->assertEquals(\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, $questiondata->status);
|
||||
$this->assertEquals($question->createdby, $questiondata->createdby);
|
||||
$this->assertEquals($question->createdby, $questiondata->modifiedby);
|
||||
$this->assertEquals('', $questiondata->idnumber);
|
||||
|
||||
@@ -57,7 +57,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->versionid = 0;
|
||||
$qdata->version = 1;
|
||||
$qdata->questionbankentryid = 0;
|
||||
@@ -146,7 +146,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
|
||||
$qdata->noanswers = 5;
|
||||
$qdata->numhints = 2;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->versionid = 0;
|
||||
$qdata->version = 1;
|
||||
$qdata->questionbankentryid = 0;
|
||||
@@ -246,7 +246,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
|
||||
$qdata->defaultmark = 1;
|
||||
$qdata->length = 1;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->versionid = 0;
|
||||
$qdata->version = 1;
|
||||
$qdata->questionbankentryid = 0;
|
||||
@@ -336,7 +336,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
|
||||
$qdata->noanswers = 5;
|
||||
$qdata->numhints = 2;
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$qdata->versionid = 0;
|
||||
$qdata->version = 1;
|
||||
$qdata->questionbankentryid = 0;
|
||||
|
||||
@@ -162,7 +162,7 @@ class qtype_numerical_test_helper extends question_test_helper {
|
||||
$form->hint[1]['text'] = '';
|
||||
|
||||
$form->qtype = 'numerical';
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ class qtype_numerical_test_helper extends question_test_helper {
|
||||
$q->penalty = 0.3333333;
|
||||
$q->qtype = 'numerical';
|
||||
$q->length = '1';
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->version = 1;
|
||||
$q->createdby = '2';
|
||||
$q->modifiedby = '2';
|
||||
|
||||
@@ -119,7 +119,7 @@ abstract class question_definition {
|
||||
public $hints = array();
|
||||
|
||||
/** @var boolean question status hidden/ready/draft in the question bank. */
|
||||
public $status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
public $status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
/** @var int Version id of the question in a question bank */
|
||||
public $versionid;
|
||||
|
||||
@@ -492,7 +492,8 @@ class question_type {
|
||||
// Get the version and status from the parent question if parent is set.
|
||||
if (!$question->parent) {
|
||||
// Get the status field. It comes from the form, but for testing we can.
|
||||
$status = $form->status ?? $question->status ?? \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$status = $form->status ?? $question->status ??
|
||||
\core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$questionversion->version = get_next_version($questionbankentry->id);
|
||||
$questionversion->status = $status;
|
||||
} else {
|
||||
@@ -1395,7 +1396,7 @@ class question_type {
|
||||
$form->questiontext = 'test question, generated by script';
|
||||
$form->defaultmark = 1;
|
||||
$form->penalty = 0.3333333;
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$form->generalfeedback = "Well done";
|
||||
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
@@ -86,14 +86,14 @@ class qtype_random extends question_type {
|
||||
list($qcsql, $qcparams) = $DB->get_in_or_equal($categorylist);
|
||||
// TODO use in_or_equal for $otherquestionsinuse and $this->manualqtypes.
|
||||
|
||||
$readystatus = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$readystatus = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$sql = "SELECT q.*
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv ON qv.questionid = q.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
|
||||
WHERE qbe.questioncategoryid {$qcsql}
|
||||
AND q.parent = 0
|
||||
AND qv.status = $readystatus
|
||||
AND qv.status = '$readystatus'
|
||||
AND q.id NOT IN ($otherquestionsinuse)
|
||||
AND q.qtype IN ($this->manualqtypes)";
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class qtype_random_test_helper extends question_test_helper {
|
||||
$form = new stdClass();
|
||||
$form->questiontext = array('text' => '');
|
||||
$form->includesubcategories = '0';
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class qtype_random_test extends advanced_testcase {
|
||||
$this->assertEquals(0, $questiondata->questiontext); // Used to store 'Select from subcategories'.
|
||||
$this->assertEquals('random', $questiondata->qtype);
|
||||
$this->assertEquals(1, $questiondata->length);
|
||||
$this->assertEquals(0, $questiondata->status);
|
||||
$this->assertEquals(\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, $questiondata->status);
|
||||
$this->assertEquals($category->contextid, $questiondata->contextid);
|
||||
|
||||
// Options - not used.
|
||||
|
||||
@@ -75,7 +75,7 @@ class qtype_shortanswer_test_helper extends question_test_helper {
|
||||
$qdata->name = 'Short answer question';
|
||||
$qdata->questiontext = 'Name an amphibian: __________';
|
||||
$qdata->generalfeedback = 'Generalfeedback: frog or toad would have been OK.';
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->usecase = 0;
|
||||
@@ -109,7 +109,7 @@ class qtype_shortanswer_test_helper extends question_test_helper {
|
||||
array('text' => 'Toad is an OK good answer.', 'format' => FORMAT_HTML),
|
||||
array('text' => 'That is a bad answer.', 'format' => FORMAT_HTML),
|
||||
);
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class qtype_shortanswer_test_helper extends question_test_helper {
|
||||
$qdata->name = 'Short answer question';
|
||||
$qdata->questiontext = 'Name the best amphibian: __________';
|
||||
$qdata->generalfeedback = 'Generalfeedback: you should have said frog.';
|
||||
$qdata->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options->usecase = false;
|
||||
|
||||
@@ -86,7 +86,7 @@ class qtype_truefalse_test_helper extends question_test_helper {
|
||||
$form->feedbackfalse['text'] = 'This is the wrong answer.';
|
||||
|
||||
$form->penalty = 1;
|
||||
$form->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$form->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class qtype_truefalse_test_helper extends question_test_helper {
|
||||
$q->penalty = 1;
|
||||
$q->qtype = 'truefalse';
|
||||
$q->length = '1';
|
||||
$q->status = \core_question\local\bank\constants::QUESTION_STATUS_READY;
|
||||
$q->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
$q->createdby = '2';
|
||||
$q->modifiedby = '2';
|
||||
$q->options = new stdClass();
|
||||
|
||||
@@ -96,7 +96,7 @@ class qtype_truefalse_test extends advanced_testcase {
|
||||
$this->assertEquals(1, $questiondata->penalty);
|
||||
$this->assertEquals('truefalse', $questiondata->qtype);
|
||||
$this->assertEquals(1, $questiondata->length);
|
||||
$this->assertEquals(0, $questiondata->status);
|
||||
$this->assertEquals(\core_question\local\bank\question_version_status::QUESTION_STATUS_READY, $questiondata->status);
|
||||
$this->assertEquals($question->createdby, $questiondata->createdby);
|
||||
$this->assertEquals($question->createdby, $questiondata->modifiedby);
|
||||
$this->assertEquals('', $questiondata->idnumber);
|
||||
|
||||
Reference in New Issue
Block a user