MDL-79863 qtype_ordering: qtype_ordering fix behavior in Adaptive mode, with 'Whether correct' review option enabled

This commit is contained in:
Gordon Bateson 2019-10-06 11:58:53 +09:00 committed by Mathew May
parent ae7ee93bf0
commit 58cd34d502
3 changed files with 73 additions and 64 deletions

View file

@ -58,6 +58,9 @@ class qtype_ordering_renderer extends qtype_with_combined_feedback_renderer {
public function formulation_and_controls(question_attempt $qa, question_display_options $options) { public function formulation_and_controls(question_attempt $qa, question_display_options $options) {
global $CFG, $DB, $PAGE; global $CFG, $DB, $PAGE;
// Initialize the return result.
$result = '';
$question = $qa->get_question(); $question = $qa->get_question();
$response = $qa->get_last_qt_data(); $response = $qa->get_last_qt_data();
$question->update_current_response($response); $question->update_current_response($response);
@ -76,10 +79,26 @@ class qtype_ordering_renderer extends qtype_with_combined_feedback_renderer {
$sortableid = 'id_sortable_'.$question->id; $sortableid = 'id_sortable_'.$question->id;
$ablockid = 'id_ablock_'.$question->id; $ablockid = 'id_ablock_'.$question->id;
$result = ''; // Set CSS classes for sortable list and sortable items.
$sortablelist = 'sortablelist';
if ($class = $question->get_ordering_layoutclass()) {
$sortablelist .= ' '.$class; // "vertical" or "horizontal"
}
if ($class = $question->options->numberingstyle) {
$sortablelist .= ' numbering'.$class;
}
if ($qa->get_state()->is_active()) {
$sortablelist .= ' active';
} else {
$sortablelist .= ' notactive';
}
// Initialise JavaScript if not in readonly mode (Items cannot be dragged in readonly mode). // Initialise JavaScript if not in readonly mode
if (!$options->readonly) { if ($options->readonly) {
// Items cannot be dragged in readonly mode.
$sortableitem = '';
} else {
$sortableitem = 'sortableitem';
$params = array($sortableid, $responseid); $params = array($sortableid, $responseid);
$PAGE->requires->js_call_amd('qtype_ordering/reorder', 'init', $params); $PAGE->requires->js_call_amd('qtype_ordering/reorder', 'init', $params);
} }
@ -93,23 +112,13 @@ class qtype_ordering_renderer extends qtype_with_combined_feedback_renderer {
// this represents the initial position of the items. // this represents the initial position of the items.
$md5keys = array(); $md5keys = array();
// Set CSS classes for sortable list and sortable items.
$sortablelist = 'sortablelist';
if ($qa->get_state()->is_active()) {
$sortablelist .= ' orderingactive';
}
if ($sortableitem = $question->get_ordering_layoutclass()) {
$sortableitem .= ' ';
}
$sortableitem .= 'numbering' . $question->options->numberingstyle;
// Generate ordering items. // Generate ordering items.
foreach ($currentresponse as $position => $answerid) { foreach ($currentresponse as $position => $answerid) {
if (!array_key_exists($answerid, $question->answers)) { if (! array_key_exists($answerid, $question->answers)) {
continue; // Shouldn't happen !! continue; // Shouldn't happen !!
} }
if (!array_key_exists($position, $correctresponse)) { if (! array_key_exists($position, $correctresponse)) {
continue; // Shouldn't happen !! continue; // Shouldn't happen !!
} }
@ -121,25 +130,23 @@ class qtype_ordering_renderer extends qtype_with_combined_feedback_renderer {
} }
// Set the CSS class and correctness img for this response. // Set the CSS class and correctness img for this response.
// (correctness: HIDDEN=0, VISIBLE=1, EDITABLE=2)
switch ($options->correctness) { switch ($options->correctness) {
case question_display_options::VISIBLE:
case question_display_options::HIDDEN: // HIDDEN=0.
case question_display_options::EDITABLE: // EDITABLE=2.
$class = 'sortableitem';
$img = '';
break;
case question_display_options::VISIBLE: // VISIBLE=1.
$score = $this->get_ordering_item_score($question, $position, $answerid); $score = $this->get_ordering_item_score($question, $position, $answerid);
list($score, $maxscore, $fraction, $percent, $class, $img) = $score; list($score, $maxscore, $fraction, $percent, $class, $img) = $score;
$class = trim("$sortableitem $class");
break; break;
case question_display_options::HIDDEN:
default: // Shouldn't happen !! case question_display_options::EDITABLE:
$class = $sortableitem;
$img = '';
break;
default:
$class = ''; $class = '';
$img = ''; $img = '';
break; break;
} }
$class = trim("$class $sortableitem");
// Format the answer text. // Format the answer text.
$answer = $question->answers[$answerid]; $answer = $question->answers[$answerid];

View file

@ -5,17 +5,18 @@
overflow: auto; overflow: auto;
} }
.que.ordering ul.sortablelist { .que.ordering .sortablelist {
float : left; float : left;
list-style-type : none; list-style-type : none;
margin : 0 0 0 5px; margin : 0 0 0 5px;
padding : 4px; padding : 4px;
} }
.que.ordering ul.sortablelist.orderingactive { .que.ordering .sortablelist.active {
border : 1px dotted #333; border : 1px dotted #333;
border-radius : 4px; border-radius : 4px;
} }
.que.ordering ul.sortablelist li {
.que.ordering .sortablelist li {
background-color : #ffffff; background-color : #ffffff;
border : 1px solid #000; border : 1px solid #000;
border-radius : 4px; border-radius : 4px;
@ -23,40 +24,41 @@
margin : 4px; margin : 4px;
padding : 6px 12px; padding : 6px 12px;
} }
.que.ordering ul.sortablelist li.sortableitem {
.que.ordering .sortablelist li.sortableitem {
position : relative; position : relative;
cursor : move; cursor : move;
margin-left : 26px; /* The margin is needed for the list-style-type in numberingxxx classes */ margin-left : 26px; /* The margin is needed for the list-style-type in numberingxxx classes */
} }
.que.ordering .sortablelist li.sortableitem:focus {
.que.ordering ul.sortablelist li.sortableitem.numberingnone {
list-style-type : none;
margin-left: 0px;
}
.que.ordering ul.sortablelist li.sortableitem.numbering123 {
list-style-type : decimal;
}
.que.ordering ul.sortablelist li.sortableitem.numberingabc {
list-style-type : lower-alpha;
}
.que.ordering ul.sortablelist li.sortableitem.numberingABC {
list-style-type : upper-alpha;
}
.que.ordering ul.sortablelist li.sortableitem.numberingiii {
list-style-type : lower-roman;
}
.que.ordering ul.sortablelist li.sortableitem.numberingIII {
list-style-type : upper-roman;
}
.que.ordering ul.sortablelist li.sortableitem:focus {
border-color: #0a0; border-color: #0a0;
box-shadow: 0 0 5px 5px rgba(255, 255, 150, 1); box-shadow: 0 0 5px 5px rgba(255, 255, 150, 1);
} }
.que.ordering ul.sortablelist li.horizontal {
.que.ordering .sortablelist.numberingnone li {
list-style-type : none;
margin-left: 0px;
}
.que.ordering .sortablelist.numbering123 li {
list-style-type : decimal;
}
.que.ordering .sortablelist.numberingabc li {
list-style-type : lower-alpha;
}
.que.ordering .sortablelist.numberingABC li {
list-style-type : upper-alpha;
}
.que.ordering .sortablelist.numberingiii li {
list-style-type : lower-roman;
}
.que.ordering .sortablelist.numberingIII li {
list-style-type : upper-roman;
}
.que.ordering .sortablelist.horizontal li {
float : left; float : left;
} }
.que.ordering ul.sortablelist li.vertical { .que.ordering .sortablelist.vertical li {
min-height : 18px; min-height : 18px;
} }
@ -66,15 +68,15 @@
padding: 0; padding: 0;
border: 0 none; border: 0 none;
} }
.que.ordering.dragproxy ul.sortablelist { .que.ordering.dragproxy .sortablelist {
margin: 0; margin: 0;
padding: 0; padding: 0;
float: none; float: none;
} }
.que.ordering.dragproxy ul.sortablelist li { .que.ordering.dragproxy .sortablelist li {
margin: 0; margin: 0;
} }
.que.ordering.dragproxy ul.sortablelist li.horizontal { .que.ordering.dragproxy .sortablelist li.horizontal {
float: none; float: none;
} }
.item-moving { .item-moving {
@ -86,23 +88,23 @@
/* Styles for feedback. */ /* Styles for feedback. */
.que.ordering ul.sortablelist li.correct { .que.ordering .sortablelist.notactive li.correct {
background-color : #dff4d8; /* light green */ background-color : #dff4d8; /* light green */
border-color : #99ff66; /* gentle green */ border-color : #99ff66; /* gentle green */
} }
.que.ordering ul.sortablelist li.partial66 { .que.ordering .sortablelist.notactive li.partial66 {
background-color : #dff4d8; /* light green */ background-color : #dff4d8; /* light green */
border-color : #ff9900; /* dark orange */ border-color : #ff9900; /* dark orange */
} }
.que.ordering ul.sortablelist li.partial33 { .que.ordering .sortablelist.notactive li.partial33 {
background-color : #ffebcc; /* light orange */ background-color : #ffebcc; /* light orange */
border-color : #ff9900; /* dark orange */ border-color : #ff9900; /* dark orange */
} }
.que.ordering ul.sortablelist li.partial00 { .que.ordering .sortablelist.notactive li.partial00 {
background-color : #ffdddd; /* light red */ background-color : #ffdddd; /* light red */
border-color : #ff9900; /* dark orange */ border-color : #ff9900; /* dark orange */
} }
.que.ordering ul.sortablelist li.incorrect { .que.ordering .sortablelist.notactive li.incorrect {
background-color : #ffdddd; /* light red */ background-color : #ffdddd; /* light red */
border-color : #ff7373; /* gentle red */ border-color : #ff7373; /* gentle red */
} }

View file

@ -29,5 +29,5 @@ $plugin->cron = 0;
$plugin->component = 'qtype_ordering'; $plugin->component = 'qtype_ordering';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->requires = 2015051100; // Moodle 2.9. $plugin->requires = 2015051100; // Moodle 2.9.
$plugin->version = 2019073193; $plugin->version = 2019100694;
$plugin->release = '2019-07-31 (93)'; $plugin->release = '2019-10-06 (94)';