MDL-40921 mod_workshop: New events to replace add_to_log function calls.

This commit is contained in:
Adrian Greeve
2014-02-07 13:21:23 +08:00
committed by Petr Škoda
parent 974c2cdc03
commit 1f0132716e
23 changed files with 1089 additions and 43 deletions
-1
View File
@@ -53,7 +53,6 @@ if ($settingsdata = $settingsform->get_data()) {
$workshop->aggregate_submission_grades(); // updates 'grade' in {workshop_submissions}
$evaluator->update_grading_grades($settingsdata); // updates 'gradinggrade' in {workshop_assessments}
$workshop->aggregate_grading_grades(); // updates 'gradinggrade' in {workshop_aggregations}
$workshop->log('update aggregate grades');
}
redirect(new moodle_url($workshop->view_url(), compact('page', 'sortby', 'sorthow')));
+18 -5
View File
@@ -161,11 +161,6 @@ if (is_null($assessment->grade) and !$assessmenteditable) {
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
if (is_null($assessment->grade)) {
$workshop->log('add assessment', $workshop->assess_url($assessment->id), $assessment->submissionid);
} else {
$workshop->log('update assessment', $workshop->assess_url($assessment->id), $assessment->submissionid);
}
// Let the grading strategy subplugin save its data.
$rawgrade = $strategy->save_assessment($assessment, $data);
@@ -194,6 +189,24 @@ if (is_null($assessment->grade) and !$assessmenteditable) {
// Update the assessment data if there is something other than just the 'id'.
if (count((array)$coredata) > 1 ) {
$DB->update_record('workshop_assessments', $coredata);
$params = array(
'objectid' => $assessment->id,
'context' => $workshop->context,
'other' => array(
'workshopid' => $workshop->id,
'submissionid' => $assessment->submissionid
)
);
if (is_null($assessment->grade)) {
// All workshop_assessments are created when allocations are made. The create event is of more use located here.
$event = \mod_workshop\event\submission_assessed::create($params);
$event->trigger();
} else {
$params['other']['grade'] = $assessment->grade;
$event = \mod_workshop\event\submission_reassessed::create($params);
$event->trigger();
}
}
// And finally redirect the user's browser.
@@ -101,7 +101,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
* @return string
*/
public static function get_name() {
return get_string('event_assessable_uploaded', 'mod_workshop');
return get_string('eventassessableuploaded', 'mod_workshop');
}
/**
@@ -0,0 +1,83 @@
<?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/>.
/**
* mod_workshop assessment evaluated event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop assessment evaluated event class.
*
* @property-read array $other {
* Extra information about the event.
*
* @type string currentgrade current saved grade.
* @type string finalgrade final grade.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class assessment_evaluated extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_aggregations';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'An assessment has been evaluated ' . $this->objectid . '.';
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventassessmentevaluated', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
}
@@ -0,0 +1,86 @@
<?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/>.
/**
* mod_workshop assessment_evaluations reset event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop assessment_evaluations reset event class.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class assessment_evaluations_reset extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'workshop_aggregations';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'The assessment evaluations have been reset ' . $this->objectid . '.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'update clear aggregated grade', 'view.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventassessmentevaluationsreset', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
}
@@ -0,0 +1,93 @@
<?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/>.
/**
* mod_workshop assessment_reevaluated event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop assessment_reevaluated event class.
*
* @property-read array $other {
* Extra information about the event.
*
* @type float currentgrade current saved grade.
* @type float finalgrade final grade.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class assessment_reevaluated extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_aggregations';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'The assessment has been re-evaluated ' . $this->objectid . '.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'update aggregate grade', 'view.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventassessmentreevaluated', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
}
@@ -0,0 +1,86 @@
<?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/>.
/**
* mod_workshop submission assessments reset event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop submission assessments reset event class.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_assessments_reset extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'workshop_assessments';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'The submission assessments of the workshop ' . $this->objectid . ' have been cleared.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'update clear assessments', 'view.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionassessmentsreset', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
}
@@ -0,0 +1,75 @@
<?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/>.
/**
* mod_workshop instances list viewed event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop instances list viewed event class.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class instances_list_viewed extends \core\event\course_module_instance_list_viewed {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'User ' . $this->userid . ' viewed the list of workshop activities in the course ' . $this->courseid . '.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'view all', 'index.php?id=' . $this->courseid, '');
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventinstanceslistviewed', 'mod_workshop');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/index.php', array('id' => $this->courseid));
}
}
@@ -0,0 +1,92 @@
<?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/>.
/**
* mod_workshop phase switched event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop phase switched event class.
*
* @property-read array $other {
* Extra information about the event.
*
* @type int workshopphase Workshop phase.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class phase_switched extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'workshop';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'The phase of the workshop ' . $this->objectid . ' has been switched to ' . $this->other['workshopphase']. '.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'update switch phase', 'view.php?id=' . $this->contextinstanceid,
$this->other['workshopphase'], $this->contextinstanceid);
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventphaseswitched', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
}
@@ -0,0 +1,93 @@
<?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/>.
/**
* mod_workshop submission_assessed event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop submission_assessed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* @type int workshopid Workshop ID.
* @type int submissionid Submission ID.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_assessed extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_assessments';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'A submission has been assessed in the workshop ' . $this->other['workshopid'] . '.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'add assessment ', 'assessment.php?asid=' . $this->objectid,
$this->other['submissionid'], $this->contextinstanceid);
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionassessed', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/assessment.php', array('asid' => $this->objectid));
}
}
@@ -0,0 +1,91 @@
<?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/>.
/**
* This file contains an event for when a workshop submission is created.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event for when a workshop submission is created.
*
* @property-read array $other {
* Extra information about the event.
*
* @type string submissiontitle Submission title.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_created extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_submissions';
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return 'A user with an id of ' . $this->userid . ' created a workshop submission with an id of ' . $this->objectid;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissioncreated', 'workshop');
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/submission.php',
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
}
/**
* replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'add submission',
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}
}
@@ -0,0 +1,94 @@
<?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/>.
/**
* mod_workshop submission_reassessed event.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_workshop submission_reassessed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* @type int workshopid Workshop ID.
* @type int submissionid Submission ID.
* @type float grade Assessment grade.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_reassessed extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_assessment';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return 'A submission was re-assessed in the workshop ' . $this->other['workshopid'] . '.';
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'update assessment', 'assessment.php?asid=' . $this->objectid,
$this->other['submissionid'], $this->contextinstanceid);
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionreassessed', 'mod_workshop');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/assessment.php?', array('asid' => $this->objectid));
}
}
@@ -0,0 +1,91 @@
<?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/>.
/**
* This file contains an event for when a workshop submission is updated.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event for when a workshop submission is updated.
*
* @property-read array $other {
* Extra information about the event.
*
* @type string submissiontitle Submission title.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_updated extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_submissions';
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return 'A user with an id of ' . $this->userid . ' updated a workshop submission with an id of ' . $this->objectid;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionupdated', 'workshop');
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/submission.php',
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
}
/**
* replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'update submission',
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}
}
@@ -0,0 +1,91 @@
<?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/>.
/**
* This file contains an event for when a workshop submission is viewed.
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_workshop\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event for when a workshop submission is viewed.
*
* @property-read array $other {
* Extra information about the event.
*
* @type int workshopid workshop ID.
* }
*
* @package mod_workshop
* @category event
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_viewed extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'workshop_submissions';
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return 'A user with an id of ' . $this->userid . ' viewed a workshop submission with an id of ' . $this->objectid;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionviewed', 'workshop');
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/workshop/submission.php',
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
}
/**
* replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'workshop', 'view submission',
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}
}
-13
View File
@@ -87,19 +87,6 @@ $mform->set_data($currentdata);
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
if ($canmanage) {
if (is_null($assessment->grade)) {
$workshop->log('add reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
} else {
$workshop->log('update reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
}
} else {
if (is_null($assessment->grade)) {
$workshop->log('add example assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
} else {
$workshop->log('update example assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
}
}
// Let the grading strategy subplugin save its data.
$rawgrade = $strategy->save_assessment($assessment, $data);
-4
View File
@@ -57,8 +57,6 @@ $output = $PAGE->get_renderer('mod_workshop');
if ($id) { // example is specified
$example = $workshop->get_example_by_id($id);
$workshop->log('view example', $workshop->exsubmission_url($example->id), $example->id);
} else { // no example specified - create new one
require_capability('mod/workshop:manageexamples', $workshop->context);
$example = new stdclass();
@@ -162,9 +160,7 @@ if ($edit and $canmanage) {
$formdata->contenttrust = 0; // updated later
if (is_null($example->id)) {
$example->id = $formdata->id = $DB->insert_record('workshop_submissions', $formdata);
$workshop->log('add example', $workshop->exsubmission_url($example->id), $example->id);
} else {
$workshop->log('update example', $workshop->exsubmission_url($example->id), $example->id);
if (empty($formdata->id) or empty($example->id) or ($formdata->id != $example->id)) {
throw new moodle_exception('err_examplesubmissionid', 'workshop');
}
+4 -2
View File
@@ -33,8 +33,6 @@ $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_course_login($course);
add_to_log($course->id, 'workshop', 'view all', "index.php?id=$course->id", '');
$PAGE->set_pagelayout('incourse');
$PAGE->set_url('/mod/workshop/index.php', array('id' => $course->id));
$PAGE->set_title($course->fullname);
@@ -45,6 +43,10 @@ $PAGE->navbar->add(get_string('modulenameplural', 'workshop'));
echo $OUTPUT->header();
$params = array('context' => context_course::instance($course->id));
$event = \mod_workshop\event\instances_list_viewed::create($params);
$event->trigger();
/// Get all the appropriate data
if (! $workshops = get_all_instances_in_course('workshop', $course)) {
+13 -1
View File
@@ -106,6 +106,18 @@ $string['evaluation'] = 'Grading evaluation';
$string['evaluationmethod'] = 'Grading evaluation method';
$string['evaluationmethod_help'] = 'The grading evaluation method determines how the grade for assessment is calculated. You can let it re-calculate grades repeatedly with different settings unless you are happy with the result.';
$string['evaluationsettings'] = 'Grading evaluation settings';
$string['eventassessmentevaluationsreset'] = 'Assessment evaluations reset';
$string['eventassessableuploaded'] = 'Assessable uploaded';
$string['eventassessmentevaluated'] = 'Assessment evaluated';
$string['eventassessmentreevaluated'] = 'Assessment re-evaluated';
$string['eventinstanceslistviewed'] = 'Workshop instance list viewed';
$string['eventsubmissionassessed'] = 'Submission assessed';
$string['eventsubmissionassessmentsreset'] = 'Submission assessments cleared';
$string['eventsubmissioncreated'] = 'Submission created';
$string['eventsubmissionreassessed'] = 'Submission re-assessed';
$string['eventsubmissionupdated'] = 'Submission updated';
$string['eventsubmissionviewed'] = 'Submission viewed';
$string['eventphaseswitched'] = 'Phase switched';
$string['event_assessable_uploaded'] = 'A submission has been uploaded.';
$string['example'] = 'Example submission';
$string['exampleadd'] = 'Add example submission';
@@ -235,8 +247,8 @@ $string['strategy_help'] = 'The grading strategy determines the assessment form
* Rubric - A level assessment is given regarding specified criteria';
$string['strategyhaschanged'] = 'The workshop grading strategy has changed since the form was opened for editing.';
$string['submission'] = 'Submission';
$string['submissionby'] = 'Submission by {$a}';
$string['submissionattachment'] = 'Attachment';
$string['submissionby'] = 'Submission by {$a}';
$string['submissioncontent'] = 'Submission content';
$string['submissionend'] = 'Submissions deadline';
$string['submissionendbeforestart'] = 'Submissions deadline can not be specified before the open for submissions date';
+12 -1
View File
@@ -938,7 +938,18 @@ function workshop_cron() {
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$workshop = new workshop($workshop, $cm, $course);
$workshop->switch_phase(workshop::PHASE_ASSESSMENT);
$workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
$params = array(
'objectid' => $workshop->id,
'context' => $workshop->context,
'courseid' => $workshop->course->id,
'other' => array(
'workshopphase' => $workshop->phase
)
);
$event = \mod_workshop\event\phase_switched::create($params);
$event->trigger();
// disable the automatic switching now so that it is not executed again by accident
// if the teacher changes the phase back to the submission one
$DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));
+21 -1
View File
@@ -2451,8 +2451,22 @@ class workshop {
if ($count > 0) {
$finalgrade = grade_floatval($sumgrades / $count);
}
// Event information.
$params = array(
'context' => $this->context,
'courseid' => $this->course->id,
'relateduserid' => $reviewerid
);
// check if the new final grade differs from the one stored in the database
if (grade_floats_different($finalgrade, $current)) {
$params['other'] = array(
'currentgrade' => $current,
'finalgrade' => $finalgrade
);
// we need to save new calculation into the database
if (is_null($agid)) {
// no aggregation record yet
@@ -2461,13 +2475,19 @@ class workshop {
$record->userid = $reviewerid;
$record->gradinggrade = $finalgrade;
$record->timegraded = $timegraded;
$DB->insert_record('workshop_aggregations', $record);
$record->id = $DB->insert_record('workshop_aggregations', $record);
$params['objectid'] = $record->id;
$event = \mod_workshop\event\assessment_evaluated::create($params);
$event->trigger();
} else {
$record = new stdclass();
$record->id = $agid;
$record->gradinggrade = $finalgrade;
$record->timegraded = $timegraded;
$DB->update_record('workshop_aggregations', $record);
$params['objectid'] = $agid;
$event = \mod_workshop\event\assessment_reevaluated::create($params);
$event->trigger();
}
}
}
+32 -11
View File
@@ -52,7 +52,19 @@ if ($edit) {
if ($id) { // submission is specified
$submission = $workshop->get_submission_by_id($id);
$workshop->log('view submission', $workshop->submission_url($submission->id), $submission->id);
$params = array(
'objectid' => $submission->id,
'context' => $workshop->context,
'courseid' => $workshop->course->id,
'relateduserid' => $submission->authorid,
'other' => array(
'workshopid' => $workshop->id
)
);
$event = \mod_workshop\event\submission_viewed::create($params);
$event->trigger();
} else { // no submission specified
if (!$submission = $workshop->get_submission_by_author($USER->id)) {
@@ -188,16 +200,27 @@ if ($edit) {
if ($workshop->phase == workshop::PHASE_ASSESSMENT) {
$formdata->late = $formdata->late | 0x2;
}
// Event information.
$params = array(
'context' => $workshop->context,
'courseid' => $workshop->course->id,
'other' => array(
'submissiontitle' => $formdata->title
)
);
$logdata = null;
if (is_null($submission->id)) {
$submission->id = $formdata->id = $DB->insert_record('workshop_submissions', $formdata);
$logdata = $workshop->log('add submission', $workshop->submission_url($submission->id), $submission->id, true);
$params['objectid'] = $submission->id;
$event = \mod_workshop\event\submission_created::create($params);
$event->trigger();
} else {
$logdata = $workshop->log('update submission', $workshop->submission_url($submission->id), $submission->id, true);
if (empty($formdata->id) or empty($submission->id) or ($formdata->id != $submission->id)) {
throw new moodle_exception('err_submissionid', 'workshop');
}
}
$params['objectid'] = $submission->id;
// save and relink embedded images and save attachments
$formdata = file_postupdate_standard_editor($formdata, 'content', $contentopts, $workshop->context,
'mod_workshop', 'submission_content', $submission->id);
@@ -209,19 +232,17 @@ if ($edit) {
}
// store the updated values or re-save the new submission (re-saving needed because URLs are now rewritten)
$DB->update_record('workshop_submissions', $formdata);
$event = \mod_workshop\event\submission_updated::create($params);
$event->add_record_snapshot('workshop_submissions', $formdata);
$event->trigger();
// send submitted content for plagiarism detection
$fs = get_file_storage();
$files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'submission_attachment', $submission->id);
$params = array(
'context' => $workshop->context,
'objectid' => $submission->id,
'other' => array(
'content' => $formdata->content,
'pathnamehashes' => array_keys($files)
)
);
$params['other']['content'] = $formdata->content;
$params['other']['pathnamehashes'] = array_keys($files);
$event = \mod_workshop\event\assessable_uploaded::create($params);
$event->set_legacy_logdata($logdata);
$event->trigger();
+10 -2
View File
@@ -38,18 +38,26 @@ require_login($course, false, $cm);
$workshop = new workshop($workshop, $cm, $course);
require_sesskey();
$params = array(
'objectid' => $workshop->id,
'context' => $workshop->context,
'courseid' => $course->id
);
switch ($tool) {
case 'clearaggregatedgrades':
require_capability('mod/workshop:overridegrades', $workshop->context);
$workshop->log('update clear aggregated grades');
$workshop->clear_submission_grades();
$workshop->clear_grading_grades();
$event = \mod_workshop\event\assessment_evaluations_reset::create($params);
$event->trigger();
break;
case 'clearassessments':
require_capability('mod/workshop:overridegrades', $workshop->context);
$workshop->log('update clear assessments');
$workshop->clear_assessments();
$event = \mod_workshop\event\submission_assessments_reset::create($params);
$event->trigger();
break;
}
+3 -1
View File
@@ -76,7 +76,9 @@ $event->trigger();
if ($workshop->phase == workshop::PHASE_SUBMISSION and $workshop->phaseswitchassessment
and $workshop->submissionend > 0 and $workshop->submissionend < time()) {
$workshop->switch_phase(workshop::PHASE_ASSESSMENT);
$workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
$eventdata['other']['workshopphase'] = $workshop->phase;
$event = \mod_workshop\event\phase_switched::create($eventdata);
$event->trigger();
// Disable the automatic switching now so that it is not executed again by accident
// if the teacher changes the phase back to the submission one.
$DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));