Skip to content

Commit

Permalink
MDL-33465 course: 'Course view section' logs should use sectionid ins…
Browse files Browse the repository at this point in the history
…tead of section number to generate action urls'
  • Loading branch information
ankitagarwal committed Jun 5, 2012
1 parent 4db0616 commit 336d8c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backup/moodle2/restore_final_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +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_section}');
$rules[] = new restore_log_rule('course', 'view section', 'view.php?id={course}&sectionid={course_section}', '{course_section}');

// module 'user' rules
$rules[] = new restore_log_rule('user', 'view', 'view.php?id={user}&course={course}', '{user}');
Expand Down
5 changes: 0 additions & 5 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,6 @@ public function process_section($data) {
global $CFG, $DB;
$data = (object)$data;
$oldid = $data->id; // We'll need this later
$oldsection = $data->number;

$restorefiles = false;

Expand Down Expand Up @@ -1100,12 +1099,10 @@ 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);
Expand Down Expand Up @@ -2544,7 +2541,6 @@ 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();
Expand All @@ -2571,7 +2567,6 @@ 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
Expand Down
7 changes: 3 additions & 4 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@
$loglabel = 'view';
$infoid = $course->id;
if(!empty($section)) {
$logparam .= '&section='. $section;
$loglabel = 'view section';
$sectionparams = array('course' => $course->id, 'section' => $section);
if ($coursesections = $DB->get_record('course_sections', $sectionparams, 'id', MUST_EXIST)) {
$infoid = $coursesections->id;
}
$coursesections = $DB->get_record('course_sections', $sectionparams, 'id', MUST_EXIST);
$infoid = $coursesections->id;
$logparam .= '&sectionid='. $infoid;
}
add_to_log($course->id, 'course', $loglabel, "view.php?". $logparam, $infoid);

Expand Down

0 comments on commit 336d8c4

Please sign in to comment.