diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml
index ad89f1dc..86c40855 100644
--- a/.github/workflows/moodle-plugin-ci.yml
+++ b/.github/workflows/moodle-plugin-ci.yml
@@ -73,7 +73,6 @@ jobs:
- name: PHP Lint
if: ${{ always() }}
- continue-on-error: true # This step will show errors but will not fail
run: moodle-plugin-ci phplint
- name: PHP Copy/Paste Detector
diff --git a/classes/condition/studentquiz_condition.php b/classes/condition/studentquiz_condition.php
index 9435e6b5..a4d23209 100755
--- a/classes/condition/studentquiz_condition.php
+++ b/classes/condition/studentquiz_condition.php
@@ -23,10 +23,10 @@
*/
namespace mod_studentquiz\condition;
-defined('MOODLE_INTERNAL') || die();
-require_once($CFG->dirroot . '/mod/studentquiz/classes/local/db.php');
-use mod_studentquiz\local\db;
+if (!class_exists('\core_question\local\bank\condition')) {
+ class_alias('\core_question\bank\search\condition', '\core_question\local\bank\condition');
+}
/**
* Conditionally modify question bank queries.
@@ -36,6 +36,24 @@
*/
class studentquiz_condition extends \core_question\local\bank\condition {
+ /**
+ * Return title of the condition
+ *
+ * @return string title of the condition
+ */
+ public function get_title() {
+ return get_string('showhidden', 'core_question');
+ }
+
+ /**
+ * Return filter class associated with this condition
+ *
+ * @return string filter class
+ */
+ public function get_filter_class() {
+ return 'qbank_deletequestion/datafilter/filtertypes/hidden';
+ }
+
/**
* Due to fix_sql_params not accepting repeated use of named params,
* we need to get unique names for params that will be used more than
@@ -67,24 +85,6 @@ public function __construct($cm, $filterform, $report, $studentquiz) {
$this->init();
}
- /**
- * Return title of the condition
- *
- * @return string title of the condition
- */
- public function get_title() {
- return get_string('showhidden', 'core_question');
- }
-
- /**
- * Return filter class associated with this condition
- *
- * @return string filter class
- */
- public function get_filter_class() {
- return 'qbank_deletequestion/datafilter/filtertypes/hidden';
- }
-
/** @var stdClass */
protected $cm;
@@ -100,8 +100,8 @@ public function get_filter_class() {
/** @var array */
protected $tests;
- /** @var array */
- protected array $params = [];
+ /** @var array we need to change the name so that it is avoid conflict existing params variable*/
+ protected $customparams = [];
/** @var bool */
protected $isfilteractive = false;
@@ -121,7 +121,7 @@ protected function init() {
if ($adddata = $this->filterform->get_data()) {
$this->tests = array();
- $this->params = array();
+ $this->customparams = array();
foreach ($this->filterform->get_fields() as $field) {
@@ -171,7 +171,7 @@ protected function init() {
, $sqldata[0]);
$sqldata[0] = $this->get_special_sql($sqldata[0], $field->_name);
$this->tests[] = '((' . $sqldata[0] . '))';
- $this->params = array_merge($this->params, $sqldata[1]);
+ $this->customparams = array_merge($this->customparams, $sqldata[1]);
}
}
}
@@ -264,6 +264,9 @@ public function where() {
* @return array parameter name => value.
*/
public function params() {
- return $this->params;
+ if (isset($this->params)) {
+ return array_merge($this->params, $this->customparams);
+ }
+ return $this->customparams;
}
}
diff --git a/classes/condition/studentquiz_condition_pre_43.php b/classes/condition/studentquiz_condition_pre_43.php
deleted file mode 100644
index f3aae8f8..00000000
--- a/classes/condition/studentquiz_condition_pre_43.php
+++ /dev/null
@@ -1,251 +0,0 @@
-.
-
-/**
- * Modify stuff conditionally
- *
- * @package mod_studentquiz
- * @copyright 2017 HSR (http://www.hsr.ch)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace mod_studentquiz\condition;
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot . '/mod/studentquiz/classes/local/db.php');
-use mod_studentquiz\local\db;
-
-/**
- * Conditionally modify question bank queries.
- *
- * @copyright 2017 HSR (http://www.hsr.ch)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class studentquiz_condition_pre_43 extends \core_question\bank\search\condition {
-
- /**
- * Due to fix_sql_params not accepting repeated use of named params,
- * we need to get unique names for params that will be used more than
- * once...
- *
- * init() from parent class duplicated here as we can't call it directly
- * (private) :-P
- *
- * where() overridden with call to init() followed by call to parent
- * where()...
- *
- * params() always returns $this->params, which doesn't change between
- * calls to get_in_or_equal, so don't need to fix anything there.
- * Which is fortunate, as there'd be no way to keep where() and params()
- * in sync.
- *
- * @param stdClass $cm
- * @param stdClass $filterform
- * @param \mod_studentquiz_report $report
- * @param stdClass $studentquiz
- */
- public function __construct($cm, $filterform, $report, $studentquiz) {
- $this->cm = $cm;
- $this->filterform = $filterform;
- $this->tests = array();
- $this->params = array();
- $this->report = $report;
- $this->studentquiz = $studentquiz;
- $this->init();
- }
-
- /** @var stdClass */
- protected $cm;
-
- /** @var stdClass $filterform Search condition depends on filterform */
- protected $filterform;
-
- /** @var stdClass */
- protected $studentquiz;
-
- /** @var \mod_studentquiz_report */
- protected $report;
-
- /** @var array */
- protected $tests;
-
- /** @var array */
- protected $params;
-
- /** @var bool */
- protected $isfilteractive = false;
-
- /**
- * Whether the filter is active.
- * @return bool
- */
- public function is_filter_active() {
- return $this->isfilteractive;
- }
-
- /**
- * Initialize.
- */
- protected function init() {
- if ($adddata = $this->filterform->get_data()) {
-
- $this->tests = array();
- $this->params = array();
-
- foreach ($this->filterform->get_fields() as $field) {
-
- // Validate input.
- $data = $field->check_data($adddata);
-
- // If input is valid, at least one filter was activated.
- if ($data === false) {
- continue;
- } else {
- $this->isfilteractive = true;
- }
-
- $sqldata = $field->get_sql_filter($data);
-
- // Disable filtering by firstname if anonymized.
- if ($field->_name == 'firstname' && !(mod_studentquiz_check_created_permission($this->cm->id) ||
- !$this->report->is_anonymized())) {
- continue;
- }
-
- // Disable filtering by firstname if anonymized.
- if ($field->_name == 'lastname' && !(mod_studentquiz_check_created_permission($this->cm->id) ||
- !$this->report->is_anonymized())) {
- continue;
- }
-
- // Respect leading and ending ',' for the tagarray as provided by tag_column.php.
- if ($field->_name == 'tagarray') {
- foreach ($sqldata[1] as $key => $value) {
- if (!empty($value)) {
- $sqldata[1][$key] = "%,$value,%";
- } else {
- $sqldata[0] = "$field->_name IS NULL";
- }
- }
- }
-
- // TODO: cleanup that buggy filter function to remove this!
- // The user_filter_checkbox class has a buggy get_sql_filter function.
- if ($field->_name == 'createdby') {
- $sqldata = array($field->_name . ' = ' . intval($data['value']), array());
- }
-
- if (is_array($sqldata)) {
- $sqldata[0] = str_replace($field->_name, $this->get_sql_field($field->_name)
- , $sqldata[0]);
- $sqldata[0] = $this->get_special_sql($sqldata[0], $field->_name);
- $this->tests[] = '((' . $sqldata[0] . '))';
- $this->params = array_merge($this->params, $sqldata[1]);
- }
- }
- }
- }
-
- /**
- * Replaces special fields with additional sql instructions in the query
- *
- * @param string $sqldata the sql query
- * @param string $name affected field name
- * @return string modified sql query
- */
- private function get_special_sql($sqldata, $name) {
- if (substr($sqldata, 0, 12) === 'mydifficulty') {
- return str_replace('mydifficulty', '(CASE WHEN sp.attempts > 0 THEN
- ROUND(1 - (CAST(sp.correctattempts AS DECIMAL) / CAST(sp.attempts AS DECIMAL)), 2)
- ELSE 0
- END)', $sqldata);
- }
- if ($name == "onlynew") {
- return str_replace('myattempts', 'sp.attempts', $sqldata);
- }
- return $sqldata;
- }
-
- /**
- * Replaces fields with additional sql instructions in place of the field
- *
- * @param string $name affected field name
- * @return string modified sql query
- */
- private function get_sql_field($name) {
- if (substr($name, 0, 12) === 'mydifficulty') {
- return str_replace('mydifficulty', '(CASE WHEN sp.attempts > 0 THEN
- ROUND(1 - (CAST(sp.correctattempts AS DECIMAL) / CAST(sp.attempts AS DECIMAL)), 2)
- ELSE 0
- END)', $name);
- }
- if (substr($name, 0, 10) === 'myattempts') {
- return 'sp.attempts';
- }
- return $this->get_sql_table_prefix($name) . $name;
- }
-
-
- /**
- * Get the sql table prefix
- *
- * @param string $name
- * @return string return sql prefix
- */
- private function get_sql_table_prefix($name) {
- switch($name){
- case 'difficultylevel':
- return 'dl.';
- case 'rate':
- return 'vo.';
- case 'publiccomment':
- return 'copub.';
- case 'state':
- return 'sqq.';
- case 'firstname':
- case 'lastname':
- return 'uc.';
- case 'lastanswercorrect':
- return 'sp.';
- case 'mydifficulty':
- return 'mydiffs.';
- case 'myattempts':
- return 'myatts.';
- case 'myrate':
- return 'myrate.';
- case 'tagarray':
- return 'tags.';
- default;
- return 'q.';
- }
- }
-
- /**
- * Provide SQL fragment to be ANDed into the WHERE clause to filter which questions are shown.
- * @return string SQL fragment. Must use named parameters.
- */
- public function where() {
- return implode(' AND ', $this->tests);
- }
-
- /**
- * Return parameters to be bound to the above WHERE clause fragment.
- * @return array parameter name => value.
- */
- public function params() {
- return $this->params;
- }
-}
diff --git a/classes/question/bank/anonym_creator_name_column.php b/classes/question/bank/anonym_creator_name_column.php
index 8940f552..900979d3 100644
--- a/classes/question/bank/anonym_creator_name_column.php
+++ b/classes/question/bank/anonym_creator_name_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* A column type for the name of the question creator.
diff --git a/classes/question/bank/attempts_column.php b/classes/question/bank/attempts_column.php
index 58c573c2..724919a8 100644
--- a/classes/question/bank/attempts_column.php
+++ b/classes/question/bank/attempts_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* Represent performances column in studentquiz_bank_view
diff --git a/classes/question/bank/comments_column.php b/classes/question/bank/comment_column.php
similarity index 99%
rename from classes/question/bank/comments_column.php
rename to classes/question/bank/comment_column.php
index f8fe11a1..c043688e 100644
--- a/classes/question/bank/comments_column.php
+++ b/classes/question/bank/comment_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
use mod_studentquiz\utils;
diff --git a/classes/question/bank/difficulty_level_column.php b/classes/question/bank/difficulty_level_column.php
index 25bfe4e6..4a93a8ab 100644
--- a/classes/question/bank/difficulty_level_column.php
+++ b/classes/question/bank/difficulty_level_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* Representing difficulty level column in studentquiz_bank_view
diff --git a/classes/question/bank/legacy/preview_column.php b/classes/question/bank/legacy/preview_column.php
deleted file mode 100644
index 43a97d98..00000000
--- a/classes/question/bank/legacy/preview_column.php
+++ /dev/null
@@ -1,77 +0,0 @@
-.
-
-namespace mod_studentquiz\bank;
-
-/**
- * A column type for preview link to mod_studentquiz_preview
- *
- * @package mod_studentquiz
- * @copyright 2017 HSR (http://www.hsr.ch)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class preview_column extends \qbank_previewquestion\preview_action_column {
-
- /**
- * Renderer
- * @var stdClass
- */
- protected $renderer;
-
- /** @var stdClass */
- protected $context;
-
- /** @var string */
- protected $previewtext;
-
- /**
- * Loads config of current userid and can see
- */
- public function init(): void {
- global $PAGE;
- $this->renderer = $PAGE->get_renderer('mod_studentquiz');
- $this->context = $this->qbank->get_most_specific_context();
- $this->previewtext = get_string('preview');
- }
-
- /**
- * Look up if current user is allowed to preview this question
- * @param object $question The current question object
- * @return boolean
- */
- private function can_preview($question) {
- global $USER;
- return ($question->createdby == $USER->id) || has_capability('mod/studentquiz:previewothers', $this->context);
- }
-
- /**
- * Override this function and return the appropriate action menu link, or null if it does not apply to this question.
- *
- * @param \stdClass $question Data about the question being displayed in this row.
- * @return \action_menu_link|null The action, if applicable to this question.
- */
- public function get_action_menu_link(\stdClass $question): ?\action_menu_link {
- if ($this->can_preview($question)) {
- $params = ['cmid' => $this->context->instanceid, 'studentquizquestionid' => $question->studentquizquestionid];
- $link = new \moodle_url('/mod/studentquiz/preview.php', $params);
-
- return new \action_menu_link_secondary($link, new \pix_icon('t/preview', ''),
- $this->previewtext, ['target' => 'questionpreview']);
- }
-
- return null;
- }
-}
diff --git a/classes/question/bank/legacy/sq_delete_action_column.php b/classes/question/bank/legacy/sq_delete_action_column.php
deleted file mode 100644
index 7b20a013..00000000
--- a/classes/question/bank/legacy/sq_delete_action_column.php
+++ /dev/null
@@ -1,51 +0,0 @@
-.
-
-namespace mod_studentquiz\bank;
-
-use qbank_deletequestion\delete_action_column;
-use mod_studentquiz\local\studentquiz_helper;
-
-/**
- * Represent delete action in studentquiz_bank_view.
- *
- * @package mod_studentquiz
- * @copyright 2021 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class sq_delete_action_column extends delete_action_column {
-
- /**
- * Override method to get url and label for delete action of the studentquiz.
- *
- * @param \stdClass $question The row from the $question table, augmented with extra information.
- * @return array With three elements.
- * $url - The URL to perform the action.
- * $icon - The icon for this action.
- * $label - Text label to display in the UI (either in the menu, or as a tool-tip on the icon).
- */
- protected function get_url_icon_and_label(\stdClass $question): array {
-
- if ($question->state == studentquiz_helper::STATE_APPROVED &&
- !has_capability('mod/studentquiz:previewothers', $this->qbank->get_most_specific_context())) {
- // Do not render delete icon if the question is in approved state for the student.
- return [null, null, null];
- }
-
- return parent::get_url_icon_and_label($question);
- }
-
-}
diff --git a/classes/question/bank/legacy/sq_edit_action_column.php b/classes/question/bank/legacy/sq_edit_action_column.php
deleted file mode 100644
index 3feaf7d5..00000000
--- a/classes/question/bank/legacy/sq_edit_action_column.php
+++ /dev/null
@@ -1,51 +0,0 @@
-.
-
-namespace mod_studentquiz\bank;
-use qbank_editquestion\edit_action_column;
-use mod_studentquiz\local\studentquiz_helper;
-
-/**
- * Represent edit action in studentquiz_bank_view
- *
- * @package mod_studentquiz
- * @author Huong Nguyen
- * @copyright 2019 HSR (http://www.hsr.ch)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class sq_edit_action_column extends edit_action_column {
-
- /**
- * Override method to get url and label for edit action of the studentquiz.
- *
- * @param \stdClass $question The row from the $question table, augmented with extra information.
- * @return array With three elements.
- * $url - The URL to perform the action.
- * $icon - The icon for this action.
- * $label - Text label to display in the UI (either in the menu, or as a tool-tip on the icon)
- */
- protected function get_url_icon_and_label(\stdClass $question): array {
-
- if (($question->state == studentquiz_helper::STATE_APPROVED || $question->state == studentquiz_helper::STATE_DISAPPROVED) &&
- !has_capability('mod/studentquiz:previewothers', $this->qbank->get_most_specific_context())) {
- // Do not render Edit icon if Question is in approved/disapproved state for Student.
- return [null, null, null];
- }
-
- return parent::get_url_icon_and_label($question);
- }
-
-}
diff --git a/classes/question/bank/legacy/sq_edit_menu_column_pre_43.php b/classes/question/bank/legacy/sq_edit_menu_column_pre_43.php
deleted file mode 100644
index b1b6cf75..00000000
--- a/classes/question/bank/legacy/sq_edit_menu_column_pre_43.php
+++ /dev/null
@@ -1,38 +0,0 @@
-.
-
-namespace mod_studentquiz\bank;
-
-use core_question\local\bank\edit_menu_column;
-
-/**
- * Represent edit column in studentquiz_bank_view which gathers together all the actions into a menu.
- *
- * @package mod_studentquiz
- * @author Thong Bui
- * @copyright 2021 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class sq_edit_menu_column_pre_43 extends edit_menu_column {
- /**
- * Title for this column.
- *
- * @return string Title of column
- */
- public function get_title() {
- return get_string('actions');
- }
-}
diff --git a/classes/question/bank/legacy/sq_hidden_action_column.php b/classes/question/bank/legacy/sq_hidden_action_column.php
deleted file mode 100644
index ded3daeb..00000000
--- a/classes/question/bank/legacy/sq_hidden_action_column.php
+++ /dev/null
@@ -1,117 +0,0 @@
-.
-
-namespace mod_studentquiz\bank;
-
-use core_question\local\bank\menu_action_column_base;
-
-/**
- * Represent sq_hiden action in studentquiz_bank_view
- *
- * @package mod_studentquiz
- * @author Huong Nguyen
- * @copyright 2019 HSR (http://www.hsr.ch)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class sq_hidden_action_column extends menu_action_column_base {
- /** @var int */
- protected $currentuserid;
-
- /**
- * Initialise Parameters for join
- */
- protected function init(): void {
- global $USER;
- $this->currentuserid = $USER->id;
- parent::init();
- }
-
- /**
- * Column name
- *
- * @return string internal name for this column. Used as a CSS class name,
- * and to store information about the current sort. Must match PARAM_ALPHA.
- */
- public function get_name() {
- return 'sq_hidden';
- }
-
- /**
- * Return an array 'table_alias' => 'JOIN clause' to bring in any data that
- * this column required.
- *
- * The return values for all the columns will be checked. It is OK if two
- * columns join in the same table with the same alias and identical JOIN clauses.
- * If to columns try to use the same alias with different joins, you get an error.
- * The only table included by default is the question table, which is aliased to 'q'.
- *
- * It is important that your join simply adds additional data (or NULLs) to the
- * existing rows of the query. It must not cause additional rows.
- *
- * @return array 'table_alias' => 'JOIN clause'
- */
- public function get_extra_joins(): array {
- $hidden = "sqq.hidden = 0";
- $mine = "q.createdby = $this->currentuserid";
-
- // Without permission, a user can only see non-hidden question or its their own.
- $sqlextra = "AND ($hidden OR $mine)";
- if (has_capability('mod/studentquiz:previewothers', $this->qbank->get_most_specific_context())) {
- $sqlextra = "";
- }
-
- return ['sqh' => "JOIN {studentquiz_question} sqh ON sqh.id = qr.itemid $sqlextra"];
- }
-
- /**
- * Required columns
- *
- * @return array fields required. use table alias 'q' for the question table, or one of the
- * ones from get_extra_joins. Every field requested must specify a table prefix.
- */
- public function get_required_fields(): array {
- return ['sqq.hidden AS sq_hidden'];
- }
-
- /**
- * Override method to get url and label for show/hidden action of the studentquiz.
- *
- * @param \stdClass $question The row from the $question table, augmented with extra information.
- * @return array With three elements.
- * $url - The URL to perform the action.
- * $icon - The icon for this action.
- * $label - Text label to display in the UI (either in the menu, or as a tool-tip on the icon)
- */
- protected function get_url_icon_and_label(\stdClass $question): array {
- $courseid = $this->qbank->get_courseid();
- $cmid = $this->qbank->cm->id;
- if (has_capability('mod/studentquiz:previewothers', $this->qbank->get_most_specific_context())) {
- if ($question->sq_hidden) {
- $url = new \moodle_url('/mod/studentquiz/hideaction.php',
- ['studentquizquestionid' => $question->studentquizquestionid, 'sesskey' => sesskey(),
- 'courseid' => $courseid, 'hide' => 0, 'cmid' => $cmid, 'returnurl' => $this->qbank->base_url()]);
- return [$url, 't/show', get_string('show')];
- } else {
- $url = new \moodle_url('/mod/studentquiz/hideaction.php',
- ['studentquizquestionid' => $question->studentquizquestionid, 'sesskey' => sesskey(),
- 'courseid' => $courseid, 'hide' => 1, 'cmid' => $cmid, 'returnurl' => $this->qbank->base_url()]);
- return [$url, 't/hide', get_string('hide')];
- }
- }
-
- return [null, null, null];
- }
-}
diff --git a/classes/question/bank/legacy/sq_pin_action_column.php b/classes/question/bank/legacy/sq_pin_action_column.php
deleted file mode 100644
index d15d3a6a..00000000
--- a/classes/question/bank/legacy/sq_pin_action_column.php
+++ /dev/null
@@ -1,94 +0,0 @@
-.
-
-
-namespace mod_studentquiz\bank;
-
-use core_question\local\bank\menu_action_column_base;
-use moodle_url;
-
-/**
- * Represent pin action in studentquiz_bank_view
- *
- * @package mod_studentquiz
- * @copyright 2021 The Open University.
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class sq_pin_action_column extends menu_action_column_base {
- /** @var mod_studentquiz Renderer of student quiz. */
- protected $renderer;
-
- /**
- * Init method.
- */
- protected function init(): void {
- global $USER, $PAGE;
- $this->currentuserid = $USER->id;
- $this->renderer = $PAGE->get_renderer('mod_studentquiz');
- }
-
- /**
- * Get the internal name for this column.
- *
- * @return string Column name.
- */
- public function get_name() {
- return 'pin_toggle';
- }
-
- /**
- * Get required fields.
- *
- * @return array Fields required.
- */
- public function get_required_fields(): array {
- return array('sqq.pinned AS pinned');
- }
-
-
- /**
- * Override method to get url and label for pin action of the studentquiz.
- *
- * @param \stdClass $question The row from the $question table, augmented with extra information.
- * @return array With three elements.
- * $url - The URL to perform the action.
- * $icon - The icon for this action.
- * $label - Text label to display in the UI (either in the menu, or as a tool-tip on the icon)
- */
- protected function get_url_icon_and_label(\stdClass $question): array {
- $output = '';
- $courseid = $this->qbank->get_courseid();
- $cmid = $this->qbank->cm->id;
- if (has_capability('mod/studentquiz:pinquestion', $this->qbank->get_most_specific_context())) {
- if ($question->pinned) {
- $url = new moodle_url('/mod/studentquiz/pinaction.php',
- ['studentquizquestionid' => $question->studentquizquestionid,
- 'pin' => 0, 'sesskey' => sesskey(), 'cmid' => $cmid,
- 'returnurl' => $this->qbank->base_url(), 'courseid' => $courseid]);
- return [$url, 'i/star', get_string('unpin', 'studentquiz'), 'courseid' => $courseid];
- } else {
- $url = new moodle_url('/mod/studentquiz/pinaction.php',
- ['studentquizquestionid' => $question->studentquizquestionid,
- 'pin' => 1, 'sesskey' => sesskey(), 'cmid' => $cmid,
- 'returnurl' => $this->qbank->base_url(), 'courseid' => $courseid]);
- return [$url, 't/emptystar', get_string('pin', 'studentquiz')];
- }
- }
-
- return [null, null, null];
- }
-
-}
diff --git a/classes/question/bank/question_bank_filter.php b/classes/question/bank/question_bank_filter.php
index a5ca8269..eb7b5460 100644
--- a/classes/question/bank/question_bank_filter.php
+++ b/classes/question/bank/question_bank_filter.php
@@ -23,7 +23,6 @@
*/
defined('MOODLE_INTERNAL') || die();
-
require_once($CFG->dirroot . '/lib/formslib.php');
require_once($CFG->dirroot . '/user/filters/text.php');
require_once($CFG->dirroot . '/user/filters/date.php');
@@ -35,7 +34,7 @@
* @copyright 2017 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class mod_studentquiz_question_bank_filter_form extends moodleform {
+class mod_studentquiz_question_bank_filter_form extends \moodleform {
/**
* Filter fields of question bank
@@ -115,7 +114,7 @@ public function definition() {
* @author Huong Nguyen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class studentquiz_user_filter_text extends user_filter_text {
+class studentquiz_user_filter_text extends \user_filter_text {
/**
* Adds controls specific to this filter in the form.
@@ -144,7 +143,7 @@ public function setupForm(&$mform) { // @codingStandardsIgnoreLine
* @author Huong Nguyen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class studentquiz_user_filter_date extends user_filter_date {
+class studentquiz_user_filter_date extends \user_filter_date {
/**
* Adds controls specific to this filter in the form.
@@ -294,7 +293,7 @@ private function generate_creation_label($creationtext, $rowtext, $inputtext, $i
*
* They have no own value but refer a the target field which is set to a defined value once toggled.
*/
-class toggle_filter_checkbox extends user_filter_checkbox {
+class toggle_filter_checkbox extends \user_filter_checkbox {
/**
* Operator is a short form to express if the value
diff --git a/classes/question/bank/question_name_column.php b/classes/question/bank/question_name_column.php
index 5df50bda..3b5c5581 100644
--- a/classes/question/bank/question_name_column.php
+++ b/classes/question/bank/question_name_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* A column type for the name of the question name.
diff --git a/classes/question/bank/question_text_row.php b/classes/question/bank/question_text_row.php
index a7d0eb4d..3ada6e43 100644
--- a/classes/question/bank/question_text_row.php
+++ b/classes/question/bank/question_text_row.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* A column type for the name of the question name.
diff --git a/classes/question/bank/rate_column.php b/classes/question/bank/rate_column.php
index a1df9e0d..3b28f0c6 100644
--- a/classes/question/bank/rate_column.php
+++ b/classes/question/bank/rate_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* Represent rate column in studentquiz_bank_view
diff --git a/classes/question/bank/sq_delete_action.php b/classes/question/bank/sq_delete_action.php
index 5c811284..505af522 100644
--- a/classes/question/bank/sq_delete_action.php
+++ b/classes/question/bank/sq_delete_action.php
@@ -14,11 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
-use qbank_deletequestion\delete_action;
use mod_studentquiz\local\studentquiz_helper;
+if (!class_exists('\qbank_deletequestion\delete_action')) {
+ class_alias('\qbank_deletequestion\delete_action_column', '\qbank_deletequestion\delete_action');
+}
/**
* Represent delete action in studentquiz_bank_view.
*
@@ -26,7 +28,7 @@
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class sq_delete_action extends delete_action {
+class sq_delete_action extends \qbank_deletequestion\delete_action {
/**
* Override method to get url and label for delete action of the studentquiz.
diff --git a/classes/question/bank/sq_edit_action.php b/classes/question/bank/sq_edit_action.php
index 7cf12241..ec833483 100644
--- a/classes/question/bank/sq_edit_action.php
+++ b/classes/question/bank/sq_edit_action.php
@@ -14,11 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
-use qbank_editquestion\edit_action;
use mod_studentquiz\local\studentquiz_helper;
+if (!class_exists('\qbank_editquestion\edit_action')) {
+ class_alias('\qbank_editquestion\edit_action_column', '\qbank_editquestion\edit_action');
+}
/**
* Represent edit action in studentquiz_bank_view
*
@@ -27,7 +29,7 @@
* @copyright 2019 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class sq_edit_action extends edit_action {
+class sq_edit_action extends \qbank_editquestion\edit_action {
/**
* Override method to get url and label for edit action of the studentquiz.
diff --git a/classes/question/bank/sq_edit_menu_column.php b/classes/question/bank/sq_edit_menu_column.php
index 5e9b8237..61a8aba5 100644
--- a/classes/question/bank/sq_edit_menu_column.php
+++ b/classes/question/bank/sq_edit_menu_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
use core_question\local\bank\edit_menu_column;
@@ -39,18 +39,22 @@ class sq_edit_menu_column extends edit_menu_column {
*/
protected function display_content($question, $rowclasses): void {
global $OUTPUT;
- $actions = $this->qbank->get_question_actions();
+ if (method_exists($this->qbank, 'get_question_actions')) {
+ $actions = $this->qbank->get_question_actions();
- $menu = new \action_menu();
- $menu->set_menu_trigger(get_string('edit'));
- foreach ($actions as $action) {
- $action = $action->get_action_menu_link($question);
- if ($action) {
- $menu->add($action);
+ $menu = new \action_menu();
+ $menu->set_menu_trigger(get_string('edit'));
+ foreach ($actions as $action) {
+ $action = $action->get_action_menu_link($question);
+ if ($action) {
+ $menu->add($action);
+ }
}
- }
- echo $OUTPUT->render($menu);
+ echo $OUTPUT->render($menu);
+ } else {
+ parent::display_content($question, $rowclasses);
+ }
}
/**
diff --git a/classes/question/bank/sq_hidden_action.php b/classes/question/bank/sq_hidden_action.php
index 1409446a..f0558a32 100644
--- a/classes/question/bank/sq_hidden_action.php
+++ b/classes/question/bank/sq_hidden_action.php
@@ -14,10 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
-
-use core_question\local\bank\question_action_base;
+namespace mod_studentquiz\question\bank;
+if (!class_exists('\core_question\local\bank\question_action_base')) {
+ class_alias('\core_question\local\bank\menu_action_column_base', '\core_question\local\bank\question_action_base');
+}
/**
* Represent sq_hiden action in studentquiz_bank_view
*
@@ -26,7 +27,7 @@
* @copyright 2019 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class sq_hidden_action extends question_action_base {
+class sq_hidden_action extends \core_question\local\bank\question_action_base {
/** @var int */
protected $currentuserid;
diff --git a/classes/question/bank/sq_pin_action.php b/classes/question/bank/sq_pin_action.php
index 6c4d8fc7..73e95000 100644
--- a/classes/question/bank/sq_pin_action.php
+++ b/classes/question/bank/sq_pin_action.php
@@ -15,9 +15,12 @@
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
+
+if (!class_exists('\core_question\local\bank\question_action_base')) {
+ class_alias('\core_question\local\bank\menu_action_column_base', '\core_question\local\bank\question_action_base');
+}
-use core_question\local\bank\question_action_base;
use moodle_url;
/**
@@ -27,7 +30,7 @@
* @copyright 2021 The Open University.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class sq_pin_action extends question_action_base {
+class sq_pin_action extends \core_question\local\bank\question_action_base {
/** @var mod_studentquiz Renderer of student quiz. */
protected $renderer;
diff --git a/classes/question/bank/sq_preview_action.php b/classes/question/bank/sq_preview_action.php
index 99f09619..bffaeb8e 100644
--- a/classes/question/bank/sq_preview_action.php
+++ b/classes/question/bank/sq_preview_action.php
@@ -14,7 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
+
+if (!class_exists('\qbank_previewquestion\preview_action')) {
+ class_alias('\qbank_previewquestion\preview_action_column', '\qbank_previewquestion\preview_action');
+}
/**
* A action type for preview link to mod_studentquiz_preview
diff --git a/classes/question/bank/state_column.php b/classes/question/bank/state_column.php
index d88f9252..b6cfa8f8 100644
--- a/classes/question/bank/state_column.php
+++ b/classes/question/bank/state_column.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* Represent state column in studentquiz_bank_view
diff --git a/classes/question/bank/state_pin_column.php b/classes/question/bank/state_pin_column.php
index de3e382d..c76abb52 100644
--- a/classes/question/bank/state_pin_column.php
+++ b/classes/question/bank/state_pin_column.php
@@ -15,9 +15,7 @@
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
-
-use core_question\local\bank\action_column_base;
+namespace mod_studentquiz\question\bank;
/**
* Represent question is pinned or not in studentquiz_bank_view
diff --git a/classes/question/bank/studentquiz_bank_view.php b/classes/question/bank/studentquiz_bank_view.php
index 6af0f8fd..7a34ce18 100755
--- a/classes/question/bank/studentquiz_bank_view.php
+++ b/classes/question/bank/studentquiz_bank_view.php
@@ -33,26 +33,7 @@
use core_question\local\bank\column_manager_base;
defined('MOODLE_INTERNAL') || die();
-
-require_once(__DIR__ .'/../../../locallib.php');
-require_once(__DIR__ . '/studentquiz_column_base.php');
require_once(__DIR__ . '/question_bank_filter.php');
-require_once(__DIR__ . '/question_text_row.php');
-require_once(__DIR__ . '/rate_column.php');
-require_once(__DIR__ . '/difficulty_level_column.php');
-require_once(__DIR__ . '/tag_column.php');
-require_once(__DIR__ . '/attempts_column.php');
-require_once(__DIR__ . '/comments_column.php');
-require_once(__DIR__ . '/state_column.php');
-require_once(__DIR__ . '/state_pin_column.php');
-require_once(__DIR__ . '/anonym_creator_name_column.php');
-require_once(__DIR__ . '/question_name_column.php');
-require_once(__DIR__ . '/sq_edit_action.php');
-require_once(__DIR__ . '/sq_preview_action.php');
-require_once(__DIR__ . '/sq_delete_action.php');
-require_once(__DIR__ . '/sq_hidden_action.php');
-require_once(__DIR__ . '/sq_pin_action.php');
-require_once(__DIR__ . '/sq_edit_menu_column.php');
/**
* Module instance settings form
@@ -200,8 +181,8 @@ public function get_questions() {
*/
protected function default_sort(): array {
return [
- 'mod_studentquiz__bank__anonym_creator_name_column-timecreated' => SORT_DESC,
- 'mod_studentquiz__bank__question_name_column' => SORT_ASC,
+ 'mod_studentquiz__question__bank__anonym_creator_name_column-timecreated' => SORT_DESC,
+ 'mod_studentquiz__question__bank__question_name_column' => SORT_ASC,
];
}
@@ -649,7 +630,7 @@ protected function parse_subsort($sort): array {
// When we sort by public/private comments and turn off the setting studentquiz | privatecomment,
// the parse_subsort function will throw exception. We should redirect to the base_url after cleaning all sort params.
$showprivatecomment = $this->studentquiz->privatecommenting;
- if ($showprivatecomment && $sort == 'mod_studentquiz\bank\comment_column' ||
+ if ($showprivatecomment && $sort == 'mod_studentquiz\question\bank\comment_column' ||
!$showprivatecomment && ($sort == 'mod_studentquiz\bank\comment_column-privatecomment' ||
$sort == 'mod_studentquiz\bank\comment_column-publiccomment')) {
for ($i = 1; $i <= self::MAX_SORTS; $i++) {
@@ -691,11 +672,11 @@ protected function init_column_manager(): void {
*/
protected function init_question_actions(): void {
$this->questionactions = [
- new \mod_studentquiz\bank\sq_edit_action($this),
- new \mod_studentquiz\bank\sq_preview_action($this),
- new \mod_studentquiz\bank\sq_delete_action($this),
- new \mod_studentquiz\bank\sq_hidden_action($this),
- new \mod_studentquiz\bank\sq_pin_action($this),
+ new sq_edit_action($this),
+ new sq_preview_action($this),
+ new sq_delete_action($this),
+ new sq_hidden_action($this),
+ new sq_pin_action($this),
];
}
diff --git a/classes/question/bank/legacy/studentquiz_bank_view_pre_43.php b/classes/question/bank/studentquiz_bank_view_pre_43.php
similarity index 95%
rename from classes/question/bank/legacy/studentquiz_bank_view_pre_43.php
rename to classes/question/bank/studentquiz_bank_view_pre_43.php
index cf22661e..22deb333 100644
--- a/classes/question/bank/legacy/studentquiz_bank_view_pre_43.php
+++ b/classes/question/bank/studentquiz_bank_view_pre_43.php
@@ -31,26 +31,7 @@
use core_question\local\bank\question_version_status;
defined('MOODLE_INTERNAL') || die();
-
-require_once(__DIR__ .'/../../../../locallib.php');
-require_once(__DIR__ . '/../studentquiz_column_base.php');
-require_once(__DIR__ . '/../question_bank_filter.php');
-require_once(__DIR__ . '/../question_text_row.php');
-require_once(__DIR__ . '/../rate_column.php');
-require_once(__DIR__ . '/../difficulty_level_column.php');
-require_once(__DIR__ . '/../tag_column.php');
-require_once(__DIR__ . '/../attempts_column.php');
-require_once(__DIR__ . '/../comments_column.php');
-require_once(__DIR__ . '/../state_column.php');
-require_once(__DIR__ . '/../anonym_creator_name_column.php');
-require_once(__DIR__ . '/../state_pin_column.php');
-require_once(__DIR__ . '/../question_name_column.php');
-require_once(__DIR__ . '/preview_column.php');
-require_once(__DIR__ . '/sq_hidden_action_column.php');
-require_once(__DIR__ . '/sq_edit_action_column.php');
-require_once(__DIR__ . '/sq_pin_action_column.php');
-require_once(__DIR__ . '/sq_delete_action_column.php');
-require_once(__DIR__ . '/sq_edit_menu_column_pre_43.php');
+require_once(__DIR__ . '/question_bank_filter.php');
/**
* Module instance settings form
@@ -151,7 +132,7 @@ public function __construct($contexts, $pageurl, $course, $cm, $studentquiz, $pa
// Init search conditions with filterform state.
$categorycondition = new \core_question\bank\search\category_condition(
$pagevars['cat'], $pagevars['recurse'], $contexts, $pageurl, $course);
- $studentquizcondition = new \mod_studentquiz\condition\studentquiz_condition_pre_43($cm, $this->filterform,
+ $studentquizcondition = new \mod_studentquiz\condition\studentquiz_condition($cm, $this->filterform,
$this->report, $studentquiz);
$this->isfilteractive = $studentquizcondition->is_filter_active();
$this->searchconditions = array ($categorycondition, $studentquizcondition);
@@ -225,8 +206,8 @@ public function get_questions() {
*/
protected function default_sort(): array {
return [
- 'mod_studentquiz\bank\anonym_creator_name_column-timecreated' => -1,
- 'mod_studentquiz\bank\question_name_column' => 1,
+ 'mod_studentquiz\question\bank\anonym_creator_name_column-timecreated' => -1,
+ 'mod_studentquiz\question\bank\question_name_column' => 1,
];
}
@@ -655,7 +636,7 @@ protected function parse_subsort($sort): array {
// When we sort by public/private comments and turn off the setting studentquiz | privatecomment,
// the parse_subsort function will throw exception. We should redirect to the base_url after cleaning all sort params.
$showprivatecomment = $this->studentquiz->privatecommenting;
- if ($showprivatecomment && $sort == 'mod_studentquiz\bank\comment_column' ||
+ if ($showprivatecomment && $sort == 'mod_studentquiz\question\bank\comment_column' ||
!$showprivatecomment && ($sort == 'mod_studentquiz\bank\comment_column-privatecomment' ||
$sort == 'mod_studentquiz\bank\comment_column-publiccomment')) {
for ($i = 1; $i <= self::MAX_SORTS; $i++) {
diff --git a/classes/question/bank/studentquiz_column_base.php b/classes/question/bank/studentquiz_column_base.php
index a7028e95..8bb43dbb 100644
--- a/classes/question/bank/studentquiz_column_base.php
+++ b/classes/question/bank/studentquiz_column_base.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
/**
* Represent studentquiz column base in studentquiz_bank_view
diff --git a/classes/question/bank/tag_column.php b/classes/question/bank/tag_column.php
index 636257f6..793d9c5f 100644
--- a/classes/question/bank/tag_column.php
+++ b/classes/question/bank/tag_column.php
@@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-namespace mod_studentquiz\bank;
+namespace mod_studentquiz\question\bank;
defined('MOODLE_INTERNAL') || die();
diff --git a/renderer.php b/renderer.php
old mode 100755
new mode 100644
index 94fa02fe..5051edd0
--- a/renderer.php
+++ b/renderer.php
@@ -26,6 +26,7 @@
use mod_studentquiz\local\studentquiz_helper;
use mod_studentquiz\utils;
use mod_studentquiz\local\studentquiz_question;
+use mod_studentquiz\question\bank\studentquiz_bank_view_pre_43;
use mod_studentquiz\question\bank\studentquiz_bank_view;
defined('MOODLE_INTERNAL') || die();
@@ -917,53 +918,53 @@ public function render_report_more_link($url) {
/**
* Get all the required columns for StudentQuiz view.
*
- * @param mod_studentquiz\question\bank\studentquiz_bank_view $view
+ * @param studentquiz_bank_view $view
* @return array
*/
- public function get_columns_for_question_bank_view(mod_studentquiz\question\bank\studentquiz_bank_view $view) {
+ public function get_columns_for_question_bank_view(studentquiz_bank_view $view) {
return [
new core_question\local\bank\checkbox_column($view),
new qbank_viewquestiontype\question_type_column($view),
- new \mod_studentquiz\bank\state_column($view),
- new \mod_studentquiz\bank\state_pin_column($view),
- new \mod_studentquiz\bank\question_name_column($view),
- new \mod_studentquiz\bank\sq_edit_menu_column($view),
+ new \mod_studentquiz\question\bank\state_column($view),
+ new \mod_studentquiz\question\bank\state_pin_column($view),
+ new \mod_studentquiz\question\bank\question_name_column($view),
+ new \mod_studentquiz\question\bank\sq_edit_menu_column($view),
new qbank_history\version_number_column($view),
- new \mod_studentquiz\bank\anonym_creator_name_column($view),
- new \mod_studentquiz\bank\tag_column($view),
- new \mod_studentquiz\bank\attempts_column($view),
- new \mod_studentquiz\bank\difficulty_level_column($view),
- new \mod_studentquiz\bank\rate_column($view),
- new \mod_studentquiz\bank\comment_column($view),
+ new \mod_studentquiz\question\bank\anonym_creator_name_column($view),
+ new \mod_studentquiz\question\bank\tag_column($view),
+ new \mod_studentquiz\question\bank\attempts_column($view),
+ new \mod_studentquiz\question\bank\difficulty_level_column($view),
+ new \mod_studentquiz\question\bank\rate_column($view),
+ new \mod_studentquiz\question\bank\comment_column($view),
];
}
/**
* Get all the required columns for StudentQuiz view.
*
- * @param mod_studentquiz\question\bank\studentquiz_bank_view_pre_43 $view
+ * @param studentquiz_bank_view_pre_43 $view
* @return array
*/
- public function get_columns_for_question_bank_view_pre_43(mod_studentquiz\question\bank\studentquiz_bank_view_pre_43 $view) {
+ public function get_columns_for_question_bank_view_pre_43(studentquiz_bank_view_pre_43 $view) {
return [
new core_question\local\bank\checkbox_column($view),
new qbank_viewquestiontype\question_type_column($view),
- new \mod_studentquiz\bank\state_column($view),
- new \mod_studentquiz\bank\state_pin_column($view),
- new \mod_studentquiz\bank\question_name_column($view),
- new \mod_studentquiz\bank\sq_edit_action_column($view),
- new \mod_studentquiz\bank\preview_column($view),
- new \mod_studentquiz\bank\sq_delete_action_column($view),
- new \mod_studentquiz\bank\sq_hidden_action_column($view),
- new \mod_studentquiz\bank\sq_pin_action_column($view),
- new \mod_studentquiz\bank\sq_edit_menu_column_pre_43($view),
+ new \mod_studentquiz\question\bank\state_column($view),
+ new \mod_studentquiz\question\bank\state_pin_column($view),
+ new \mod_studentquiz\question\bank\question_name_column($view),
+ new \mod_studentquiz\question\bank\sq_edit_action($view),
+ new \mod_studentquiz\question\bank\sq_preview_action($view),
+ new \mod_studentquiz\question\bank\sq_delete_action($view),
+ new \mod_studentquiz\question\bank\sq_hidden_action($view),
+ new \mod_studentquiz\question\bank\sq_pin_action($view),
+ new \mod_studentquiz\question\bank\sq_edit_menu_column($view),
new qbank_history\version_number_column($view),
- new \mod_studentquiz\bank\anonym_creator_name_column($view),
- new \mod_studentquiz\bank\tag_column($view),
- new \mod_studentquiz\bank\attempts_column($view),
- new \mod_studentquiz\bank\difficulty_level_column($view),
- new \mod_studentquiz\bank\rate_column($view),
- new \mod_studentquiz\bank\comment_column($view),
+ new \mod_studentquiz\question\bank\anonym_creator_name_column($view),
+ new \mod_studentquiz\question\bank\tag_column($view),
+ new \mod_studentquiz\question\bank\attempts_column($view),
+ new \mod_studentquiz\question\bank\difficulty_level_column($view),
+ new \mod_studentquiz\question\bank\rate_column($view),
+ new \mod_studentquiz\question\bank\comment_column($view),
];
}
diff --git a/tests/bank_performance_test.php b/tests/bank_performance_test.php
index 23977224..b9a36e52 100644
--- a/tests/bank_performance_test.php
+++ b/tests/bank_performance_test.php
@@ -18,16 +18,10 @@
use mod_studentquiz\question\bank\studentquiz_bank_view;
use mod_studentquiz\question\bank\studentquiz_bank_view_pre_43;
-use mod_studentquiz\utils;
defined('MOODLE_INTERNAL') || die();
global $CFG;
-if (utils::moodle_version_is("<=", "42")) {
- require_once($CFG->dirroot . '/mod/studentquiz/classes/question/bank/legacy/studentquiz_bank_view_pre_43.php');
-} else {
- require_once($CFG->dirroot . '/mod/studentquiz/classes/question/bank/studentquiz_bank_view.php');
-}
require_once($CFG->dirroot . '/mod/studentquiz/reportlib.php');
require_once($CFG->dirroot . '/lib/questionlib.php');
require_once($CFG->dirroot . '/question/editlib.php');
diff --git a/tests/bank_view_test.php b/tests/bank_view_test.php
index 856d03bc..22686fa2 100644
--- a/tests/bank_view_test.php
+++ b/tests/bank_view_test.php
@@ -23,11 +23,6 @@
defined('MOODLE_INTERNAL') || die();
global $CFG;
-if (utils::moodle_version_is("<=", "42")) {
- require_once($CFG->dirroot . '/mod/studentquiz/classes/question/bank/legacy/studentquiz_bank_view_pre_43.php');
-} else {
- require_once($CFG->dirroot . '/mod/studentquiz/classes/question/bank/studentquiz_bank_view.php');
-}
require_once($CFG->dirroot . '/mod/studentquiz/reportlib.php');
require_once($CFG->dirroot . '/lib/questionlib.php');
require_once($CFG->dirroot . '/question/editlib.php');
@@ -120,20 +115,20 @@ public function run_questionbank() {
$report = new \mod_studentquiz_report($this->cm->id);
if (utils::moodle_version_is("<=", "42")) {
$questionbank = new studentquiz_bank_view_pre_43(
- new \core_question\local\bank\question_edit_contexts(\context_module::instance($this->cm->id))
- , new \moodle_url('/mod/studentquiz/view.php', array('cmid' => $this->cm->id))
- , $this->course
- , $this->cm
- , $this->studentquiz
- , $pagevars, $report);
+ new \core_question\local\bank\question_edit_contexts(\context_module::instance($this->cm->id)),
+ new \moodle_url('/mod/studentquiz/view.php', ['cmid' => $this->cm->id]),
+ $this->course,
+ $this->cm,
+ $this->studentquiz,
+ $pagevars, $report);
} else {
$questionbank = new studentquiz_bank_view(
- new \core_question\local\bank\question_edit_contexts(\context_module::instance($this->cm->id))
- , new \moodle_url('/mod/studentquiz/view.php', array('cmid' => $this->cm->id))
- , $this->course
- , $this->cm
- , $this->studentquiz
- , $pagevars, $report);
+ new \core_question\local\bank\question_edit_contexts(\context_module::instance($this->cm->id)),
+ new \moodle_url('/mod/studentquiz/view.php', ['cmid' => $this->cm->id]),
+ $this->course,
+ $this->cm,
+ $this->studentquiz,
+ $pagevars, $report);
}
return $questionbank;
}
@@ -184,36 +179,36 @@ public function test_wanted_columns() {
if ($below42) {
$this->assertInstanceOf('core_question\local\bank\checkbox_column', $requiredcolumns[0]);
$this->assertInstanceOf('qbank_viewquestiontype\question_type_column', $requiredcolumns[1]);
- $this->assertInstanceOf('mod_studentquiz\bank\state_column', $requiredcolumns[2]);
- $this->assertInstanceOf('mod_studentquiz\bank\state_pin_column', $requiredcolumns[3]);
- $this->assertInstanceOf('mod_studentquiz\bank\question_name_column', $requiredcolumns[4]);
- $this->assertInstanceOf('mod_studentquiz\bank\sq_edit_action_column', $requiredcolumns[5]);
- $this->assertInstanceOf('mod_studentquiz\bank\preview_column', $requiredcolumns[6]);
- $this->assertInstanceOf('mod_studentquiz\bank\sq_delete_action_column', $requiredcolumns[7]);
- $this->assertInstanceOf('mod_studentquiz\bank\sq_hidden_action_column', $requiredcolumns[8]);
- $this->assertInstanceOf('mod_studentquiz\bank\sq_pin_action_column', $requiredcolumns[9]);
- $this->assertInstanceOf('mod_studentquiz\bank\sq_edit_menu_column_pre_43', $requiredcolumns[10]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\state_column', $requiredcolumns[2]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\state_pin_column', $requiredcolumns[3]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\question_name_column', $requiredcolumns[4]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\sq_edit_action', $requiredcolumns[5]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\sq_preview_action', $requiredcolumns[6]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\sq_delete_action', $requiredcolumns[7]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\sq_hidden_action', $requiredcolumns[8]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\sq_pin_action', $requiredcolumns[9]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\sq_edit_menu_column', $requiredcolumns[10]);
$this->assertInstanceOf('qbank_history\version_number_column', $requiredcolumns[11]);
- $this->assertInstanceOf('mod_studentquiz\bank\anonym_creator_name_column', $requiredcolumns[12]);
- $this->assertInstanceOf('mod_studentquiz\bank\tag_column', $requiredcolumns[13]);
- $this->assertInstanceOf('mod_studentquiz\bank\attempts_column', $requiredcolumns[14]);
- $this->assertInstanceOf('mod_studentquiz\bank\difficulty_level_column', $requiredcolumns[15]);
- $this->assertInstanceOf('mod_studentquiz\bank\rate_column', $requiredcolumns[16]);
- $this->assertInstanceOf('mod_studentquiz\bank\comment_column', $requiredcolumns[17]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\anonym_creator_name_column', $requiredcolumns[12]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\tag_column', $requiredcolumns[13]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\attempts_column', $requiredcolumns[14]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\difficulty_level_column', $requiredcolumns[15]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\rate_column', $requiredcolumns[16]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\comment_column', $requiredcolumns[17]);
} else {
$this->assertInstanceOf('core_question\local\bank\checkbox_column', $requiredcolumns[0]);
$this->assertInstanceOf('qbank_viewquestiontype\question_type_column', $requiredcolumns[1]);
- $this->assertInstanceOf('mod_studentquiz\bank\state_column', $requiredcolumns[2]);
- $this->assertInstanceOf('mod_studentquiz\bank\state_pin_column', $requiredcolumns[3]);
- $this->assertInstanceOf('mod_studentquiz\bank\question_name_column', $requiredcolumns[4]);
- $this->assertInstanceOf('\mod_studentquiz\bank\sq_edit_menu_column', $requiredcolumns[5]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\state_column', $requiredcolumns[2]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\state_pin_column', $requiredcolumns[3]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\question_name_column', $requiredcolumns[4]);
+ $this->assertInstanceOf('\mod_studentquiz\question\bank\sq_edit_menu_column', $requiredcolumns[5]);
$this->assertInstanceOf('qbank_history\version_number_column', $requiredcolumns[6]);
- $this->assertInstanceOf('mod_studentquiz\bank\anonym_creator_name_column', $requiredcolumns[7]);
- $this->assertInstanceOf('mod_studentquiz\bank\tag_column', $requiredcolumns[8]);
- $this->assertInstanceOf('mod_studentquiz\bank\attempts_column', $requiredcolumns[9]);
- $this->assertInstanceOf('mod_studentquiz\bank\difficulty_level_column', $requiredcolumns[10]);
- $this->assertInstanceOf('mod_studentquiz\bank\rate_column', $requiredcolumns[11]);
- $this->assertInstanceOf('mod_studentquiz\bank\comment_column', $requiredcolumns[12]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\anonym_creator_name_column', $requiredcolumns[7]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\tag_column', $requiredcolumns[8]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\attempts_column', $requiredcolumns[9]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\difficulty_level_column', $requiredcolumns[10]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\rate_column', $requiredcolumns[11]);
+ $this->assertInstanceOf('mod_studentquiz\question\bank\comment_column', $requiredcolumns[12]);
}
}
diff --git a/viewlib.php b/viewlib.php
index 54da39d7..1641e484 100755
--- a/viewlib.php
+++ b/viewlib.php
@@ -169,7 +169,6 @@ private function load_questionbank() {
}
$this->qbpagevar = array_merge($pagevars, $params);
if (utils::moodle_version_is("<=", "42")) {
- require_once($CFG->dirroot . '/mod/studentquiz/classes/question/bank/legacy/studentquiz_bank_view_pre_43.php');
$this->questionbank = new \mod_studentquiz\question\bank\studentquiz_bank_view_pre_43(
$contexts, $thispageurl, $this->course, $this->cm, $this->studentquiz, $pagevars, $this->report);
} else {