Skip to content

Commit

Permalink
MDL-40921 mod_workshop: New events to replace add_to_log function calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve authored and skodak committed Feb 7, 2014
1 parent 974c2cd commit 1f01327
Show file tree
Hide file tree
Showing 23 changed files with 1,089 additions and 43 deletions.
1 change: 0 additions & 1 deletion mod/workshop/aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
$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')));
23 changes: 18 additions & 5 deletions mod/workshop/assessment.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@
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);
Expand Down Expand Up @@ -194,6 +189,24 @@
// 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.
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/classes/event/assessable_uploaded.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function get_legacy_logdata() {
* @return string
*/
public static function get_name() {
return get_string('event_assessable_uploaded', 'mod_workshop');
return get_string('eventassessableuploaded', 'mod_workshop');
}

/**
Expand Down
83 changes: 83 additions & 0 deletions mod/workshop/classes/event/assessment_evaluated.php
Original file line number Diff line number Diff line change
@@ -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));
}
}
86 changes: 86 additions & 0 deletions mod/workshop/classes/event/assessment_evaluations_reset.php
Original file line number Diff line number Diff line change
@@ -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));
}
}
93 changes: 93 additions & 0 deletions mod/workshop/classes/event/assessment_reevaluated.php
Original file line number Diff line number Diff line change
@@ -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));
}
}
Loading

0 comments on commit 1f01327

Please sign in to comment.