Skip to content

Commit

Permalink
Merge branch 'wip-MDL-18309-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
danpoltawski committed Apr 15, 2015
2 parents c7ccb54 + 314a221 commit 75e20c1
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 12 deletions.
Expand Up @@ -634,7 +634,8 @@ BRANCH.prototype = {
id : this.get('key'),
type : this.get('type'),
sesskey : M.cfg.sesskey,
instance : this.get('tree').get('instance')
instance : this.get('tree').get('instance'),
returnurl : location.href
};

var ajaxfile = '/lib/ajax/getnavbranch.php';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -632,7 +632,8 @@ BRANCH.prototype = {
id : this.get('key'),
type : this.get('type'),
sesskey : M.cfg.sesskey,
instance : this.get('tree').get('instance')
instance : this.get('tree').get('instance'),
returnurl : location.href
};

var ajaxfile = '/lib/ajax/getnavbranch.php';
Expand Down
3 changes: 2 additions & 1 deletion blocks/navigation/yui/src/navigation/js/navigation.js
Expand Up @@ -632,7 +632,8 @@ BRANCH.prototype = {
id : this.get('key'),
type : this.get('type'),
sesskey : M.cfg.sesskey,
instance : this.get('tree').get('instance')
instance : this.get('tree').get('instance'),
returnurl : location.href
};

var ajaxfile = '/lib/ajax/getnavbranch.php';
Expand Down
3 changes: 3 additions & 0 deletions course/category.ajax.php
Expand Up @@ -29,11 +29,14 @@

require_once(dirname(__dir__) . '/config.php');

$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);

if ($CFG->forcelogin) {
require_login();
}

$PAGE->set_context(context_system::instance());
$courserenderer = $PAGE->get_renderer('core', 'course');
$courserenderer->returnurl = $returnurl;

echo json_encode($courserenderer->coursecat_ajax());
1 change: 1 addition & 0 deletions course/index.php
Expand Up @@ -44,6 +44,7 @@

$PAGE->set_pagelayout('coursecategory');
$courserenderer = $PAGE->get_renderer('core', 'course');
$courserenderer->returnurl = $PAGE->url;

if ($CFG->forcelogin) {
require_login();
Expand Down
6 changes: 5 additions & 1 deletion course/renderer.php
Expand Up @@ -49,6 +49,9 @@ class core_course_renderer extends plugin_renderer_base {
*/
protected $strings;

/** @var moodle_url|null stores page where to return to from the enrolment page */
public $returnurl;

/**
* Override the constructor so that we can initialise the string cache
*
Expand Down Expand Up @@ -1207,7 +1210,8 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi

// course name
$coursename = $chelper->get_course_formatted_name($course);
$coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
$coursenamelink = html_writer::link(new moodle_url('/course/view.php',
array('id' => $course->id, 'returnurl' => $this->returnurl)),
$coursename, array('class' => $course->visible ? '' : 'dimmed'));
$content .= html_writer::tag($nametag, $coursenamelink, array('class' => 'coursename'));
// If we display course in collapsed form but the course has summary or course contacts, display the link to the info page.
Expand Down
69 changes: 69 additions & 0 deletions course/tests/behat/navigate_course_list.feature
@@ -0,0 +1,69 @@
@core @core_course
Feature: Browse course list and return back from enrolment page
In order to navigate between course list consistently
As a user
I need to be able to return back from enrolment page

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@asd.com |
| user2 | User | 2 | user2@asd.com |
And the following "categories" exist:
| name | category | idnumber |
| Sample category | 0 | CAT1 |
And the following "courses" exist:
| fullname | shortname | category |
| Sample course | C1 | 0 |
| Course 1 | COURSE1 | CAT1 |

@javascript
Scenario: A user can return to the category page from enrolment page
When I log in as "user2"
And I click on "Courses" "link" in the "Navigation" "block"
And I follow "Miscellaneous"
And I follow "Sample course"
And I press "Continue"
Then I should see "Courses" in the ".breadcrumb-nav" "css_element"
And I click on "Courses" "link" in the ".breadcrumb-nav" "css_element"
And I follow "Sample category"
And I follow "Course 1"
And I press "Continue"
And I should see "Sample category" in the ".breadcrumb-nav" "css_element"

@javascript
Scenario: A user can return to the previous page from enrolment page by clicking navigation links
When I log in as "user2"
And I expand "My profile settings" node
And I follow "Edit profile"
And I expand "Courses" node
And I expand "Sample category" node
And I follow "Course 1"
And I press "Continue"
Then I should see "Edit profile" in the ".breadcrumb-nav" "css_element"

@javascript
Scenario: User can return to the choice activity from enrolment page
Given the following "roles" exist:
| name | shortname | description | archetype |
| Non-enrolled | custom1 | My custom role 1 | user |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| user1 | custom1 | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| choice | Test choice | Test choice description | C1 | choice1 |
And I log in as "admin"
And I set the following system permissions of "Non-enrolled" role:
| capability | permission |
| moodle/course:view | Allow |
And I log out
When I log in as "user1"
And I click on "Courses" "link" in the "Navigation" "block"
And I follow "Miscellaneous"
And I follow "Sample course"
And I follow "Test choice"
And I should see "Sorry, only enrolled users are allowed to make choices."
And I press "Enrol me in this course"
And I press "Continue"
Then I should see "Test choice" in the ".breadcrumb-nav" "css_element"
4 changes: 4 additions & 0 deletions course/view.php
Expand Up @@ -19,6 +19,7 @@
$switchrole = optional_param('switchrole',-1, PARAM_INT); // Deprecated, use course/switchrole.php instead.
$modchooser = optional_param('modchooser', -1, PARAM_BOOL);
$return = optional_param('return', 0, PARAM_LOCALURL);
$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);

$params = array();
if (!empty($name)) {
Expand All @@ -42,6 +43,9 @@
if ($section) {
$urlparams['section'] = $section;
}
if ($returnurl) {
$urlparams['returnurl'] = $returnurl;
}

$PAGE->set_url('/course/view.php', $urlparams); // Defined here to avoid notices on errors etc

Expand Down
Expand Up @@ -181,7 +181,8 @@ NS._toggle_category_expansion = function(e) {
categoryid: categoryid,
depth: depth,
showcourses: categorynode.getData('showcourses'),
type: TYPE_CATEGORY
type: TYPE_CATEGORY,
returnurl: location.href
}
});
};
Expand Down

0 comments on commit 75e20c1

Please sign in to comment.