Merge branch 'wip-MDL-44340-master' of git://github.com/abgreeve/moodle

This commit is contained in:
Damyon Wiese 2014-04-08 12:16:42 +08:00
commit 19346e06cb
5 changed files with 24 additions and 12 deletions

View File

@ -1505,6 +1505,7 @@ class workshop {
/**
* Workshop wrapper around {@see add_to_log()}
* @deprecated since 2.7 Please use the provided event classes for logging actions.
*
* @param string $action to be logged
* @param moodle_url $url absolute url as returned by {@see workshop::submission_url()} and friends
@ -1513,6 +1514,7 @@ class workshop {
* @return void|array array of arguments for add_to_log if $return is true
*/
public function log($action, moodle_url $url = null, $info = null, $return = false) {
debugging('The log method is now deprecated, please use event classes instead', DEBUG_DEVELOPER);
if (is_null($url)) {
$url = $this->view_url();
@ -1690,6 +1692,15 @@ class workshop {
$DB->set_field('workshop', 'phase', $newphase, array('id' => $this->id));
$this->phase = $newphase;
$eventdata = array(
'objectid' => $this->id,
'context' => $this->context,
'other' => array(
'workshopphase' => $this->phase
)
);
$event = \mod_workshop\event\phase_switched::create($eventdata);
$event->trigger();
return true;
}

View File

@ -47,7 +47,6 @@ if ($confirm) {
if (!$workshop->switch_phase($phase)) {
print_error('errorswitchingphase', 'workshop', $workshop->view_url());
}
$workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
redirect($workshop->view_url());
}

View File

@ -80,22 +80,20 @@ class mod_workshop_events_testcase extends advanced_testcase {
$this->workshop->phaseswitchassessment = 1;
$this->workshop->submissionend = time() - 1;
$event = \mod_workshop\event\phase_switched::create(array(
'objectid' => $this->workshop->id,
'context' => $this->context,
'courseid' => $this->course->id,
'other' => array('workshopphase' => $this->workshop->phase)
));
$cm = get_coursemodule_from_instance('workshop', $this->workshop->id, $this->course->id, false, MUST_EXIST);
$workshop = new testable_workshop($this->workshop, $cm, $this->course);
// The phase that we are switching to.
$newphase = 30;
// Trigger and capture the event.
$sink = $this->redirectEvents();
$event->trigger();
$workshop->switch_phase($newphase);
$events = $sink->get_events();
$event = reset($events);
// Check that the legacy log data is valid.
$expected = array($this->course->id, 'workshop', 'update switch phase', 'view.php?id=' . $this->workshop->id,
$this->workshop->phase, $this->cm->id);
$newphase, $this->cm->id);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);

7
mod/workshop/upgrade.txt Normal file
View File

@ -0,0 +1,7 @@
This files describes API changes in /mod/workshop - activity modules,
information provided here is intended especially for developers.
=== 2.7 ===
* The method workshop::log() has been deprecated in the workshop module. Please use the event classes instead
(mod/workshop/classes/event).

View File

@ -74,9 +74,6 @@ $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);
$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));