Merge branch 'wip-MDL-58502-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski 2017-04-18 19:48:35 +01:00
commit 9c1889810a
5 changed files with 10 additions and 18 deletions

View File

@ -654,31 +654,23 @@ class mod_feedback_completion extends mod_feedback_structure {
/**
* Trigger module viewed event.
*
* @param stdClass $course optional, course object from DB
* @since Moodle 3.3
*/
public function trigger_module_viewed($course = null) {
if ($course == null) {
$course = get_course($this->courseid);
}
$event = \mod_feedback\event\course_module_viewed::create_from_record($this->feedback, $this->cm, $course);
public function trigger_module_viewed() {
$event = \mod_feedback\event\course_module_viewed::create_from_record($this->feedback, $this->cm, $this->cm->get_course());
$event->trigger();
}
/**
* Mark activity viewed for completion-tracking.
*
* @param stdClass $course optional, course object from DB
* @since Moodle 3.3
*/
public function set_module_viewed($course = null) {
public function set_module_viewed() {
global $CFG;
require_once($CFG->libdir . '/completionlib.php');
if ($course == null) {
$course = get_course($this->courseid);
}
$completion = new completion_info($course);
$completion = new completion_info($this->cm->get_course());
$completion->set_module_viewed($this->cm);
}
@ -704,7 +696,7 @@ class mod_feedback_completion extends mod_feedback_structure {
if ($this->form->is_cancelled()) {
// Form was cancelled - return to the course page.
$urltogo = course_get_url($this->courseid);
$urltogo = course_get_url($this->courseid ?: $this->feedback->course);
} else if ($this->form->is_submitted() &&
($this->form->is_validated() || $gopreviouspage)) {
// Form was submitted (skip validation for "Previous page" button).

View File

@ -307,13 +307,13 @@ class mod_feedback_external extends external_api {
$feedbackcompletion = new mod_feedback_completion($feedback, $cm, $course->id);
// Trigger module viewed event.
$feedbackcompletion->trigger_module_viewed($course);
$feedbackcompletion->trigger_module_viewed();
if ($params['moduleviewed']) {
if (!$feedbackcompletion->is_open()) {
throw new moodle_exception('feedback_is_not_open', 'feedback');
}
// Mark activity viewed for completion-tracking.
$feedbackcompletion->set_module_viewed($course);
$feedbackcompletion->set_module_viewed();
}
$result = array(

View File

@ -36,7 +36,7 @@ class mod_feedback_structure {
protected $feedback;
/** @var cm_info */
protected $cm;
/** @var int */
/** @var int course where the feedback is filled. For feedbacks that are NOT on the front page this is 0 */
protected $courseid = 0;
/** @var int */
protected $templateid;

View File

@ -83,7 +83,7 @@ if (!$feedbackcompletion->is_open()) {
// Mark activity viewed for completion-tracking.
if (isloggedin() && !isguestuser()) {
$feedbackcompletion->set_module_viewed($course);
$feedbackcompletion->set_module_viewed();
}
// Check if user is prevented from re-submission.

View File

@ -59,7 +59,7 @@ if (!has_capability('mod/feedback:edititems', $context) &&
}
// Trigger module viewed event.
$feedbackcompletion->trigger_module_viewed($course);
$feedbackcompletion->trigger_module_viewed();
/// Print the page header
echo $OUTPUT->header();