Skip to content

Commit

Permalink
MDL-32766 course log: specify log for viewing course section
Browse files Browse the repository at this point in the history
  • Loading branch information
Rossiani Wijaya committed May 22, 2012
1 parent 4f7f2a8 commit 15a848b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions backup/moodle2/restore_final_task.class.php
Expand Up @@ -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 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 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', '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 // module 'user' rules
$rules[] = new restore_log_rule('user', 'view', 'view.php?id={user}&course={course}', '{user}'); $rules[] = new restore_log_rule('user', 'view', 'view.php?id={user}&course={course}', '{user}');
Expand Down
6 changes: 5 additions & 1 deletion backup/moodle2/restore_stepslib.php
Expand Up @@ -1034,6 +1034,7 @@ public function process_section($data) {
global $CFG, $DB; global $CFG, $DB;
$data = (object)$data; $data = (object)$data;
$oldid = $data->id; // We'll need this later $oldid = $data->id; // We'll need this later
$oldsection = $data->number;


$restorefiles = false; $restorefiles = false;


Expand Down Expand Up @@ -1086,10 +1087,12 @@ public function process_section($data) {


$DB->update_record('course_sections', $section); $DB->update_record('course_sections', $section);
$newitemid = $secrec->id; $newitemid = $secrec->id;
$oldsection = $secrec->section;
} }


// Annotate the section mapping, with restorefiles option if needed // Annotate the section mapping, with restorefiles option if needed
$this->set_mapping('course_section', $oldid, $newitemid, $restorefiles); $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 // set the new course_section id in the task
$this->task->set_sectionid($newitemid); $this->task->set_sectionid($newitemid);
Expand Down Expand Up @@ -2528,7 +2531,7 @@ protected function process_module($data) {


$data = (object)$data; $data = (object)$data;
$oldid = $data->id; $oldid = $data->id;

$oldsection = $data->sectionnumber;
$this->task->set_old_moduleversion($data->version); $this->task->set_old_moduleversion($data->version);


$data->course = $this->task->get_courseid(); $data->course = $this->task->get_courseid();
Expand All @@ -2555,6 +2558,7 @@ protected function process_module($data) {
'course' => $this->get_courseid(), 'course' => $this->get_courseid(),
'section' => 1); 'section' => 1);
$data->section = $DB->insert_record('course_sections', $sectionrec); // 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 $data->groupingid= $this->get_mappingid('grouping', $data->groupingid); // grouping
if (!$CFG->enablegroupmembersonly) { // observe groupsmemberonly if (!$CFG->enablegroupmembersonly) { // observe groupsmemberonly
Expand Down
9 changes: 7 additions & 2 deletions course/view.php
Expand Up @@ -88,8 +88,13 @@


require_once($CFG->dirroot.'/calendar/lib.php'); /// This is after login because it needs $USER require_once($CFG->dirroot.'/calendar/lib.php'); /// This is after login because it needs $USER


//TODO: danp do we need different urls? $logparam = 'id='. $course->id;
add_to_log($course->id, 'course', 'view', "view.php?id=$course->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); $course->format = clean_param($course->format, PARAM_ALPHA);
if (!file_exists($CFG->dirroot.'/course/format/'.$course->format.'/format.php')) { if (!file_exists($CFG->dirroot.'/course/format/'.$course->format.'/format.php')) {
Expand Down

0 comments on commit 15a848b

Please sign in to comment.