MDL-79863 qtype_ordering: Update comments and remove unused functions
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -14,12 +14,10 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Generic library to allow things in a vertical list to be re-ordered using drag and drop.
|
||||
*
|
||||
* To make a set of things draggable, create a new instance of this object passing the
|
||||
* necessary config, as explained in the comment on the constructor.
|
||||
*
|
||||
* @package qtype_ordering
|
||||
* @package qtype_ordering\drag_reorder
|
||||
* @copyright 2018 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
namespace qtype_ordering\output;
|
||||
|
||||
/**
|
||||
* Renderable class for the description of the correct response to a given question attempt.
|
||||
* Create an array for the correct response based on the question and current step state.
|
||||
*
|
||||
* @package qtype_ordering
|
||||
* @copyright 2023 Mihail Geshoski <[email protected]>
|
||||
@@ -26,7 +26,7 @@ namespace qtype_ordering\output;
|
||||
class correct_response extends renderable_base {
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
* Based on the question and step state, create an array for the correct response.
|
||||
*
|
||||
* @param \renderer_base $output renderer to be used to render the action bar elements.
|
||||
* @return array
|
||||
|
||||
@@ -21,7 +21,7 @@ use question_attempt;
|
||||
use question_display_options;
|
||||
|
||||
/**
|
||||
* Renderable class for the displaying the feedback.
|
||||
* Collate various sections of displayable feedback for render.
|
||||
*
|
||||
* @package qtype_ordering
|
||||
* @copyright 2023 Mathew May <mathew.solutions>
|
||||
@@ -33,7 +33,7 @@ class feedback extends renderable_base {
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
* Define the feedback with options for display.
|
||||
*
|
||||
* @param question_attempt $qa The question attempt object.
|
||||
* @param question_display_options $options Controls what should and should not be displayed
|
||||
@@ -45,7 +45,7 @@ class feedback extends renderable_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
* Build the feedback array which is used to render the feedback.
|
||||
*
|
||||
* @param renderer_base $output renderer to be used to render the feedback elements.
|
||||
* @return array
|
||||
|
||||
@@ -20,7 +20,7 @@ use question_attempt;
|
||||
use question_display_options;
|
||||
|
||||
/**
|
||||
* Renderable class for the displaying the formulation and controls of the question.
|
||||
* Create the question formulation, controls ready for output.
|
||||
*
|
||||
* @package qtype_ordering
|
||||
* @copyright 2023 Ilya Tregubov <[email protected]>
|
||||
@@ -32,7 +32,7 @@ class formulation_and_controls extends renderable_base {
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
* Construct the rendarable as we also need to pass the question options.
|
||||
*
|
||||
* @param question_attempt $qa The question attempt object.
|
||||
* @param question_display_options $options The question options.
|
||||
@@ -43,7 +43,7 @@ class formulation_and_controls extends renderable_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
* Export the question based on the question attempt and the question display options.
|
||||
*
|
||||
* @param \renderer_base $output renderer to be used to render the action bar elements.
|
||||
* @return array
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
namespace qtype_ordering\output;
|
||||
|
||||
/**
|
||||
* Renderable class for the statement of how many sub-parts of the question the student got correct|partial|incorrect.
|
||||
* Generate the number of correct, partial, and incorrect parts of the question ready for output
|
||||
*
|
||||
* @package qtype_ordering
|
||||
* @copyright 2023 Ilya Tregubov <[email protected]>
|
||||
@@ -26,7 +26,7 @@ namespace qtype_ordering\output;
|
||||
class num_parts_correct extends renderable_base {
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
* Based on the latest step, get the number of correct, partial, and incorrect parts of the question.
|
||||
*
|
||||
* @param \renderer_base $output The output renderer.
|
||||
* @return array
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace qtype_ordering\output;
|
||||
use qtype_ordering_question;
|
||||
|
||||
/**
|
||||
* Renderable class for the displaying the grade detail of the response.
|
||||
* Generate the grade feedback when the grading should be shown.
|
||||
*
|
||||
* @package qtype_ordering
|
||||
* @copyright 2023 Ilya Tregubov <[email protected]>
|
||||
@@ -28,7 +28,7 @@ use qtype_ordering_question;
|
||||
class specific_grade_detail_feedback extends renderable_base {
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
* Based on the current state and the question options, generate the feedback.
|
||||
*
|
||||
* @param \renderer_base $output renderer to be used to render the action bar elements.
|
||||
* @return array
|
||||
|
||||
@@ -26,7 +26,6 @@ require_once($CFG->dirroot.'/question/type/ordering/question.php');
|
||||
* @package qtype_ordering
|
||||
* @copyright 2013 Gordon Bateson ([email protected])
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @codeCoverageIgnore Edit form is covered via behat and mocked in units.
|
||||
*/
|
||||
class qtype_ordering_edit_form extends question_edit_form {
|
||||
|
||||
@@ -92,7 +91,6 @@ class qtype_ordering_edit_form extends question_edit_form {
|
||||
// Field for selectcount.
|
||||
$name = 'selectcount';
|
||||
$label = get_string($name, $plugin);
|
||||
|
||||
$mform->addElement('text', $name, $label, ['size' => 2]);
|
||||
$mform->setDefault($name, qtype_ordering_question::MIN_SUBSET_ITEMS);
|
||||
$mform->setType($name, PARAM_INT);
|
||||
@@ -117,6 +115,7 @@ class qtype_ordering_edit_form extends question_edit_form {
|
||||
$mform->addHelpButton($name, $name, $plugin);
|
||||
$mform->setDefault($name, $this->get_default_value($name, 1));
|
||||
|
||||
// Field for numberingstyle.
|
||||
$name = 'numberingstyle';
|
||||
$label = get_string($name, $plugin);
|
||||
$options = qtype_ordering_question::get_numbering_styles();
|
||||
@@ -124,19 +123,18 @@ class qtype_ordering_edit_form extends question_edit_form {
|
||||
$mform->addHelpButton($name, $name, $plugin);
|
||||
$mform->setDefault($name, $this->get_default_value($name, qtype_ordering_question::NUMBERING_STYLE_DEFAULT));
|
||||
|
||||
$elements = [];
|
||||
$options = [];
|
||||
|
||||
$mform->addElement('header', 'answersheader', get_string('draggableitems', $plugin));
|
||||
$mform->setExpanded('answersheader', true);
|
||||
|
||||
// Field for the answers.
|
||||
$elements = [];
|
||||
$options = [];
|
||||
$name = 'answer';
|
||||
$elements[] = $mform->createElement('editor', $name, get_string('draggableitemno', $plugin),
|
||||
$this->get_editor_attributes(), $this->get_editor_options());
|
||||
$elements[] = $mform->createElement('submit', $name . 'removeeditor', get_string('removeeditor', $plugin),
|
||||
['onclick' => 'skipClientValidation = true;']);
|
||||
$options[$name] = ['type' => PARAM_RAW];
|
||||
|
||||
$this->add_repeat_elements($mform, $name, $elements, $options);
|
||||
|
||||
// Adjust HTML editor and removal buttons.
|
||||
@@ -467,17 +465,6 @@ class qtype_ordering_edit_form extends question_edit_form {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a preference item name, returns the full
|
||||
* preference name of that item for this plugin
|
||||
*
|
||||
* @param string $name Item name
|
||||
* @return string full preference name
|
||||
*/
|
||||
protected function get_my_preference_name(string $name): string {
|
||||
return $this->plugin_name()."_$name";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of countable item types
|
||||
*
|
||||
|
||||
@@ -570,7 +570,7 @@ class qtype_ordering_question extends question_graded_automatically {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert response data from mform into array
|
||||
* Unpack the students' response into an array which updates the question currentresponse.
|
||||
*
|
||||
* @param array $response Form data
|
||||
*/
|
||||
@@ -586,6 +586,7 @@ class qtype_ordering_question extends question_graded_automatically {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Note: TH mentions that this is a bit of a hack.
|
||||
$this->currentresponse = $ids;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,9 +721,6 @@ class qtype_ordering extends question_type {
|
||||
$newquestion = $format->import_headers($data);
|
||||
$newquestion->qtype = $questiontype;
|
||||
|
||||
// Fix empty or long question name.
|
||||
$newquestion->name = $this->fix_questionname($newquestion->name, $newquestion->questiontext);
|
||||
|
||||
// Extra fields - "selecttype" and "selectcount"
|
||||
// (these fields used to be called "logical" and "studentsee").
|
||||
if (isset($data['#']['selecttype'])) {
|
||||
@@ -784,33 +781,6 @@ class qtype_ordering extends question_type {
|
||||
return $newquestion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix empty or long question name
|
||||
*
|
||||
* @param string $name The name of the question
|
||||
* @param string|null $defaultname (optional, default='') The default name of the question
|
||||
* @param int|null $maxnamelength (optional, default=42) The maximum length of the name
|
||||
* @return string Fixed name
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function fix_questionname(string $name, ?string $defaultname = '', ?int $maxnamelength = 42): string {
|
||||
if (trim($name) == '') {
|
||||
if ($defaultname) {
|
||||
$name = $defaultname;
|
||||
} else {
|
||||
$name = get_string('defaultquestionname', 'qtype_ordering');
|
||||
}
|
||||
}
|
||||
if (strlen($name) > $maxnamelength) {
|
||||
$name = substr($name, 0, $maxnamelength);
|
||||
if ($pos = strrpos($name, ' ')) {
|
||||
$name = substr($name, 0, $pos);
|
||||
}
|
||||
$name .= ' ...';
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set layouttype, selecttype, selectcount, gradingtype, showgrading based on their textual representation
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user