MDL-79870 qtype_ordering: Remove unused code

Part of: MDL-79863
This commit is contained in:
Mathew May 2024-04-04 15:45:26 +08:00
parent cf1bcfce18
commit 36822f0c0a
2 changed files with 8 additions and 57 deletions

View File

@ -14,15 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for qtype_ordering.
*
* @package qtype_ordering
* @copyright 2013 Gordon Bateson (gordon.bateson@gmail.com)
* @author rdebleu@eWallah.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace qtype_ordering\privacy;
/**
@ -35,17 +26,13 @@ namespace qtype_ordering\privacy;
*/
class provider implements \core_privacy\local\metadata\null_provider {
// This polyfill allows the provider to work on both old (pre-7)
// and new PHP versions. Thanks to Tim Hunt for this suggestion.
use \core_privacy\local\legacy_polyfill;
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function _get_reason() { // phpcs:ignore
public static function get_reason(): string {
return 'privacy:metadata';
}
}

View File

@ -81,7 +81,7 @@ class qtype_ordering_edit_form extends question_edit_form {
$options = qtype_ordering_question::get_layout_types();
$mform->addElement('select', $name, $label, $options);
$mform->addHelpButton($name, $name, $plugin);
$mform->setDefault($name, $this->get_my_default_value($name, qtype_ordering_question::LAYOUT_VERTICAL));
$mform->setDefault($name, $this->get_default_value($name, qtype_ordering_question::LAYOUT_VERTICAL));
// Field for selecttype.
$name = 'selecttype';
@ -89,7 +89,7 @@ class qtype_ordering_edit_form extends question_edit_form {
$options = qtype_ordering_question::get_select_types();
$mform->addElement('select', $name, $label, $options);
$mform->addHelpButton($name, $name, $plugin);
$mform->setDefault($name, $this->get_my_default_value($name, qtype_ordering_question::SELECT_ALL));
$mform->setDefault($name, $this->get_default_value($name, qtype_ordering_question::SELECT_ALL));
// Field for selectcount.
$name = 'selectcount';
@ -109,7 +109,7 @@ class qtype_ordering_edit_form extends question_edit_form {
$options = qtype_ordering_question::get_grading_types();
$mform->addElement('select', $name, $label, $options);
$mform->addHelpButton($name, $name, $plugin);
$mform->setDefault($name, $this->get_my_default_value($name, qtype_ordering_question::GRADING_ABSOLUTE_POSITION));
$mform->setDefault($name, $this->get_default_value($name, qtype_ordering_question::GRADING_ABSOLUTE_POSITION));
// Field for showgrading.
$name = 'showgrading';
@ -118,14 +118,14 @@ class qtype_ordering_edit_form extends question_edit_form {
1 => get_string('show'));
$mform->addElement('select', $name, $label, $options);
$mform->addHelpButton($name, $name, $plugin);
$mform->setDefault($name, $this->get_my_default_value($name, 1));
$mform->setDefault($name, $this->get_default_value($name, 1));
$name = 'numberingstyle';
$label = get_string($name, $plugin);
$options = qtype_ordering_question::get_numbering_styles();
$mform->addElement('select', $name, $label, $options);
$mform->addHelpButton($name, $name, $plugin);
$mform->setDefault($name, $this->get_my_default_value($name, qtype_ordering_question::NUMBERING_STYLE_DEFAULT));
$mform->setDefault($name, $this->get_default_value($name, qtype_ordering_question::NUMBERING_STYLE_DEFAULT));
$elements = array();
$options = array();
@ -384,7 +384,7 @@ class qtype_ordering_edit_form extends question_edit_form {
if (isset($question->options->$name)) {
$question->$name = $question->options->$name;
} else {
$question->$name = $this->get_my_default_value($name, $default);
$question->$name = $this->get_default_value($name, $default);
}
}
@ -458,7 +458,7 @@ class qtype_ordering_edit_form extends question_edit_form {
'gradingtype', 'showgrading', 'numberingstyle');
foreach ($fields as $field) {
if (array_key_exists($field, $data)) {
$this->set_my_default_value($field, $data[$field]);
question_bank::get_qtype($this->qtype())->set_default_value($field, $data[$field]);
}
}
}
@ -477,42 +477,6 @@ class qtype_ordering_edit_form extends question_edit_form {
return $this->plugin_name()."_$name";
}
/**
* Saves default value for item
*
* @param string $name Item name
* @param string|mixed|null $value
* @return boolean (usually TRUE, unless there is an error)
*/
protected function set_my_default_value($name, $value) {
if (method_exists($this, 'set_default_value')) {
// This method doesn't exist yet, but it might one day ;-).
return $this->set_default_value($name, $value);
} else {
// Until at least Moodle <= 4.0, we expect to come this way.
$name = $this->get_my_preference_name($name);
return set_user_preferences(array($name => $value));
}
}
/**
* Returns default value for item
*
* @param string $name Item name
* @param string|mixed|null $default Default value (optional, default = null)
* @return string|mixed|null Default value for field with this $name
*/
protected function get_my_default_value($name, $default) {
if (method_exists($this, 'get_default_value')) {
// Moodle >= 3.10.
return $this->get_default_value($name, $default);
} else {
// Moodle <= 3.9.
$name = $this->get_my_preference_name($name);
return get_user_preferences($name, $default);
}
}
/**
* Get array of countable item types
*