Skip to content

Commit a6a1ba8

Browse files
committed
iss1680 - Load latest version on refresh. Display warning flags if no variants. Do not show test tab on deploy.
1 parent 3f58378 commit a6a1ba8

7 files changed

Lines changed: 49 additions & 19 deletions

File tree

amd/build/dashboard.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/dashboard.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/dashboard.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,35 @@ define([], function () {
2727
*
2828
*/
2929
function init() {
30+
const warningTab = document.getElementById('warning-tab');
31+
if (document.querySelectorAll('.var-pane-fail').length) {
32+
const varTab = document.getElementById('variants-pane-warning');
33+
varTab.style.display = 'inline';
34+
warningTab.style.display = 'inline';
35+
}
36+
if (document.querySelectorAll('.test-pane-fail').length) {
37+
const testTab = document.getElementById('test-pane-warning');
38+
testTab.style.display = 'inline';
39+
warningTab.style.display = 'inline';
40+
}
41+
const variantCount = document.getElementById('variant-count').textContent;
42+
const variantTab = document.getElementById('variants-tab-label');
43+
variantTab.textContent = variantTab.textContent + ' ' + variantCount;
44+
document.getElementById('dashboard-tab-content').style.display = 'block';
45+
46+
// Prevent page refresh loading old version.
47+
const url = new URL(location);
48+
if (url.searchParams.get('historic')) {
49+
url.searchParams.delete('historic');
50+
history.replaceState(null, null, url);
51+
} else {
52+
// Page reload will not reset dropdown. We have to do it manually.
53+
var options = document.querySelectorAll('.version-dropdown-option');
54+
for (var i = 0, l = options.length; i < l; i++) {
55+
options[i].selected = options[i].defaultSelected;
56+
}
57+
}
58+
3059
// Add simple client-side sorting for the first two columns.
3160
const variantsTable = document.getElementById('deployed-variants-table');
3261
if (!variantsTable) {
@@ -139,18 +168,6 @@ define([], function () {
139168
});
140169
});
141170
}
142-
143-
const warningTab = document.getElementById('warning-tab');
144-
if (document.querySelectorAll('.var-pane-fail').length) {
145-
const varTab = document.getElementById('variants-pane-warning');
146-
varTab.style.display = 'inline';
147-
warningTab.style.display = 'inline';
148-
}
149-
if (document.querySelectorAll('.test-pane-fail').length) {
150-
const testTab = document.getElementById('test-pane-warning');
151-
testTab.style.display = 'inline';
152-
warningTab.style.display = 'inline';
153-
}
154171
}
155172

156173
/** Export our entry point. */

deploy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
// Initialise $PAGE.
5050
$nexturl = new moodle_url('/question/type/stack/questiontestrun.php', $urlparams, 'variants-pane');
51+
$nexturl->param('hidetests', 1);
5152
$PAGE->set_url($nexturl); // Since this script always ends in a redirect.
5253
$PAGE->set_heading($COURSE->fullname);
5354
$PAGE->set_pagelayout('popup');

questiontestrun.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
$initialdata->general->cmid = $cmid;
173173
$initialdata->general->questionid = $questionid;
174174
$initialdata->general->seed = $seed;
175+
$initialdata->general->hidetests = optional_param('hidetests', '', PARAM_INT);
175176

176177
// Output the progress bars first.
177178
$dashboard->create_progress_bars();
@@ -265,7 +266,7 @@
265266
$variantdata->hastests = optional_param('testall', null, PARAM_INT);
266267
$testalllink = new moodle_url(
267268
'/question/type/stack/questiontestrun.php',
268-
$urlparams + ['testall' => '1', 'sesskey' => $sesskey, 'nocache' => time(), 'historic' => $historic],
269+
$urlparams + ['testall' => '1', 'sesskey' => $sesskey, 'nocache' => time(), 'historic' => $historic, 'hidetests' => 1],
269270
'variants-pane'
270271
);
271272
$variantdata->testalllink = $testalllink->out();

templates/questiontestrun.mustache

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"courseid": 7,
7575
"cmid": 7,
7676
"questionid": "6605",
77-
"seed": 182397542
77+
"seed": 182397542,
78+
"hidetests": ""
7879
},
7980
"istest": true
8081
}
@@ -86,7 +87,10 @@
8687
<p>{{#str}} version, qtype_stack {{/str}}
8788
<select onChange="window.location.href=this.value;">
8889
{{#question.versions}}
89-
<option value="{{{url}}}" {{#active}} selected="selected" {{/active}}>
90+
<option class="version-dropdown-option"
91+
value="{{{url}}}"
92+
{{#active}} selected=true defaultSelected=true {{/active}}
93+
{{^active}} defaultSelected=false {{/active}}>
9094
{{version}}
9195
</option>
9296
{{/question.versions}}
@@ -142,13 +146,16 @@
142146
<a class="nav-link stack-dash-tab-load disabled" href="#question-pane" id="question-tab" data-bs-toggle="tab" data-toggle="tab" role="tab" aria-controls="question-pane" aria-selected="false">{{#str}} question, core {{/str}}</a>
143147
</li>
144148
<li class="nav-item stack-dash-tab-load" role="presentation">
145-
<a class="nav-link stack-dash-tab-load disabled" href="#variants-pane" id="variants-tab" data-bs-toggle="tab" data-toggle="tab" role="tab" aria-controls="variants-pane" aria-selected="false"><span id="variants-pane-warning" style="display:none;">{{#pix}}req, core{{/pix}}</span>{{#str}} variants, qtype_stack {{/str}}</a>
149+
<a class="nav-link stack-dash-tab-load disabled" href="#variants-pane" id="variants-tab" data-bs-toggle="tab" data-toggle="tab" role="tab" aria-controls="variants-pane" aria-selected="false">
150+
<span id="variants-pane-warning" style="display:none;">{{#pix}}req, core{{/pix}}</span>
151+
<span id="variants-tab-label">{{#str}} variants, qtype_stack {{/str}}</span>
152+
</a>
146153
</li>
147154
<li id="warning-tab" class="nav-link stack-dash-tab-load disabled" style="border: none; border-radius: 0; display:none;">{{#pix}}req, core{{/pix}}{{#str}}dashboardissues, qtype_stack{{/str}}</li>
148155
</ul>
149156

150157
<!-- Tab panes -->
151-
<div class="tab-content">
158+
<div id="dashboard-tab-content" class="tab-content" {{#general.hidetests}}style="display: none"{{/general.hidetests}}>
152159
<!-- Question details panes -->
153160
<div class="tab-pane mt-3" id="question-pane" role="tabpanel" aria-labelledby="question-tab">
154161
<h3>{{question.name}}</h3>

templates/questiontestrunvariants.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@
9898
{{^hasrandomvariants}}
9999
<!-- No randomisation -->
100100
<p>{{#str}} questiondoesnotuserandomisation, qtype_stack {{/str}} <a href="{{{previewurl}}}">{{#pix}}t/preview, core, {{#str}} preview, core {{/str}}{{/pix}}</a></p>
101+
<span id="variant-count" hidden>(-)</span>
102+
{{/hasrandomvariants}}
103+
{{#hasrandomvariants}}
104+
<span id="variant-count" hidden>({{deployedcount}})</span>
101105
{{/hasrandomvariants}}
102106
{{^notes.0}}
103107
{{#hasrandomvariants}}

0 commit comments

Comments
 (0)