Skip to content

Commit

Permalink
Fixed delete and move for questions in edit, and also added tag searc…
Browse files Browse the repository at this point in the history
…h condition
  • Loading branch information
sebastsg committed Sep 12, 2018
1 parent ceab235 commit e61ac0c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions classes/bank/jazzquiz_question_bank_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

defined('MOODLE_INTERNAL') || die();

use \core_question\bank\search\tag_condition as tag_condition;
use \core_question\bank\search\hidden_condition as hidden_condition;
use \core_question\bank\search\category_condition as category_condition;

Expand Down Expand Up @@ -73,15 +74,19 @@ protected function wanted_columns() {
* @param array $tagids
*/
public function display($tabname, $page, $perpage, $cat, $recurse, $showhidden, $showquestiontext, $tagids = []) {
global $OUTPUT;
global $PAGE;

if ($this->process_actions_needing_ui()) {
return;
}
$contexts = $this->contexts->having_one_edit_tab_cap($tabname);
list($categoryid, $contextid) = explode(',', $cat);
$catcontext = \context::instance_by_id($contextid);
$thiscontext = $this->get_most_specific_context();

// Category selection form.
echo $OUTPUT->heading(get_string('questionbank', 'question'), 2);
$this->display_question_bank_header();
array_unshift($this->searchconditions, new tag_condition([$catcontext, $thiscontext], $tagids));
array_unshift($this->searchconditions, new hidden_condition(!$showhidden));
array_unshift($this->searchconditions, new category_condition($cat, $recurse, $contexts, $this->baseurl, $this->course));
$this->display_options_form($showquestiontext, '/mod/jazzquiz/edit.php');
Expand All @@ -99,6 +104,8 @@ public function display($tabname, $page, $perpage, $cat, $recurse, $showhidden,
$showquestiontext,
$this->contexts->having_cap('moodle/question:add')
);

$PAGE->requires->js_call_amd('core_question/edit_tags', 'init', ['#questionscontainer']);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function jazzquiz_edit_list_questions($jazzquiz, $contexts, $url, $pagevars) {
* View edit page.
*/
function jazzquiz_edit() {
global $PAGE;
global $PAGE, $COURSE;

$action = optional_param('action', 'listquestions', PARAM_ALPHA);

Expand Down Expand Up @@ -161,6 +161,10 @@ function jazzquiz_edit() {
return;
}

// Process moving, deleting and unhiding questions...
$questionbank = new \core_question\bank\view($contexts, $url, $COURSE, $cm);
$questionbank->process_actions();

switch ($action) {
case 'order':
jazzquiz_edit_order($jazzquiz);
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2018091206; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2018091207; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2016052304; // Moodle 3.1 (or above)
$plugin->cron = 0; // Period in seconds for cron to run.
$plugin->component = 'mod_jazzquiz';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '0.8.2 (Build: 2018091206)';
$plugin->release = '0.8.2 (Build: 2018091207)';

0 comments on commit e61ac0c

Please sign in to comment.