Merge branch 'wip-MDL-18309-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
+2
-1
@@ -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';
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
blocks/navigation/yui/build/moodle-block_navigation-navigation/moodle-block_navigation-navigation.js
Vendored
+2
-1
@@ -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';
|
||||
|
||||
+2
-1
@@ -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';
|
||||
|
||||
@@ -29,11 +29,14 @@ define('AJAX_SCRIPT', true);
|
||||
|
||||
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());
|
||||
|
||||
@@ -44,6 +44,7 @@ if ($categoryid) {
|
||||
|
||||
$PAGE->set_pagelayout('coursecategory');
|
||||
$courserenderer = $PAGE->get_renderer('core', 'course');
|
||||
$courserenderer->returnurl = $PAGE->url;
|
||||
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
|
||||
+5
-1
@@ -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
|
||||
*
|
||||
@@ -1207,7 +1210,8 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -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"
|
||||
@@ -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)) {
|
||||
@@ -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
|
||||
|
||||
|
||||
+2
-1
@@ -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
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+2
-1
@@ -180,7 +180,8 @@ NS._toggle_category_expansion = function(e) {
|
||||
categoryid: categoryid,
|
||||
depth: depth,
|
||||
showcourses: categorynode.getData('showcourses'),
|
||||
type: TYPE_CATEGORY
|
||||
type: TYPE_CATEGORY,
|
||||
returnurl: location.href
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
+2
-1
@@ -179,7 +179,8 @@ NS._toggle_category_expansion = function(e) {
|
||||
categoryid: categoryid,
|
||||
depth: depth,
|
||||
showcourses: categorynode.getData('showcourses'),
|
||||
type: TYPE_CATEGORY
|
||||
type: TYPE_CATEGORY,
|
||||
returnurl: location.href
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ require('../config.php');
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);
|
||||
|
||||
if (!isloggedin()) {
|
||||
// do not use require_login here because we are usually coming from it,
|
||||
@@ -98,6 +99,8 @@ foreach ($forms as $form) {
|
||||
if (!$forms) {
|
||||
if (isguestuser()) {
|
||||
notice(get_string('noguestaccess', 'enrol'), get_login_url());
|
||||
} else if ($returnurl) {
|
||||
notice(get_string('notenrollable', 'enrol'), $returnurl);
|
||||
} else {
|
||||
notice(get_string('notenrollable', 'enrol'), "$CFG->wwwroot/index.php");
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ try {
|
||||
$branchtype = required_param('type', PARAM_INT);
|
||||
// This identifies the block instance requesting AJAX extension
|
||||
$instanceid = optional_param('instance', null, PARAM_INT);
|
||||
// URL of referrer page.
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
@@ -102,9 +104,18 @@ try {
|
||||
if (!$linkcategories) {
|
||||
foreach ($branch->find_all_of_type(navigation_node::TYPE_CATEGORY) as $category) {
|
||||
$category->action = null;
|
||||
foreach ($category->find_all_of_type(navigation_node::TYPE_COURSE) as $course) {
|
||||
$course->action->param('returnurl', $returnurl);
|
||||
}
|
||||
}
|
||||
foreach ($branch->find_all_of_type(navigation_node::TYPE_MY_CATEGORY) as $category) {
|
||||
$category->action = null;
|
||||
foreach ($category->find_all_of_type(navigation_node::TYPE_COURSE) as $course) {
|
||||
$course->action->param('returnurl', $returnurl);
|
||||
}
|
||||
}
|
||||
foreach ($branch->find_all_of_type(navigation_node::TYPE_COURSE) as $course) {
|
||||
$course->action->param('returnurl', $returnurl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -2796,7 +2796,11 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
|
||||
if ($setwantsurltome) {
|
||||
$SESSION->wantsurl = qualified_me();
|
||||
}
|
||||
redirect($CFG->wwwroot .'/enrol/index.php?id='. $course->id);
|
||||
$redirecturl = new moodle_url($CFG->wwwroot .'/enrol/index.php', array('id' => $course->id));
|
||||
if ($PAGE->url->get_param('returnurl')) {
|
||||
$redirecturl->param('returnurl', $PAGE->url->get_param('returnurl'));
|
||||
}
|
||||
redirect($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -186,7 +186,9 @@ if (!$choiceformshown) {
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
echo '<p align="center">'. get_string('notenrolledchoose', 'choice') .'</p>';
|
||||
echo $OUTPUT->container_start('continuebutton');
|
||||
echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id'=>$course->id)), get_string('enrolme', 'core_enrol', $courseshortname));
|
||||
echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?',
|
||||
array('id' => $course->id, 'returnurl' => $PAGE->url)),
|
||||
get_string('enrolme', 'core_enrol', $courseshortname));
|
||||
echo $OUTPUT->container_end();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
+6
-1
@@ -187,7 +187,12 @@ if (!empty($forum)) { // User is starting a new discussion in a forum
|
||||
if (!is_enrolled($coursecontext)) { // User is a guest here!
|
||||
$SESSION->wantsurl = qualified_me();
|
||||
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
|
||||
redirect($CFG->wwwroot.'/enrol/index.php?id='.$course->id, get_string('youneedtoenrol'));
|
||||
redirect(new moodle_url('/enrol/index.php', array(
|
||||
'id' => $course->id,
|
||||
'returnurl' => new moodle_url('/mod/forum/view.php',
|
||||
array('f' => $forum->id))
|
||||
)),
|
||||
get_string('youneedtoenrol'));
|
||||
}
|
||||
}
|
||||
print_error('nopostforum', 'forum');
|
||||
|
||||
Reference in New Issue
Block a user