mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-41726-master-2nd' of git://github.com/FMCorz/moodle
Conflicts: lang/en/moodle.php
- Loading branch information
Showing
7 changed files
with
348 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/>. | ||
|
||
/** | ||
* core course reset ended event. | ||
* | ||
* @package core | ||
* @copyright 2013 Frédéric Massart | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace core\event; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* core course reset ended event class. | ||
* | ||
* @package core | ||
* @copyright 2013 Frédéric Massart | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class course_reset_ended extends \core\event\base { | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return "The reset of course $this->courseid has ended."; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('eventcourseresetended', 'core'); | ||
} | ||
|
||
/** | ||
* Get URL related to the action | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/course/view.php', array('id' => $this->courseid)); | ||
} | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'd'; | ||
$this->data['level'] = self::LEVEL_OTHER; | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
if (!isset($this->other['reset_options'])) { | ||
throw new \coding_exception('The key reset_options must be set in $other.'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/>. | ||
|
||
/** | ||
* core course reset started event. | ||
* | ||
* @package core | ||
* @copyright 2013 Frédéric Massart | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace core\event; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* core course reset started event class. | ||
* | ||
* @package core | ||
* @copyright 2013 Frédéric Massart | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class course_reset_started extends \core\event\base { | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description() { | ||
return "The user $this->userid has started the reset of course $this->courseid."; | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return get_string('eventcourseresetstarted', 'core'); | ||
} | ||
|
||
/** | ||
* Get URL related to the action | ||
* | ||
* @return \moodle_url | ||
*/ | ||
public function get_url() { | ||
return new \moodle_url('/course/view.php', array('id' => $this->courseid)); | ||
} | ||
|
||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'd'; | ||
$this->data['level'] = self::LEVEL_OTHER; | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
if (!isset($this->other['reset_options'])) { | ||
throw new \coding_exception('The key reset_options must be set in $other.'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Group observers. | ||
* | ||
* @package mod_quiz | ||
* @copyright 2013 Frédéric Massart | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_quiz; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot . '/mod/quiz/locallib.php'); | ||
|
||
/** | ||
* Group observers class. | ||
* | ||
* @package mod_quiz | ||
* @copyright 2013 Frédéric Massart | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class group_observers { | ||
|
||
/** | ||
* Flag whether a course reset is in progress or not. | ||
* | ||
* @var int The course ID. | ||
*/ | ||
protected static $resetinprogress = false; | ||
|
||
/** | ||
* A course reset has started. | ||
* | ||
* @param \core\event\base $event The event. | ||
* @return void | ||
*/ | ||
public static function course_reset_started($event) { | ||
self::$resetinprogress = $event->courseid; | ||
} | ||
|
||
/** | ||
* A course reset has ended. | ||
* | ||
* @param \core\event\base $event The event. | ||
* @return void | ||
*/ | ||
public static function course_reset_ended($event) { | ||
if (!empty(self::$resetinprogress)) { | ||
if (!empty($event->other['reset_options']['reset_groups_remove'])) { | ||
quiz_process_group_deleted_in_course($event->courseid); | ||
} | ||
if (!empty($event->other['reset_options']['reset_groups_members'])) { | ||
quiz_update_open_attempts(array('courseid' => $event->courseid)); | ||
} | ||
} | ||
|
||
self::$resetinprogress = null; | ||
} | ||
|
||
/** | ||
* A group was deleted. | ||
* | ||
* @param \core\event\base $event The event. | ||
* @return void | ||
*/ | ||
public static function group_deleted($event) { | ||
if (!empty(self::$resetinprogress)) { | ||
// We will take care of that once the course reset ends. | ||
return; | ||
} | ||
quiz_process_group_deleted_in_course($event->courseid); | ||
} | ||
|
||
/** | ||
* A group member was removed. | ||
* | ||
* @param \core\event\base $event The event. | ||
* @return void | ||
*/ | ||
public static function group_member_added($event) { | ||
quiz_update_open_attempts(array('userid' => $event->relateduserid, 'groupid' => $event->objectid)); | ||
} | ||
|
||
/** | ||
* A group member was deleted. | ||
* | ||
* @param \core\event\base $event The event. | ||
* @return void | ||
*/ | ||
public static function group_member_removed($event) { | ||
if (!empty(self::$resetinprogress)) { | ||
// We will take care of that once the course reset ends. | ||
return; | ||
} | ||
quiz_update_open_attempts(array('userid' => $event->relateduserid, 'groupid' => $event->objectid)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.