Skip to content

Commit

Permalink
navigation MDL-14632 Added fuzzy matching as a worst case scenario to…
Browse files Browse the repository at this point in the history
… find the active node and tidied up course report page layouts
  • Loading branch information
Sam Hemelryk committed May 19, 2010
1 parent dec1351 commit 7c4efe3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
11 changes: 6 additions & 5 deletions course/report/log/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
$logformat = optional_param('logformat', 'showashtml', PARAM_ALPHA);

$params = array();
if ($id !== 0) $params['id'] = $id;
if ($host_course !== '') $params['host_course'] = $host_course;
if ($group !== 0) $params['group'] = $group;
if ($user !== 0) $params['user'] = $user;
if ($date !== 0) $params['date'] = $date;
if ($modname !== 0) $params['modname'] = $modname;
if ($modname !== '') $params['modname'] = $modname;
if ($modid !== 0) $params['modid'] = $modid;
if ($modaction !== '') $params['modaction'] = $modaction;
if ($page !== '0') $params['page'] = $page;
Expand All @@ -47,6 +49,7 @@
if ($chooselog !== 0) $params['chooselog'] = $chooselog;
if ($logformat !== 'showashtml') $params['logformat'] = $logformat;
$PAGE->set_url('/course/report/log/index.php', $params);
$PAGE->set_pagelayout('admin');

if ($hostid == $CFG->mnet_localhost_id) {
if (!$course = $DB->get_record('course', array('id'=>$id))) {
Expand Down Expand Up @@ -141,13 +144,11 @@

} else {
if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($strlogs);
echo $OUTPUT->header();
}

Expand Down
3 changes: 1 addition & 2 deletions course/report/outline/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
}

$PAGE->set_url('/course/report/outline/index.php', array('id'=>$id));
$PAGE->set_pagelayout('admin');

require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
Expand All @@ -35,8 +36,6 @@

$PAGE->set_title($course->shortname .': '. $stractivityreport);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($stractivityreport);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($course->fullname));

Expand Down
12 changes: 9 additions & 3 deletions course/report/participation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
$page = optional_param('page', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page

$PAGE->set_url('/course/report/participation/index.php', compact('id', 'roleid', 'instanceid', 'timefrom', 'page', 'perpage'));
$url = new moodle_url('/course/report/participation/index.php', array('id'=>$id));
if ($roleid !== 0) $url->param('roleid');
if ($instanceid !== 0) $url->param('instanceid');
if ($timefrom !== 0) $url->param('timefrom');
if ($action !== '') $url->param('action');
if ($page !== 0) $url->param('page');
if ($perpage !== DEFAULT_PAGE_SIZE) $url->param('perpage');
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');

if ($action != 'view' and $action != 'post') {
$action = ''; // default to all (don't restrict)
Expand Down Expand Up @@ -51,8 +59,6 @@

$PAGE->set_title($course->shortname .': '. $strparticipation);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($strparticipation);
echo $OUTPUT->header();

$modinfo = get_fast_modinfo($course);
Expand Down
7 changes: 2 additions & 5 deletions course/report/progress/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ function csv_quote($value) {
if ($format !== '') {
$url->param('format', $format);
}
if ($start !== '') {
if ($start !== 0) {
$url->param('start', $start);
}
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');

require_login($course);

Expand Down Expand Up @@ -99,10 +100,6 @@ function csv_quote($value) {

$PAGE->set_title($strcompletion);
$PAGE->set_heading($course->fullname);
if (has_capability('moodle/site:viewreports', $context)) {
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
}
$PAGE->navbar->add($strcompletion);
echo $OUTPUT->header();

if($svgcleverness) {
Expand Down
37 changes: 32 additions & 5 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,24 @@ public function find_active_node() {
return false;
}

/**
* Searches all children for the best matching active node
* @return navigation_node|false
*/
public function search_for_active_node() {
if ($this->check_if_active(URL_MATCH_BASE)) {
return $this;
} else {
foreach ($this->children as &$child) {
$outcome = $child->search_for_active_node();
if ($outcome !== false) {
return $outcome;
}
}
}
return false;
}

/**
* Gets the content for this node.
*
Expand Down Expand Up @@ -896,21 +914,23 @@ public function initialise() {
case CONTEXT_SYSTEM :
case CONTEXT_COURSECAT :
// Load the front page course navigation
$this->load_course($SITE);
$coursenode = $this->load_course($SITE);
$this->add_front_page_course_essentials($coursenode, $SITE);
break;
case CONTEXT_BLOCK :
case CONTEXT_COURSE :
// Load the course associated with the page into the navigation
$course = $this->page->course;
$coursenode = $this->load_course($course);
// Make it active
$coursenode->make_active();
// Add the essentials such as reports etc...
$this->add_course_essentials($coursenode, $course);
if ($this->format_display_course_content($course->format)) {
// Load the course sections
$sections = $this->load_course_sections($course, $coursenode);
}
if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) {
$coursenode->make_active();
}
break;
case CONTEXT_MODULE :
$course = $this->page->course;
Expand Down Expand Up @@ -938,8 +958,11 @@ public function initialise() {
}
// Finally load the cm specific navigaton information
$this->load_activity($cm, $course, $activities[$cm->id]);
// And make the activity node active.
$activities[$cm->id]->make_active();
// Check if we have an active ndoe
if (!$activities[$cm->id]->contains_active_node() && !$activities[$cm->id]->search_for_active_node()) {
// And make the activity node active.
$activities[$cm->id]->make_active();
}
break;
case CONTEXT_USER :
$course = $this->page->course;
Expand Down Expand Up @@ -1000,6 +1023,10 @@ public function initialise() {
}
}

if (!$this->contains_active_node()) {
$this->search_for_active_node();
}

// If the user is not logged in modify the navigation structure as detailed
// in {@link http://docs.moodle.org/en/Development:Navigation_2.0_structure}
if (!isloggedin()) {
Expand Down
11 changes: 6 additions & 5 deletions tag/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
$perpage = optional_param('perpage', 18, PARAM_INT);

$params = array();
if ($query) {
if ($query !== '') {
$params['query'] = $query;
}
if ($page) {
if ($page !== 0) {
$params['page'] = $page;
}
if ($perpage) {
if ($perpage !== 18) {
$params['perpage'] = $perpage;
}
$PAGE->set_url('/tag/search.php', $params);
$PAGE->set_url(new moodle_url('/tag/search.php', $params));
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_pagelayout('standard');

$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$manage_link = ' ';

$PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
$PAGE->set_title(get_string('tags', 'tag'));
$PAGE->set_heading($SITE->fullname.': '.$PAGE->title);
echo $OUTPUT->header();

if ( has_capability('moodle/tag:manage',$systemcontext) ) {
Expand Down

0 comments on commit 7c4efe3

Please sign in to comment.