diff --git a/classes/question/numerical.php b/classes/question/numerical.php index d86bbedb..994e000b 100644 --- a/classes/question/numerical.php +++ b/classes/question/numerical.php @@ -83,7 +83,7 @@ protected function question_survey_display($response, $descendantsdata, $blankqu // Numeric. $questiontags = new \stdClass(); $precision = $this->precise; - $a = new \StdClass(); + $a = new \stdClass(); if (isset($response->answers[$this->id][0])) { $mynumber = $response->answers[$this->id][0]->value; if ($mynumber != '') { diff --git a/locallib.php b/locallib.php index 4fce8590..c997be87 100644 --- a/locallib.php +++ b/locallib.php @@ -65,10 +65,10 @@ global $questionnaireresponseviewers; $questionnaireresponseviewers = array ( + QUESTIONNAIRE_STUDENTVIEWRESPONSES_NEVER => get_string('responseviewstudentsnever', 'questionnaire'), QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENANSWERED => get_string('responseviewstudentswhenanswered', 'questionnaire'), QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENCLOSED => get_string('responseviewstudentswhenclosed', 'questionnaire'), - QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS => get_string('responseviewstudentsalways', 'questionnaire'), - QUESTIONNAIRE_STUDENTVIEWRESPONSES_NEVER => get_string('responseviewstudentsnever', 'questionnaire')); + QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS => get_string('responseviewstudentsalways', 'questionnaire')); global $autonumbering; $autonumbering = array (0 => get_string('autonumberno', 'questionnaire'), diff --git a/questionnaire.class.php b/questionnaire.class.php index e366f70b..4e88c5e3 100644 --- a/questionnaire.class.php +++ b/questionnaire.class.php @@ -826,9 +826,10 @@ public function count_submissions($userid=false, $groupid=0) { * * @param int|bool $userid * @param int $groupid + * @param int|bool $includeincomplete * @return array */ - public function get_responses($userid=false, $groupid=0) { + public function get_responses($userid=false, $groupid=0, $includeincomplete=false) { global $DB; $params = []; @@ -840,6 +841,12 @@ public function get_responses($userid=false, $groupid=0) { $params['groupid'] = $groupid; } + $statuscnd = ''; + if (!$includeincomplete) { + $statuscnd = ' AND r.complete = :status '; + $params['status'] = 'y'; + } + // Since submission can be across questionnaires in the case of public questionnaires, need to check the realm. // Public questionnaires can have responses to multiple questionnaire instances. if ($this->survey_is_public_master()) { @@ -848,16 +855,14 @@ public function get_responses($userid=false, $groupid=0) { 'INNER JOIN {questionnaire} q ON r.questionnaireid = q.id ' . 'INNER JOIN {questionnaire_survey} s ON q.sid = s.id ' . $groupsql . - 'WHERE s.id = :surveyid AND r.complete = :status' . $groupcnd; + 'WHERE s.id = :surveyid' . $statuscnd . $groupcnd; $params['surveyid'] = $this->sid; - $params['status'] = 'y'; } else { $sql = 'SELECT r.* ' . 'FROM {questionnaire_response} r ' . $groupsql . - 'WHERE r.questionnaireid = :questionnaireid AND r.complete = :status' . $groupcnd; + 'WHERE r.questionnaireid = :questionnaireid' . $statuscnd . $groupcnd; $params['questionnaireid'] = $this->id; - $params['status'] = 'y'; } if ($userid) { $sql .= ' AND r.userid = :userid'; diff --git a/report.php b/report.php index 09f75671..ae03eeb4 100755 --- a/report.php +++ b/report.php @@ -267,6 +267,9 @@ case 'delallresp': // Delete all responses? Ask for confirmation. require_capability('mod/questionnaire:deleteresponses', $context); + // Get all responses including incompletes. + $respsallparticipants = $questionnaire->get_responses(false, 0, true); + if (!empty($respsallparticipants)) { // Print the page header. @@ -357,6 +360,9 @@ throw new \moodle_exception('surveyowner', 'mod_questionnaire'); } + // Get all responses including incompletes. + $respsallparticipants = $questionnaire->get_responses(false, 0, true); + // Available group modes (0 = no groups; 1 = separate groups; 2 = visible groups). if ($groupmode > 0) { switch ($currentgroupid) { @@ -640,7 +646,7 @@ // not an array. $errorreporting = error_reporting(0); $pdf->writeHTML($html); - @$pdf->Output(clean_param($questionnaire->name, PARAM_FILE), 'D'); + @$pdf->Output(clean_param($questionnaire->name, PARAM_FILE) . '.pdf', 'D'); error_reporting($errorreporting); } else { // Default to HTML.