Skip to content

Commit

Permalink
Ghi456 311 (PoetOS#464) fix for PH8 feedback issue
Browse files Browse the repository at this point in the history
* GHI456 Allow saving back to no feedback.

* GHI456 Don't try and display missing feedback.

* GHI456 Ensuring  $table is always set.
  • Loading branch information
mchurchward committed Feb 28, 2023
1 parent ffb0046 commit 857f482
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion classes/feedback_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function definition() {
$mform =& $this->_form;

// Questionnaire Feedback Sections and Messages.
$mform->addElement('header', 'submithdr', get_string('feedbackoptions', 'questionnaire'));
$feedbackoptions = [];
$feedbackoptions[0] = get_string('feedbacknone', 'questionnaire');
$mform->addElement('header', 'submithdr', get_string('feedbackoptions', 'questionnaire'));
$feedbackoptions[1] = get_string('feedbackglobal', 'questionnaire');
$feedbackoptions[2] = get_string('feedbacksections', 'questionnaire');

Expand Down
2 changes: 1 addition & 1 deletion feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
}

if ($settings = $feedbackform->get_data()) {
if (isset($settings->feedbacksettingsbutton1) || isset($settings->buttongroup)) {
if (isset($settings->feedbacksettingsbutton1) || isset($settings->feedbacksettingsbutton2) || isset($settings->buttongroup)) {
if (isset ($settings->feedbackscores)) {
$sdata->feedbackscores = $settings->feedbackscores;
} else {
Expand Down
41 changes: 23 additions & 18 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3848,6 +3848,7 @@ public function response_analysis($rid, $resps, $compare, $isgroupmember, $allre
$oppositeallscore = ' | '.$allscore[1].'%';
}
if ($this->survey->feedbackscores) {
$table = $table ?? new html_table();
if ($compare) {
$table->data[] = array($sectionlabel, $score[0].'%'.$oppositescore, $allscore[0].'%'.$oppositeallscore);
} else {
Expand Down Expand Up @@ -3976,24 +3977,28 @@ public function response_analysis($rid, $resps, $compare, $isgroupmember, $allre
default:
}

foreach ($allscore as $key => $sc) {
if (isset($chartlabels[$key])) {
$lb = explode("|", $chartlabels[$key]);
$oppositescore = '';
$oppositeallscore = '';
if (count($lb) > 1) {
$sectionlabel = $lb[0] . ' | ' . $lb[1];
$oppositescore = ' | ' . $oppositescorepercent[$key] . '%';
$oppositeallscore = ' | ' . $alloppositescorepercent[$key] . '%';
} else {
$sectionlabel = $chartlabels[$key];
}
// If all questions of $section are unseen then don't show feedbackscores for this section.
if ($compare && !is_nan($scorepercent[$key])) {
$table->data[] = array($sectionlabel, $scorepercent[$key] . '%' . $oppositescore,
$allscorepercent[$key] . '%' . $oppositeallscore);
} else if (isset($allscorepercent[$key]) && !is_nan($allscorepercent[$key])) {
$table->data[] = array($sectionlabel, $allscorepercent[$key] . '%' . $oppositeallscore);
if ($this->survey->feedbackscores) {
foreach ($allscore as $key => $sc) {
if (isset($chartlabels[$key])) {
$lb = explode("|", $chartlabels[$key]);
$oppositescore = '';
$oppositeallscore = '';
if (count($lb) > 1) {
$sectionlabel = $lb[0] . ' | ' . $lb[1];
$oppositescore = ' | ' . $oppositescorepercent[$key] . '%';
$oppositeallscore = ' | ' . $alloppositescorepercent[$key] . '%';
} else {
$sectionlabel = $chartlabels[$key];
}
// If all questions of $section are unseen then don't show feedbackscores for this section.
if ($compare && !is_nan($scorepercent[$key])) {
$table = $table ?? new html_table();
$table->data[] = array($sectionlabel, $scorepercent[$key] . '%' . $oppositescore,
$allscorepercent[$key] . '%' . $oppositeallscore);
} else if (isset($allscorepercent[$key]) && !is_nan($allscorepercent[$key])) {
$table = $table ?? new html_table();
$table->data[] = array($sectionlabel, $allscorepercent[$key] . '%' . $oppositeallscore);
}
}
}
}
Expand Down

0 comments on commit 857f482

Please sign in to comment.