From da320eea665327ba9fc8748fd5dec243605fb6a6 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 31 Jul 2024 17:08:21 +0100 Subject: [PATCH] MDL-72956 mod_feedback: remove session access for started activities. --- mod/feedback/classes/completion.php | 13 ++----------- mod/feedback/classes/external.php | 4 +--- mod/feedback/complete.php | 2 -- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/mod/feedback/classes/completion.php b/mod/feedback/classes/completion.php index 48d6a56291aec..ab2e96854c969 100644 --- a/mod/feedback/classes/completion.php +++ b/mod/feedback/classes/completion.php @@ -550,7 +550,7 @@ public function save_response_tmp($data) { * It is also responsible for sending email notifications when applicable. */ public function save_response() { - global $SESSION, $DB, $USER; + global $DB, $USER; $feedbackcompleted = $this->find_last_completed(); // If no record is found, change false to null for safe use in feedback_save_tmp_values. @@ -574,8 +574,6 @@ public function save_response() { feedback_send_email_anonym($this->cm, $this->feedback, $this->cm->get_course()); } - unset($SESSION->feedback->is_started); - // Update completion state. $completion = new completion_info($this->cm->get_course()); if ((isloggedin() || $USER->id != $this->userid) && $completion->is_enabled($this->cm) && @@ -704,7 +702,7 @@ public function set_module_viewed() { * @since Moodle 3.3 */ public function process_page($gopage, $gopreviouspage = false) { - global $CFG, $PAGE, $SESSION; + global $PAGE; $urltogo = null; @@ -720,9 +718,6 @@ public function process_page($gopage, $gopreviouspage = false) { ($this->form->is_validated() || $gopreviouspage)) { // Form was submitted (skip validation for "Previous page" button). $data = $this->form->get_submitted_data(); - if (!isset($SESSION->feedback->is_started) OR !$SESSION->feedback->is_started == true) { - throw new \moodle_exception('error', '', $CFG->wwwroot.'/course/view.php?id='.$this->courseid); - } $this->save_response_tmp($data); if (!empty($data->savevalues) || !empty($data->gonextpage)) { if (($nextpage = $this->get_next_page($gopage)) !== null) { @@ -755,10 +750,6 @@ public function process_page($gopage, $gopreviouspage = false) { * @since Moodle 3.3 */ public function render_items() { - global $SESSION; - - // Print the items. - $SESSION->feedback->is_started = true; return $this->form->render(); } } \ No newline at end of file diff --git a/mod/feedback/classes/external.php b/mod/feedback/classes/external.php index 8dc80d8536873..1f127e206e5b6 100644 --- a/mod/feedback/classes/external.php +++ b/mod/feedback/classes/external.php @@ -729,7 +729,7 @@ public static function process_page_parameters() { * @since Moodle 3.3 */ public static function process_page($feedbackid, $page, $responses = [], $goprevious = false, $courseid = 0) { - global $USER, $SESSION; + global $USER; $params = array('feedbackid' => $feedbackid, 'page' => $page, 'responses' => $responses, 'goprevious' => $goprevious, 'courseid' => $courseid); @@ -768,8 +768,6 @@ public static function process_page($feedbackid, $page, $responses = [], $goprev // Ignore sesskey (deep in some APIs), the request is already validated. $USER->ignoresesskey = true; - feedback_init_feedback_session(); - $SESSION->feedback->is_started = true; $feedbackcompletion->process_page($params['page'], $params['goprevious']); $completed = $feedbackcompletion->just_completed(); diff --git a/mod/feedback/complete.php b/mod/feedback/complete.php index ca50e27e35e95..837d41afafa80 100644 --- a/mod/feedback/complete.php +++ b/mod/feedback/complete.php @@ -25,8 +25,6 @@ require_once("../../config.php"); require_once("lib.php"); -feedback_init_feedback_session(); - $id = required_param('id', PARAM_INT); $courseid = optional_param('courseid', null, PARAM_INT); $gopage = optional_param('gopage', 0, PARAM_INT);