Skip to content

Commit

Permalink
Update code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvu committed Jan 17, 2024
1 parent 7f9978d commit fa1b86b
Show file tree
Hide file tree
Showing 33 changed files with 164 additions and 877 deletions.
1 change: 0 additions & 1 deletion .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 29 additions & 26 deletions classes/condition/studentquiz_condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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) {

Expand Down Expand Up @@ -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]);
}
}
}
Expand Down Expand Up @@ -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;
}
}
251 changes: 0 additions & 251 deletions classes/condition/studentquiz_condition_pre_43.php

This file was deleted.

2 changes: 1 addition & 1 deletion classes/question/bank/anonym_creator_name_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_studentquiz\bank;
namespace mod_studentquiz\question\bank;

/**
* A column type for the name of the question creator.
Expand Down
2 changes: 1 addition & 1 deletion classes/question/bank/attempts_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_studentquiz\bank;
namespace mod_studentquiz\question\bank;

/**
* Represent performances column in studentquiz_bank_view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_studentquiz\bank;
namespace mod_studentquiz\question\bank;

use mod_studentquiz\utils;

Expand Down
2 changes: 1 addition & 1 deletion classes/question/bank/difficulty_level_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_studentquiz\bank;
namespace mod_studentquiz\question\bank;

/**
* Representing difficulty level column in studentquiz_bank_view
Expand Down
Loading

0 comments on commit fa1b86b

Please sign in to comment.