Permalink
Browse files

MDL-32766 course log: specify log for viewing course section

  • Loading branch information...
Rossiani Wijaya
Rossiani Wijaya committed May 15, 2012
1 parent 4f7f2a8 commit 15a848ba906a5cb5fef8dc651fc94c35a73a3b5a
Showing with 13 additions and 3 deletions.
  1. +1 −0 backup/moodle2/restore_final_task.class.php
  2. +5 −1 backup/moodle2/restore_stepslib.php
  3. +7 −2 course/view.php
@@ -135,6 +135,7 @@ static public function define_restore_log_rules() {
$rules[] = new restore_log_rule('course', 'report outline', 'report/outline/index.php?id={course}', '{course}');
$rules[] = new restore_log_rule('course', 'report participation', 'report/participation/index.php?id={course}', '{course}');
$rules[] = new restore_log_rule('course', 'report stats', 'report/stats/index.php?id={course}', '{course}');
+ $rules[] = new restore_log_rule('course', 'view section', 'view.php?id={course}&section={course_sectionnumber}', '{course}');
// module 'user' rules
$rules[] = new restore_log_rule('user', 'view', 'view.php?id={user}&course={course}', '{user}');
@@ -1034,6 +1034,7 @@ public function process_section($data) {
global $CFG, $DB;
$data = (object)$data;
$oldid = $data->id; // We'll need this later
+ $oldsection = $data->number;
$restorefiles = false;
@@ -1086,10 +1087,12 @@ public function process_section($data) {
$DB->update_record('course_sections', $section);
$newitemid = $secrec->id;
+ $oldsection = $secrec->section;
}
// Annotate the section mapping, with restorefiles option if needed
$this->set_mapping('course_section', $oldid, $newitemid, $restorefiles);
+ $this->set_mapping('course_sectionnumber', $oldsection, $section->section, $restorefiles);
// set the new course_section id in the task
$this->task->set_sectionid($newitemid);
@@ -2528,7 +2531,7 @@ protected function process_module($data) {
$data = (object)$data;
$oldid = $data->id;
-
+ $oldsection = $data->sectionnumber;
$this->task->set_old_moduleversion($data->version);
$data->course = $this->task->get_courseid();
@@ -2555,6 +2558,7 @@ protected function process_module($data) {
'course' => $this->get_courseid(),
'section' => 1);
$data->section = $DB->insert_record('course_sections', $sectionrec); // section 1
+ $this->set_mapping('course_sectionnumber', $oldsection, $sectionrec->section, $restorefiles);
}
$data->groupingid= $this->get_mappingid('grouping', $data->groupingid); // grouping
if (!$CFG->enablegroupmembersonly) { // observe groupsmemberonly
View
@@ -88,8 +88,13 @@
require_once($CFG->dirroot.'/calendar/lib.php'); /// This is after login because it needs $USER
- //TODO: danp do we need different urls?
- add_to_log($course->id, 'course', 'view', "view.php?id=$course->id", "$course->id");
+ $logparam = 'id='. $course->id;
+ $loglabel = 'view';
+ if(!empty($section)) {
+ $logparam .= '&section='. $section;
+ $loglabel = 'view section';
+ }
+ add_to_log($course->id, 'course', $loglabel, "view.php?". $logparam, "$course->fullname");
$course->format = clean_param($course->format, PARAM_ALPHA);
if (!file_exists($CFG->dirroot.'/course/format/'.$course->format.'/format.php')) {

0 comments on commit 15a848b

Please sign in to comment.