diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15bf6dfd..6433720d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ on: [push, pull_request] jobs: test: - runs-on: 'ubuntu-latest' + runs-on: ubuntu-22.04 services: postgres: @@ -14,14 +14,14 @@ jobs: ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + mariadb: - image: mariadb:10.6 + image: mariadb:10 env: MYSQL_USER: 'root' MYSQL_ALLOW_EMPTY_PASSWORD: "true" MYSQL_CHARACTER_SET_SERVER: "utf8mb4" MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" - ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: plugin @@ -60,12 +60,12 @@ jobs: - name: Deploy moodle-plugin-ci run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 - # Add dirs to $PATH + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 echo $(cd ci/bin; pwd) >> $GITHUB_PATH echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH - # PHPUnit depends on en_AU.UTF-8 locale sudo locale-gen en_AU.UTF-8 + # Install nvm. + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash - name: Install Moodle # Need explicit IP to stop mysql client fail on attempt to use unix socket. 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/lang/en/questionnaire.php b/lang/en/questionnaire.php index 4a47a2fe..7eabf425 100644 --- a/lang/en/questionnaire.php +++ b/lang/en/questionnaire.php @@ -151,8 +151,8 @@ $string['download'] = 'Download'; $string['downloadpdf'] = 'Download PDF'; $string['downloadtextformat'] = 'Download'; -$string['downloadtextformat_help'] = 'This feature enables you to save all the responses of a questionnaire to a selectable, supported file format. - You can choose to include extra data items in the export, as well as choose to automatically send the file to selected users.'; +$string['downloadtextformat_help'] = 'This feature enables you to download questionnaire responses in a file format of your choice. + The file can then be opened in a spreadsheet program (e.g. MS Excel or Open Office Calc) or a statistical package for further processing.'; $string['downloadtextformat_link'] = 'mod/questionnaire/report#Download_in_text_format'; $string['downloadtypes'] = 'Report type'; $string['dropdown'] = 'Dropdown Box'; diff --git a/locallib.php b/locallib.php index f537070f..f5486179 100644 --- a/locallib.php +++ b/locallib.php @@ -68,10 +68,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 f50636f2..ef1d68b7 100644 --- a/questionnaire.class.php +++ b/questionnaire.class.php @@ -851,9 +851,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 = []; @@ -865,6 +866,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()) { @@ -873,16 +880,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 e66b3555..ea8331a8 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) { @@ -449,10 +455,10 @@ } $output = ''; $output .= "

\n"; - $output .= $questionnaire->renderer->help_icon('downloadtextformat', 'questionnaire'); - $output .= ' ' . (get_string('downloadtextformat', 'questionnaire')) . ': ' . - get_string('responses', 'questionnaire').' '.$groupname; - $output .= $questionnaire->renderer->heading(get_string('textdownloadoptions', 'questionnaire')); + $output .= html_writer::tag('h2', (get_string('downloadtextformat', 'questionnaire')) + . ': ' . get_string('responses', 'questionnaire') . ' ' . + $groupname . $questionnaire->renderer->help_icon('downloadtextformat', 'questionnaire')); + $output .= $questionnaire->renderer->heading(get_string('textdownloadoptions', 'questionnaire'), 3); $output .= $questionnaire->renderer->box_start(); $downloadparams = [ 'instance' => $instance,