MDL-51703 mod_survey: Trigger response_submitted event in correct place
authorJuan Leyva <juanleyvadelgado@gmail.com>
Fri, 9 Oct 2015 14:26:59 +0000 (16:26 +0200)
committerDan Poltawski <dan@moodle.com>
Thu, 15 Oct 2015 12:59:15 +0000 (13:59 +0100)
mod/survey/save.php

index a98013b..4b3580e 100644 (file)
         print_error('invalidsurveyid', 'survey');
     }
 
-    $params = array(
-        'context' => $context,
-        'courseid' => $course->id,
-        'other' => array('surveyid' => $survey->id)
-    );
-    $event = \mod_survey\event\response_submitted::create($params);
-    $event->trigger();
-
     $strsurveysaved = get_string('surveysaved', 'survey');
 
     $PAGE->set_title($strsurveysaved);
         }
     }
 
+    $params = array(
+        'context' => $context,
+        'courseid' => $course->id,
+        'other' => array('surveyid' => $survey->id)
+    );
+    $event = \mod_survey\event\response_submitted::create($params);
+    $event->trigger();
+
 // Print the page and finish up.
 
     notice(get_string("thanksforanswers","survey", $USER->firstname), "$CFG->wwwroot/course/view.php?id=$course->id");