Skip to content

Commit

Permalink
Merge branch 'wip-MDL-53399' of https://github.com/JoeyAndres/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 21, 2016
2 parents da871bb + fdac806 commit c6d20e6
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 194 deletions.
12 changes: 5 additions & 7 deletions course/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,19 @@ class core_course_renderer extends plugin_renderer_base {
public function __construct(moodle_page $page, $target) {
$this->strings = new stdClass;
parent::__construct($page, $target);
$this->add_modchoosertoggle();
}

/**
* Adds the item in course settings navigation to toggle modchooser
*
* Theme can overwrite as an empty function to exclude it (for example if theme does not
* use modchooser at all)
*
* @deprecated since 3.2
*/
protected function add_modchoosertoggle() {
debugging('core_course_renderer::add_modchoosertoggle() is deprecated.', DEBUG_DEVELOPER);

global $CFG;

// Only needs to be done once per page.
Expand Down Expand Up @@ -182,9 +185,7 @@ public function course_modchooser($modules, $course) {
array(array('courseid' => $course->id, 'closeButtonTitle' => get_string('close', 'editor')))
);
$this->page->requires->strings_for_js(array(
'addresourceoractivity',
'modchooserenable',
'modchooserdisable',
'addresourceoractivity'
), 'moodle');

// Add the header
Expand Down Expand Up @@ -406,9 +407,6 @@ public function course_section_cm_edit_actions($actions, cm_info $mod = null, $d
/**
* Renders HTML for the menus to add activities and resources to the current course
*
* Note, if theme overwrites this function and it does not use modchooser,
* see also {@link core_course_renderer::add_modchoosertoggle()}
*
* @param stdClass $course
* @param int $section relative section number (field course_sections.section)
* @param int $sectionreturn The section to link back to
Expand Down
6 changes: 0 additions & 6 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
$move = optional_param('move', 0, PARAM_INT);
$marker = optional_param('marker',-1 , PARAM_INT);
$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);

$params = array();
Expand Down Expand Up @@ -178,11 +177,6 @@
redirect($PAGE->url);
}
}
if (($modchooser == 1) && confirm_sesskey()) {
set_user_preference('usemodchooser', $modchooser);
} else if (($modchooser == 0) && confirm_sesskey()) {
set_user_preference('usemodchooser', $modchooser);
}

if (has_capability('moodle/course:sectionvisibility', $context)) {
if ($hide && confirm_sesskey()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, {
// Initialize existing sections and register for dynamically created sections
this.setup_for_section();
M.course.coursebase.register_module(this);

// Catch the page toggle
Y.all('.block_settings #settingsnav .type_course .modchoosertoggle a').on('click', this.toggle_mod_chooser, this);
},

/**
Expand Down Expand Up @@ -132,62 +129,6 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, {
this.display_chooser(e);
},

/**
* Toggle availability of the activity chooser.
*
* @method toggle_mod_chooser
* @param {EventFacade} e
*/
toggle_mod_chooser : function(e) {
// Get the add section link
var modchooserlinks = Y.all('div.addresourcemodchooser');

// Get the dropdowns
var dropdowns = Y.all('div.addresourcedropdown');

if (modchooserlinks.size() === 0) {
// Continue with non-js action if there are no modchoosers to add
return;
}

// We need to update the text and link
var togglelink = Y.one('.block_settings #settingsnav .type_course .modchoosertoggle a');

// The actual text is in the last child
var toggletext = togglelink.get('lastChild');

var usemodchooser;
// Determine whether they're currently hidden
if (modchooserlinks.item(0).hasClass('visibleifjs')) {
// The modchooser is currently visible, hide it
usemodchooser = 0;
modchooserlinks
.removeClass('visibleifjs')
.addClass('hiddenifjs');
dropdowns
.addClass('visibleifjs')
.removeClass('hiddenifjs');
toggletext.set('data', M.util.get_string('modchooserenable', 'moodle'));
togglelink.set('href', togglelink.get('href').replace('off', 'on'));
} else {
// The modchooser is currently not visible, show it
usemodchooser = 1;
modchooserlinks
.addClass('visibleifjs')
.removeClass('hiddenifjs');
dropdowns
.removeClass('visibleifjs')
.addClass('hiddenifjs');
toggletext.set('data', M.util.get_string('modchooserdisable', 'moodle'));
togglelink.set('href', togglelink.get('href').replace('on', 'off'));
}

M.util.set_user_preference('usemodchooser', usemodchooser);

// Prevent the page from reloading
e.preventDefault();
},

/**
* Helper function to set the value of a hidden radio button when a
* selection is made.
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, {
// Initialize existing sections and register for dynamically created sections
this.setup_for_section();
M.course.coursebase.register_module(this);

// Catch the page toggle
Y.all('.block_settings #settingsnav .type_course .modchoosertoggle a').on('click', this.toggle_mod_chooser, this);
},

/**
Expand Down Expand Up @@ -132,62 +129,6 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, {
this.display_chooser(e);
},

/**
* Toggle availability of the activity chooser.
*
* @method toggle_mod_chooser
* @param {EventFacade} e
*/
toggle_mod_chooser : function(e) {
// Get the add section link
var modchooserlinks = Y.all('div.addresourcemodchooser');

// Get the dropdowns
var dropdowns = Y.all('div.addresourcedropdown');

if (modchooserlinks.size() === 0) {
// Continue with non-js action if there are no modchoosers to add
return;
}

// We need to update the text and link
var togglelink = Y.one('.block_settings #settingsnav .type_course .modchoosertoggle a');

// The actual text is in the last child
var toggletext = togglelink.get('lastChild');

var usemodchooser;
// Determine whether they're currently hidden
if (modchooserlinks.item(0).hasClass('visibleifjs')) {
// The modchooser is currently visible, hide it
usemodchooser = 0;
modchooserlinks
.removeClass('visibleifjs')
.addClass('hiddenifjs');
dropdowns
.addClass('visibleifjs')
.removeClass('hiddenifjs');
toggletext.set('data', M.util.get_string('modchooserenable', 'moodle'));
togglelink.set('href', togglelink.get('href').replace('off', 'on'));
} else {
// The modchooser is currently not visible, show it
usemodchooser = 1;
modchooserlinks
.addClass('visibleifjs')
.removeClass('hiddenifjs');
dropdowns
.removeClass('visibleifjs')
.addClass('hiddenifjs');
toggletext.set('data', M.util.get_string('modchooserdisable', 'moodle'));
togglelink.set('href', togglelink.get('href').replace('on', 'off'));
}

M.util.set_user_preference('usemodchooser', usemodchooser);

// Prevent the page from reloading
e.preventDefault();
},

/**
* Helper function to set the value of a hidden radio button when a
* selection is made.
Expand Down
59 changes: 0 additions & 59 deletions course/yui/src/modchooser/js/modchooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, {
// Initialize existing sections and register for dynamically created sections
this.setup_for_section();
M.course.coursebase.register_module(this);

// Catch the page toggle
Y.all('.block_settings #settingsnav .type_course .modchoosertoggle a').on('click', this.toggle_mod_chooser, this);
},

/**
Expand Down Expand Up @@ -130,62 +127,6 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, {
this.display_chooser(e);
},

/**
* Toggle availability of the activity chooser.
*
* @method toggle_mod_chooser
* @param {EventFacade} e
*/
toggle_mod_chooser : function(e) {
// Get the add section link
var modchooserlinks = Y.all('div.addresourcemodchooser');

// Get the dropdowns
var dropdowns = Y.all('div.addresourcedropdown');

if (modchooserlinks.size() === 0) {
// Continue with non-js action if there are no modchoosers to add
return;
}

// We need to update the text and link
var togglelink = Y.one('.block_settings #settingsnav .type_course .modchoosertoggle a');

// The actual text is in the last child
var toggletext = togglelink.get('lastChild');

var usemodchooser;
// Determine whether they're currently hidden
if (modchooserlinks.item(0).hasClass('visibleifjs')) {
// The modchooser is currently visible, hide it
usemodchooser = 0;
modchooserlinks
.removeClass('visibleifjs')
.addClass('hiddenifjs');
dropdowns
.addClass('visibleifjs')
.removeClass('hiddenifjs');
toggletext.set('data', M.util.get_string('modchooserenable', 'moodle'));
togglelink.set('href', togglelink.get('href').replace('off', 'on'));
} else {
// The modchooser is currently not visible, show it
usemodchooser = 1;
modchooserlinks
.addClass('visibleifjs')
.removeClass('hiddenifjs');
dropdowns
.removeClass('visibleifjs')
.addClass('hiddenifjs');
toggletext.set('data', M.util.get_string('modchooserdisable', 'moodle'));
togglelink.set('href', togglelink.get('href').replace('on', 'off'));
}

M.util.set_user_preference('usemodchooser', usemodchooser);

// Prevent the page from reloading
e.preventDefault();
},

/**
* Helper function to set the value of a hidden radio button when a
* selection is made.
Expand Down
2 changes: 2 additions & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
$string['computedfromlogs'] = 'Computed from logs since {$a}.';
$string['condifmodeditdefaults'] = 'Default values are used in the settings form when creating a new activity or resource.';
$string['confeditorhidebuttons'] = 'Select the buttons that should be hidden in the HTML editor.';
$string['configenableactivitychooser'] = 'The activity chooser is a dialog box with a short description of each activity and resource. If disabled, separate resource and activity dropdown menus are provided instead.';
$string['configallcountrycodes'] = 'This is the list of countries that may be selected in various places, for example in a user\'s profile. If blank (the default) the list in countries.php in the standard English language pack is used. That is the list from ISO 3166-1. Otherwise, you can specify a comma-separated list of codes, for example \'GB,FR,ES\'. If you add new, non-standard codes here, you will need to add them to countries.php in \'en\' and your language pack.';
$string['configallowassign'] = 'You can allow people who have the roles on the left side to assign some of the column roles to other people';
$string['configallowblockstodock'] = 'If enabled and supported by the selected theme users can choose to move blocks to a special dock.';
Expand Down Expand Up @@ -458,6 +459,7 @@
* Alternative text (optional) - String identifier and component of the alternative text of the emoticon.';
$string['emoticonsreset'] = 'Reset emoticons setting to default values';
$string['emptysettingvalue'] = 'Empty';
$string['enableactivitychooser'] = 'Enable activity chooser';
$string['enableblogs'] = 'Enable blogs';
$string['enablecalendarexport'] = 'Enable calendar export';
$string['enablecomments'] = 'Enable comments';
Expand Down
4 changes: 3 additions & 1 deletion lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ manageofficialtags,core_tag
settypeofficial,core_tag
filetoolarge,core
maxbytesforfile,core
modchooserenable,core
modchooserdisable,core
maxbytes,core_error
downloadcsv,core_table
downloadexcel,core_table
downloadods,core_table
downloadoptions,core_table
downloadtsv,core_table
downloadxhtml,core_table
downloadxhtml,core_table
7 changes: 5 additions & 2 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
$string['courseformatoptions'] = 'Formatting options for {$a}';
$string['courseformatudpate'] = 'Update format';
$string['courseprofiles'] = 'Course profiles';
$string['coursepreferences'] = 'Course preferences';
$string['coursegrades'] = 'Course grades';
$string['coursehelpcategory'] = 'Position the course on the course listing and may make it easier for students to find it.';
$string['coursehelpforce'] = 'Force the course group mode to every activity in the course.';
Expand Down Expand Up @@ -1161,8 +1162,6 @@
$string['month'] = 'Month';
$string['months'] = 'Months';
$string['modified'] = 'Modified';
$string['modchooserenable'] = 'Activity chooser on';
$string['modchooserdisable'] = 'Activity chooser off';
$string['moduleintro'] = 'Description';
$string['modulesetup'] = 'Setting up module tables';
$string['modulesuccess'] = '{$a} tables have been set up correctly';
Expand Down Expand Up @@ -2027,3 +2026,7 @@
// Deprecated since Moodle 3.1.
$string['filetoolarge'] = 'is too large to upload';
$string['maxbytesforfile'] = 'The file {$a} is larger than the maximum size allowed.';

// Deprecated since Moodle 3.2.
$string['modchooserenable'] = 'Activity chooser on';
$string['modchooserdisable'] = 'Activity chooser off';
9 changes: 9 additions & 0 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4453,6 +4453,15 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr
}
}

// Add "Course preferences" link.
if (isloggedin() && !isguestuser($user)) {
if ($currentuser && has_capability('moodle/user:editownprofile', $systemcontext) ||
has_capability('moodle/user:editprofile', $usercontext)) {
$url = new moodle_url('/user/course.php', array('id' => $user->id, 'course' => $course->id));
$useraccount->add(get_string('coursepreferences'), $url, self::TYPE_SETTING, null, 'coursepreferences');
}
}

// View the roles settings.
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override',
'moodle/role:manage'), $usercontext)) {
Expand Down
Loading

0 comments on commit c6d20e6

Please sign in to comment.