Skip to content

Commit

Permalink
MDL-79863 qtype_ordering: Update comments and remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Apr 5, 2024
1 parent d0a9505 commit 7dda680
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 64 deletions.
2 changes: 1 addition & 1 deletion question/type/ordering/amd/build/drag_reorder.min.js.map

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions question/type/ordering/amd/src/drag_reorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions question/type/ordering/classes/output/correct_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand All @@ -26,7 +26,7 @@
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
Expand Down
6 changes: 3 additions & 3 deletions question/type/ordering/classes/output/feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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>
Expand All @@ -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
Expand All @@ -45,7 +45,7 @@ public function __construct(question_attempt $qa, question_display_options $opti
}

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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]>
Expand All @@ -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.
Expand All @@ -43,7 +43,7 @@ public function __construct(question_attempt $qa, question_display_options $opti
}

/**
* 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
Expand Down
4 changes: 2 additions & 2 deletions question/type/ordering/classes/output/num_parts_correct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand All @@ -26,7 +26,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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]>
Expand All @@ -28,7 +28,7 @@
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
Expand Down
21 changes: 4 additions & 17 deletions question/type/ordering/edit_ordering_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* @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 {

Expand Down Expand Up @@ -92,7 +91,6 @@ public function definition_inner($mform): void {
// 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);
Expand All @@ -117,26 +115,26 @@ public function definition_inner($mform): void {
$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();
$mform->addElement('select', $name, $label, $options);
$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.
Expand Down Expand Up @@ -467,17 +465,6 @@ public function validation($data, $files): array {
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
*
Expand Down
3 changes: 2 additions & 1 deletion question/type/ordering/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public function get_response_fieldname(): string {
}

/**
* Convert response data from mform into array
* Unpack the students' response into an array which updates the question currentresponse.
*
* @param array $response Form data
*/
Expand All @@ -586,6 +586,7 @@ public function update_current_response(array $response) {
}
}
}
// Note: TH mentions that this is a bit of a hack.
$this->currentresponse = $ids;
}
}
Expand Down
30 changes: 0 additions & 30 deletions question/type/ordering/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,6 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra =
$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'])) {
Expand Down Expand Up @@ -784,33 +781,6 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra =
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
*
Expand Down

0 comments on commit 7dda680

Please sign in to comment.