Skip to content

Commit

Permalink
MDL-72956 mod_feedback: remove session access for started activities.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jan 15, 2025
1 parent a843eab commit da320ee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
13 changes: 2 additions & 11 deletions mod/feedback/classes/completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) &&
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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();
}
}
4 changes: 1 addition & 3 deletions mod/feedback/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions mod/feedback/complete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit da320ee

Please sign in to comment.