mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-74054 mod_quiz: Prevent question bank customisations in custom view
This commit is contained in:
parent
93ca1cdc32
commit
82599bef84
mod/quiz
@ -28,7 +28,9 @@ namespace mod_quiz\question\bank;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core\output\datafilter;
|
||||
use core_question\local\bank\column_base;
|
||||
use core_question\local\bank\condition;
|
||||
use core_question\local\bank\column_manager_base;
|
||||
use core_question\local\bank\question_version_status;
|
||||
use mod_quiz\question\bank\filter\custom_category_condition;
|
||||
use qbank_managecategories\category_condition;
|
||||
@ -79,7 +81,7 @@ class custom_view extends \core_question\local\bank\view {
|
||||
}
|
||||
}
|
||||
|
||||
$this->init_required_columns();
|
||||
$this->init_columns($this->wanted_columns(), $this->heading_column());
|
||||
parent::__construct($contexts, $pageurl, $course, $cm, $params, $extraparams);
|
||||
[$this->quiz, ] = get_module_from_cmid($cm->id);
|
||||
$this->set_quiz_has_attempts(quiz_has_attempts($this->quiz->id));
|
||||
@ -87,55 +89,42 @@ class custom_view extends \core_question\local\bank\view {
|
||||
}
|
||||
|
||||
/**
|
||||
* Init required columns.
|
||||
* Just use the base column manager in this view.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init_required_columns(): void {
|
||||
// Override core columns.
|
||||
$this->corequestionbankcolumns = [
|
||||
'add_action_column',
|
||||
'checkbox_column',
|
||||
'question_type_column',
|
||||
'question_name_text_column',
|
||||
'preview_action_column'
|
||||
];
|
||||
protected function init_column_manager(): void {
|
||||
$this->columnmanager = new column_manager_base();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class for each question bank columns.
|
||||
* Don't display plugin controls.
|
||||
*
|
||||
* @return array
|
||||
* @param \core\context $context
|
||||
* @param int $categoryid
|
||||
* @return string
|
||||
*/
|
||||
protected function get_class_for_columns(): array {
|
||||
protected function get_plugin_controls(\core\context $context, int $categoryid): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function get_question_bank_plugins(): array {
|
||||
$questionbankclasscolumns = [];
|
||||
if (question_get_display_preference('qbshowtext', 0, PARAM_INT, new \moodle_url(''))) {
|
||||
$this->corequestionbankcolumns[] = 'question_text_row';
|
||||
}
|
||||
foreach ($this->corequestionbankcolumns as $fullname) {
|
||||
$shortname = $fullname;
|
||||
if (class_exists('mod_quiz\\question\\bank\\' . $fullname)) {
|
||||
$fullname = 'mod_quiz\\question\\bank\\' . $fullname;
|
||||
$questionbankclasscolumns[$shortname] = new $fullname($this);
|
||||
} else if (class_exists('core_question\\local\\bank\\' . $fullname)) {
|
||||
$fullname = 'core_question\\local\\bank\\' . $fullname;
|
||||
$questionbankclasscolumns[$shortname] = new $fullname($this);
|
||||
} else {
|
||||
$questionbankclasscolumns[$shortname] = '';
|
||||
$customviewcolumns = [
|
||||
'mod_quiz\question\bank\add_action_column' . column_base::ID_SEPARATOR . 'add_action_column',
|
||||
'core_question\local\bank\checkbox_column' . column_base::ID_SEPARATOR . 'checkbox_column',
|
||||
'qbank_viewquestiontype\question_type_column' . column_base::ID_SEPARATOR . 'question_type_column',
|
||||
'mod_quiz\question\bank\question_name_text_column' . column_base::ID_SEPARATOR . 'question_name_text_column',
|
||||
'mod_quiz\question\bank\preview_action_column' . column_base::ID_SEPARATOR . 'preview_action_column',
|
||||
];
|
||||
|
||||
foreach ($customviewcolumns as $columnid) {
|
||||
[$columnclass, $columnname] = explode(column_base::ID_SEPARATOR, $columnid, 2);
|
||||
if (class_exists($columnclass)) {
|
||||
$questionbankclasscolumns[$columnid] = $columnclass::from_column_name($this, $columnname);
|
||||
}
|
||||
}
|
||||
return $questionbankclasscolumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of qbank plugins with available objects for features.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_question_bank_plugins(): array {
|
||||
// The view is too crowded, exclude some columns.
|
||||
$questionbankclasscolumns = parent::get_question_bank_plugins();
|
||||
$questionbankclasscolumns = array_intersect_key($questionbankclasscolumns, array_flip($this->corequestionbankcolumns));
|
||||
return $questionbankclasscolumns;
|
||||
}
|
||||
|
||||
|
@ -801,7 +801,7 @@ table.quizreviewsummary td.cell {
|
||||
margin: 0 0.2em;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit #categoryquestions .questionname,
|
||||
#page-mod-quiz-edit .question-bank-table .questionname,
|
||||
#page-mod-quiz-edit ul.slots li.activity div.activityinstance .questionname {
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
@ -845,91 +845,105 @@ table.quizreviewsummary td.cell {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#categoryquestions .header {
|
||||
#page-mod-quiz-edit .question-bank-table {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit .question-bank-table .header {
|
||||
text-align: center;
|
||||
padding: 0 2px;
|
||||
border: 0 none;
|
||||
vertical-align: top;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#categoryquestions .header.checkbox {
|
||||
#page-mod-quiz-edit .question-bank-table .header.checkbox {
|
||||
vertical-align: bottom;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#categoryquestions .header.qtype {
|
||||
#page-mod-quiz-edit .question-bank-table .header.qtype .sorters {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#categoryquestions th .sorters {
|
||||
#page-mod-quiz-edit .question-bank-table th .sorters {
|
||||
font-weight: normal;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
#categoryquestions td.modifiername,
|
||||
#categoryquestions td.creatorname,
|
||||
#categoryquestions td.questionlastused {
|
||||
#page-mod-quiz-edit .question-bank-table td.modifiername,
|
||||
#page-mod-quiz-edit .question-bank-table td.creatorname,
|
||||
#page-mod-quiz-edit .question-bank-table td.questionlastused {
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
#categoryquestions td.modifiername span.date,
|
||||
#categoryquestions td.creatorname span.date {
|
||||
#page-mod-quiz-edit .question-bank-table td.modifiername span.date,
|
||||
#page-mod-quiz-edit .question-bank-table td.creatorname span.date {
|
||||
font-weight: normal;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
table#categoryquestions {
|
||||
width: 100%;
|
||||
#page-mod-quiz-edit table.question-bank-table {
|
||||
table-layout: fixed;
|
||||
overflow-x: visible;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
#categoryquestions .iconcol {
|
||||
width: 15px;
|
||||
#page-mod-quiz-edit .question-bank-table .iconcol {
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
}
|
||||
#page-mod-quiz-edit .question-bank-table .iconcol .icon {
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit .question-bank-table .checkbox {
|
||||
width: 32px;
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#categoryquestions .checkbox {
|
||||
width: 19px;
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#categoryquestions .editmenu {
|
||||
#page-mod-quiz-edit .question-bank-table .editmenu {
|
||||
width: 5em;
|
||||
}
|
||||
|
||||
#categoryquestions .qtype {
|
||||
#page-mod-quiz-edit .question-bank-table .qtype {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#categoryquestions .qtype {
|
||||
#page-mod-quiz-edit .question-bank-table .qtype {
|
||||
width: 28px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#categoryquestions .questiontext {
|
||||
#page-mod-quiz-edit .question-bank-table .questionnametext {
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit .question-bank-table .questiontext {
|
||||
position: relative;
|
||||
zoom: 1;
|
||||
padding-left: 0.3em;
|
||||
padding: 0.3em;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
#categoryquestions .questionname {
|
||||
#page-mod-quiz-edit .question-bank-table .questionname {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
zoom: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#categoryquestions .questiontext p {
|
||||
#page-mod-quiz-edit .question-bank-table .questiontext p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#page-mod-quiz-edit table#categoryquestions td,
|
||||
#page-mod-quiz-edit table#categoryquestions th {
|
||||
#page-mod-quiz-edit table.question-bank-table td,
|
||||
#page-mod-quiz-edit table.question-bank-table th {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user