Skip to content

Commit dbb66b8

Browse files
authored
Ghi456 311 (#464) fix for PH8 feedback issue
* GHI456 Allow saving back to no feedback. * GHI456 Don't try and display missing feedback. * GHI456 Ensuring $table is always set.
1 parent ff87e4e commit dbb66b8

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

classes/feedback_form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function definition() {
4040
$mform =& $this->_form;
4141

4242
// Questionnaire Feedback Sections and Messages.
43+
$mform->addElement('header', 'submithdr', get_string('feedbackoptions', 'questionnaire'));
4344
$feedbackoptions = [];
4445
$feedbackoptions[0] = get_string('feedbacknone', 'questionnaire');
45-
$mform->addElement('header', 'submithdr', get_string('feedbackoptions', 'questionnaire'));
4646
$feedbackoptions[1] = get_string('feedbackglobal', 'questionnaire');
4747
$feedbackoptions[2] = get_string('feedbacksections', 'questionnaire');
4848

feedback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
}
9292

9393
if ($settings = $feedbackform->get_data()) {
94-
if (isset($settings->feedbacksettingsbutton1) || isset($settings->buttongroup)) {
94+
if (isset($settings->feedbacksettingsbutton1) || isset($settings->feedbacksettingsbutton2) || isset($settings->buttongroup)) {
9595
if (isset ($settings->feedbackscores)) {
9696
$sdata->feedbackscores = $settings->feedbackscores;
9797
} else {

questionnaire.class.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3841,6 +3841,7 @@ public function response_analysis($rid, $resps, $compare, $isgroupmember, $allre
38413841
$oppositeallscore = ' | '.$allscore[1].'%';
38423842
}
38433843
if ($this->survey->feedbackscores) {
3844+
$table = $table ?? new html_table();
38443845
if ($compare) {
38453846
$table->data[] = array($sectionlabel, $score[0].'%'.$oppositescore, $allscore[0].'%'.$oppositeallscore);
38463847
} else {
@@ -3969,24 +3970,28 @@ public function response_analysis($rid, $resps, $compare, $isgroupmember, $allre
39693970
default:
39703971
}
39713972

3972-
foreach ($allscore as $key => $sc) {
3973-
if (isset($chartlabels[$key])) {
3974-
$lb = explode("|", $chartlabels[$key]);
3975-
$oppositescore = '';
3976-
$oppositeallscore = '';
3977-
if (count($lb) > 1) {
3978-
$sectionlabel = $lb[0] . ' | ' . $lb[1];
3979-
$oppositescore = ' | ' . $oppositescorepercent[$key] . '%';
3980-
$oppositeallscore = ' | ' . $alloppositescorepercent[$key] . '%';
3981-
} else {
3982-
$sectionlabel = $chartlabels[$key];
3983-
}
3984-
// If all questions of $section are unseen then don't show feedbackscores for this section.
3985-
if ($compare && !is_nan($scorepercent[$key])) {
3986-
$table->data[] = array($sectionlabel, $scorepercent[$key] . '%' . $oppositescore,
3987-
$allscorepercent[$key] . '%' . $oppositeallscore);
3988-
} else if (isset($allscorepercent[$key]) && !is_nan($allscorepercent[$key])) {
3989-
$table->data[] = array($sectionlabel, $allscorepercent[$key] . '%' . $oppositeallscore);
3973+
if ($this->survey->feedbackscores) {
3974+
foreach ($allscore as $key => $sc) {
3975+
if (isset($chartlabels[$key])) {
3976+
$lb = explode("|", $chartlabels[$key]);
3977+
$oppositescore = '';
3978+
$oppositeallscore = '';
3979+
if (count($lb) > 1) {
3980+
$sectionlabel = $lb[0] . ' | ' . $lb[1];
3981+
$oppositescore = ' | ' . $oppositescorepercent[$key] . '%';
3982+
$oppositeallscore = ' | ' . $alloppositescorepercent[$key] . '%';
3983+
} else {
3984+
$sectionlabel = $chartlabels[$key];
3985+
}
3986+
// If all questions of $section are unseen then don't show feedbackscores for this section.
3987+
if ($compare && !is_nan($scorepercent[$key])) {
3988+
$table = $table ?? new html_table();
3989+
$table->data[] = array($sectionlabel, $scorepercent[$key] . '%' . $oppositescore,
3990+
$allscorepercent[$key] . '%' . $oppositeallscore);
3991+
} else if (isset($allscorepercent[$key]) && !is_nan($allscorepercent[$key])) {
3992+
$table = $table ?? new html_table();
3993+
$table->data[] = array($sectionlabel, $allscorepercent[$key] . '%' . $oppositeallscore);
3994+
}
39903995
}
39913996
}
39923997
}

0 commit comments

Comments
 (0)