Skip to content

Commit

Permalink
Merge branch 'PoetOS:MOODLE_401_STABLE' into wip253248
Browse files Browse the repository at this point in the history
  • Loading branch information
tailetan authored Aug 22, 2024
2 parents a2c6142 + 6253d1a commit ebdf66d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
test:
runs-on: 'ubuntu-latest'
runs-on: ubuntu-22.04

services:
postgres:
Expand All @@ -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
Expand All @@ -45,7 +45,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion classes/question/numerical.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 != '') {
Expand Down
4 changes: 2 additions & 2 deletions lang/en/questionnaire.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
15 changes: 10 additions & 5 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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()) {
Expand All @@ -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';
Expand Down
14 changes: 10 additions & 4 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -449,10 +455,10 @@
}
$output = '';
$output .= "<br /><br />\n";
$output .= $questionnaire->renderer->help_icon('downloadtextformat', 'questionnaire');
$output .= '&nbsp;' . (get_string('downloadtextformat', 'questionnaire')) . ':&nbsp;' .
get_string('responses', 'questionnaire').'&nbsp;'.$groupname;
$output .= $questionnaire->renderer->heading(get_string('textdownloadoptions', 'questionnaire'));
$output .= html_writer::tag('h2', (get_string('downloadtextformat', 'questionnaire'))
. ':&nbsp;' . get_string('responses', 'questionnaire') . '&nbsp;' .
$groupname . $questionnaire->renderer->help_icon('downloadtextformat', 'questionnaire'));
$output .= $questionnaire->renderer->heading(get_string('textdownloadoptions', 'questionnaire'), 3);
$output .= $questionnaire->renderer->box_start();
$downloadparams = [
'instance' => $instance,
Expand Down

0 comments on commit ebdf66d

Please sign in to comment.