Skip to content

Commit

Permalink
Merge pull request #45 from rlorenzo/updated-logging_28dev
Browse files Browse the repository at this point in the history
Converting add_to_log to new logging system for Moodle 2.7+
  • Loading branch information
gonenradai committed Aug 27, 2015
2 parents fe1e7e3 + e63ed67 commit 8d42764
Show file tree
Hide file tree
Showing 16 changed files with 485 additions and 4 deletions.
59 changes: 59 additions & 0 deletions mod/kalvidassign/classes/event/assignment_details_viewed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* The assignment_details_viewed event.
*
* @package mod
* @subpackage kalvidassign
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_kalvidassign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The assignment_details_viewed event class.
*
*
* @since Moodle 2.7
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class assignment_details_viewed extends \core\event\base {
protected function init() {
$this->data['crud'] = 'r'; // c(reate), r(ead), u(pdate), d(elete)
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'kalvidassign';
}

public static function get_name() {
return get_string('eventassignment_details_viewed', 'kalvidassign');
}

public function get_description() {
return "The user with id '{$this->userid}' viewed the details"
. " of the Kaltura media assignment with the course module id of '{$this->contextinstanceid}'.";
}

public function get_url() {
return new \moodle_url('view.php', array('cmid' => $this->contextinstanceid));
}

public function get_legacy_logdata() {
return array($this->courseid, 'kalvidassign', 'view assignment details',
$this->get_url(), $this->objectid, $this->contextinstanceid);
}
}
59 changes: 59 additions & 0 deletions mod/kalvidassign/classes/event/assignment_submitted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* The assignment_submitted event.
*
* @package mod
* @subpackage kalvidassign
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_kalvidassign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The assignment_submitted event class.
*
*
* @since Moodle 2.7
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class assignment_submitted extends \core\event\base {
protected function init() {
$this->data['crud'] = 'u'; // c(reate), r(ead), u(pdate), d(elete)
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'kalvidassign_submission';
}

public static function get_name() {
return get_string('eventassignment_submitted', 'kalvidassign');
}

public function get_description() {
return "The user with id '{$this->userid}' made a submission to the Kaltura media"
. " assignment with the course module id of '{$this->contextinstanceid}'.";
}

public function get_url() {
return new \moodle_url('view.php', array('cmid' => $this->contextinstanceid));
}

public function get_legacy_logdata() {
return array($this->courseid, 'kalvidassign', 'submit',
$this->get_url(), $this->objectid, $this->contextinstanceid);
}
}
59 changes: 59 additions & 0 deletions mod/kalvidassign/classes/event/grade_submissions_page_viewed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* The grade_submissions_page_viewed event.
*
* @package mod
* @subpackage kalvidassign
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_kalvidassign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The grade_submissions_page_viewed event class.
*
*
* @since Moodle 2.7
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class grade_submissions_page_viewed extends \core\event\base {
protected function init() {
$this->data['crud'] = 'r'; // c(reate), r(ead), u(pdate), d(elete)
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'kalvidassign';
}

public static function get_name() {
return get_string('eventgrade_submissions_page_viewed', 'kalvidassign');
}

public function get_description() {
return "The user with id '{$this->userid}' viewed the grade submissions page for "
. "the Kaltura media assignment with the course module id '{$this->contextinstanceid}'.";
}

public function get_url() {
return new \moodle_url('grade_submissions.php', array('cmid' => $this->contextinstanceid));
}

public function get_legacy_logdata() {
return array($this->courseid, 'kalvidassign', 'view submissions page',
$this->get_url(), $this->objectid, $this->contextinstanceid);
}
}
61 changes: 61 additions & 0 deletions mod/kalvidassign/classes/event/grades_updated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* The grades_updated event.
*
* @package mod
* @subpackage kalvidassign
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_kalvidassign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The grades_updated event class.
*
* @property-read array $other {
* 'crud' => string 'c', 'r', 'u', or 'd', depending on context the event is triggered in
* }
*
* @since Moodle 2.7
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class grades_updated extends \core\event\base {
protected function init() {
$this->data['crud'] = 'u'; // c(reate), r(ead), u(pdate), d(elete)
$this->data['edulevel'] = self::LEVEL_TEACHING;
}

public static function get_name() {
return get_string('eventgrades_updated', 'kalvidassign');
}

public function get_description() {
return "The user with id '{$this->userid}' updated the grades"
. " for the Kaltura media assignment with the course module id of '{$this->contextinstanceid}'.";
}

public function get_url() {
return new \moodle_url('grade_submissions.php', array('cmid' => $this->contextinstanceid));
}

public function get_legacy_logdata() {
return array($this->courseid, 'kalvidassign', 'update grades',
$this->get_url(), $this->contextinstanceid);
}
}
59 changes: 59 additions & 0 deletions mod/kalvidassign/classes/event/single_submission_page_viewed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* The single_submission_page_viewed event.
*
* @package mod
* @subpackage kalvidassign
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_kalvidassign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The single_submission_page_viewed event class.
*
*
* @since Moodle 2.7
* @copyright 2015 Rex Lorenzo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class single_submission_page_viewed extends \core\event\base {
protected function init() {
$this->data['crud'] = 'r'; // c(reate), r(ead), u(pdate), d(elete)
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'kalvidassign_submission';
}

public static function get_name() {
return get_string('eventsingle_submission_page_viewed', 'kalvidassign');
}

public function get_description() {
return "The user with id '{$this->userid}' viewed the submission with id '{$this->objectid}'"
. " for the Kaltura media assignment with the course module id of '{$this->contextinstanceid}'.";
}

public function get_url() {
return new \moodle_url('single_submission.php', array('cmid' => $this->contextinstanceid));
}

public function get_legacy_logdata() {
return array($this->courseid, 'kalvidassign', 'view submission page',
$this->get_url(), $this->objectid, $this->contextinstanceid);
}
}
24 changes: 23 additions & 1 deletion mod/kalvidassign/grade_submissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@

