Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

583 Fix M.core_formchangechecker is undefined #584

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 3 additions & 1 deletion module.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ M.mod_questionnaire = M.mod_questionnaire || {};
/* exported Y */
/* exported e */
M.mod_questionnaire.init_attempt_form = function() {
M.core_formchangechecker.init({formid: 'phpesp_response'});
require(['core_form/changechecker'], function(FormChangeChecker) {
FormChangeChecker.watchFormById('phpesp_response');
});
};

M.mod_questionnaire.init_sendmessage = function(Y) {
Expand Down
15 changes: 10 additions & 5 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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()) {
Expand All @@ -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';
Expand Down
6 changes: 6 additions & 0 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
Loading