Skip to content

Commit 5900714

Browse files
lamtranblamtranb
authored andcommitted
Questionnaire: "'Save is actully 'Save and exit', and should be better labelled. Also it should be easier to resume if pressed in error". #560831 (#396)
Co-authored-by: lamtranb <[email protected]>
1 parent a8b70d5 commit 5900714

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

lang/en/questionnaire.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@
549549
$string['resumesurvey'] = 'Resume questionnaire';
550550
$string['return'] = 'Return';
551551
$string['save'] = 'Save';
552+
$string['save_and_exit'] = 'Save and exit';
552553
$string['saveasnew'] = 'Save as New Question';
553554
$string['savedbutnotsubmitted'] = 'This questionnaire has been saved but not yet submitted.';
554555
$string['savedprogress'] = 'Your progress has been saved. You may return at any time to complete this questionnaire.';

questionnaire.class.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ public function print_survey($quser, $userid=false) {
12541254
}
12551255
if ($this->resume) {
12561256
$controlbuttons['resume'] = ['type' => 'submit', 'class' => 'btn btn-secondary',
1257-
'value' => get_string('save', 'questionnaire')];
1257+
'value' => get_string('save_and_exit', 'questionnaire')];
12581258
}
12591259

12601260
// Add a 'hidden' variable for the mod's 'view.php', and use a language variable for the submit button.
@@ -2528,7 +2528,7 @@ private function response_goto_thankyou() {
25282528
* @param string $url
25292529
*/
25302530
private function response_goto_saved($url) {
2531-
global $CFG;
2531+
global $CFG, $USER;
25322532
$resumesurvey = get_string('resumesurvey', 'questionnaire');
25332533
$savedprogress = get_string('savedprogress', 'questionnaire', '<strong>'.$resumesurvey.'</strong>');
25342534

@@ -2537,6 +2537,21 @@ private function response_goto_saved($url) {
25372537
$this->page->add_to_page('respondentinfo',
25382538
$this->renderer->homelink($CFG->wwwroot.'/course/view.php?id='.$this->course->id,
25392539
get_string("backto", "moodle", $this->course->fullname)));
2540+
2541+
if ($this->resume) {
2542+
$message = $this->user_access_messages($USER->id, true);
2543+
if ($message === false) {
2544+
if ($this->user_can_take($USER->id)) {
2545+
if ($this->questions) { // Sanity check.
2546+
if ($this->user_has_saved_response($USER->id)) {
2547+
$this->page->add_to_page('respondentinfo',
2548+
$this->renderer->homelink($CFG->wwwroot . '/mod/questionnaire/complete.php?' .
2549+
'id=' . $this->cm->id . '&resume=1', $resumesurvey));
2550+
}
2551+
}
2552+
}
2553+
}
2554+
}
25402555
return;
25412556
}
25422557

styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ td.selected {
175175
display: inline;
176176
}
177177

178+
#page-mod-questionnaire-complete .notice .buttons input {
179+
margin-bottom: 10px;
180+
}
181+
178182
.floatprinticon {
179183
margin-top: -30px;
180184
float: right;
@@ -217,6 +221,10 @@ td.selected {
217221
overflow: hidden;
218222
}
219223

224+
#page-mod-questionnaire-complete .mod_questionnaire_completepage.generalbox .homelink ~ .homelink {
225+
padding-top: 10px;
226+
}
227+
220228
.qn-legend {
221229
float: left;
222230
font-size: inherit;

tests/behat/save_and_resume.feature

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ Feature: Questionnaire responses can be saved and resumed without submitting.
5050
And I set the field "One" to "checked"
5151
And I set the field "Two" to "checked"
5252
And I set the field "Select one choice" to "Four"
53-
And I press "Save"
53+
And I press "Save and exit"
5454
Then I should see "Your progress has been saved."
55+
And I should see "Resume questionnaire"
5556

5657
And I am on "Course 1" course homepage
5758
And I follow "Questionnaire 1"
@@ -66,8 +67,9 @@ Feature: Questionnaire responses can be saved and resumed without submitting.
6667
And the field "Select one choice" matches value "Four"
6768
And I set the field "Two" to "0"
6869
And I set the field "Three" to "checked"
69-
And I press "Save"
70+
And I press "Save and exit"
7071
Then I should see "Your progress has been saved."
72+
And I should see "Resume questionnaire"
7173

7274
And I am on "Course 1" course homepage
7375
And I follow "Questionnaire 1"
@@ -81,6 +83,7 @@ Feature: Questionnaire responses can be saved and resumed without submitting.
8183
And the field "Select one choice" matches value "Four"
8284
And I press "Submit questionnaire"
8385
Then I should see "Thank you for completing this Questionnaire."
86+
And I should not see "Resume questionnaire"
8487

8588
And I am on "Course 1" course homepage
8689
And I follow "Questionnaire 1"

0 commit comments

Comments
 (0)