require_capability('mod/kalvidassign:gradesubmission', context_module::instance($cm->id));

$event = \mod_kalvidassign\event\grade_submissions_page_viewed::create(array(
'objectid' => $kalvidassignobj->id,
'context' => context_module::instance($cm->id)
));
$event->trigger();

$prefform = new kalvidassign_gradepreferences_form(null, array('cmid' => $cm->id, 'groupmode' => $cm->groupmode));
$data = null;

Expand Down Expand Up @@ -141,6 +147,14 @@

kalvidassign_grade_item_update($kalvidassignobj, $grade);

// Add to log only if updating.
$event = \mod_kalvidassign\event\grades_updated::create(array(
'context' => context_module::instance($cm->id),
'other' => array(
'crud' => 'u'
)
));
$event->trigger();
}

} else {
Expand Down Expand Up @@ -182,6 +196,14 @@

kalvidassign_grade_item_update($kalvidassignobj, $grade);

// Add to log only if updating
$event = \mod_kalvidassign\event\grades_updated::create(array(
'context' => context_module::instance($cm->id),
'other' => array(
'crud' => 'c'
)
));
$event->trigger();
}

}
Expand All @@ -197,4 +219,4 @@

$PAGE->requires->yui_module('moodle-local_kaltura-ltipanel', 'M.local_kaltura.initreviewsubmission');

echo $OUTPUT->footer();
echo $OUTPUT->footer();
7 changes: 6 additions & 1 deletion mod/kalvidassign/lang/en/kalvidassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@
$string['failedtoinsertsubmission'] = 'Failed to insert submission record.';
$string['video_thumbnail'] = 'Video thumbnail';
$string['feedbackfromteacher'] = 'Feedback From Teacher';
$string['currentgrade'] = 'Current grade in gradebook';
$string['currentgrade'] = 'Current grade in gradebook';
$string['eventgrade_submissions_page_viewed'] = 'Grade submissions page viewed';
$string['eventsingle_submission_page_viewed'] = 'Single submission page viewed';
$string['eventgrades_updated'] = 'Assignment grades updated';
$string['eventassignment_submitted'] = 'Assignment submitted';
$string['eventassignment_details_viewed'] = 'Assignment details viewed';
Loading

0 comments on commit 8d42764

Please sign in to comment.