Skip to content

Commit

Permalink
Questionnaire: treat '0' as valid answer.
Browse files Browse the repository at this point in the history
--HG--
branch : 3.11
  • Loading branch information
jexi committed May 24, 2021
1 parent 2db0143 commit acf0ba7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions modules/questionnaire/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,22 +221,20 @@
if (isset($_POST['submitAnswers'])) {
$pqid = intval($_GET['modifyAnswers']);
$question = Database::get()->querySingle("SELECT * FROM poll_question WHERE pid = ?d and pqid = ?d", $pid,$pqid);
if(!$question){
if (!$question) {
redirect_to_home_page("modules/questionnaire/index.php?course=$course_code");
}
$answers = $_POST['answers'];

Database::get()->query("DELETE FROM poll_question_answer WHERE pqid IN
(SELECT pqid FROM poll_question WHERE pid = ?d AND pqid = ?d)", $pid, $pqid);

foreach ($answers as $answer) {
if (!empty($answer)) {
if ($answer !== '') {
Database::get()->query("INSERT INTO poll_question_answer (pqid, answer_text)
VALUES (?d, ?s)", $pqid, $answer);
}
}
redirect_to_home_page("modules/questionnaire/admin.php?course=$course_code&pid=$pid");

}
if (isset($_GET['deleteQuestion'])) {
$pqid = intval($_GET['deleteQuestion']);
Expand Down

0 comments on commit acf0ba7

Please sign in to comment.