Skip to content

Commit

Permalink
Merge branch 'MDL-63445-master' of git://github.com/bmbrands/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Oct 29, 2018
2 parents f3d80b4 + a7712a9 commit 77ac4d8
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 3 deletions.
4 changes: 3 additions & 1 deletion admin/settings/courses.php
Expand Up @@ -121,6 +121,9 @@
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0, $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
array(0 => new lang_string('no'), 1 => new lang_string('yes')))); array(0 => new lang_string('no'), 1 => new lang_string('yes'))));


$temp->add(new admin_setting_configcheckbox('moodlecourse/showcourseimages', get_string('showcourseimages'),
get_string('showcourseimages_desc'), 1));

// Files and uploads. // Files and uploads.
$temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), '')); $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));


Expand Down Expand Up @@ -155,7 +158,6 @@


$ADMIN->add('courses', $temp); $ADMIN->add('courses', $temp);



// "courserequests" settingpage. // "courserequests" settingpage.
$temp = new admin_settingpage('courserequest', new lang_string('courserequest')); $temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
Expand Down
3 changes: 3 additions & 0 deletions lang/en/moodle.php
Expand Up @@ -327,6 +327,7 @@
$string['courseformats'] = 'Course formats'; $string['courseformats'] = 'Course formats';
$string['courseformatoptions'] = 'Formatting options for {$a}'; $string['courseformatoptions'] = 'Formatting options for {$a}';
$string['courseformatudpate'] = 'Update format'; $string['courseformatudpate'] = 'Update format';
$string['courseheaderimage'] = 'Course header image';
$string['courseprofiles'] = 'Course profiles'; $string['courseprofiles'] = 'Course profiles';
$string['coursepreferences'] = 'Course preferences'; $string['coursepreferences'] = 'Course preferences';
$string['coursegrades'] = 'Course grades'; $string['coursegrades'] = 'Course grades';
Expand Down Expand Up @@ -1822,6 +1823,8 @@
$string['showblockcourse'] = 'Show list of courses containing block'; $string['showblockcourse'] = 'Show list of courses containing block';
$string['showcategory'] = 'Show {$a}'; $string['showcategory'] = 'Show {$a}';
$string['showchartdata'] = 'Show chart data'; $string['showchartdata'] = 'Show chart data';
$string['showcourseimages'] = 'Show course images';
$string['showcourseimages_desc'] = 'Show the course image or image placeholder in the course header.';
$string['showcomments'] = 'Show/hide comments'; $string['showcomments'] = 'Show/hide comments';
$string['showcommentsnonjs'] = 'Show comments'; $string['showcommentsnonjs'] = 'Show comments';
$string['showdescription'] = 'Display description on course page'; $string['showdescription'] = 'Display description on course page';
Expand Down
6 changes: 6 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -2666,5 +2666,11 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2018102900.00); upgrade_main_savepoint(true, 2018102900.00);
} }


if ($oldversion < 2018102900.01) {
// Show course images by default.
set_config('showcourseimages', 1, 'moodlecourse');
upgrade_main_savepoint(true, 2018102900.01);
}

return true; return true;
} }
10 changes: 9 additions & 1 deletion lib/outputrenderers.php
Expand Up @@ -4153,7 +4153,7 @@ public function render_preferences_group(preferences_group $renderable) {
} }


public function context_header($headerinfo = null, $headinglevel = 1) { public function context_header($headerinfo = null, $headinglevel = 1) {
global $DB, $USER, $CFG; global $DB, $USER, $CFG, $COURSE;
require_once($CFG->dirroot . '/user/lib.php'); require_once($CFG->dirroot . '/user/lib.php');
$context = $this->page->context; $context = $this->page->context;
$heading = null; $heading = null;
Expand All @@ -4164,6 +4164,14 @@ public function context_header($headerinfo = null, $headinglevel = 1) {
if (isset($headerinfo['heading'])) { if (isset($headerinfo['heading'])) {
$heading = $headerinfo['heading']; $heading = $headerinfo['heading'];
} }

// Show a course image if enabled.
if ($context->contextlevel == CONTEXT_COURSE && get_config('moodlecourse', 'showcourseimages')) {
$exporter = new core_course\external\course_summary_exporter($COURSE, ['context' => $context]);
$courseinfo = $exporter->export($this);
$imagedata = $this->render_from_template('core/course_header_image', $courseinfo);
}

// The user context currently has images and buttons. Other contexts may follow. // The user context currently has images and buttons. Other contexts may follow.
if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) { if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) {
if (isset($headerinfo['user'])) { if (isset($headerinfo['user'])) {
Expand Down
29 changes: 29 additions & 0 deletions lib/templates/course_header_image.mustache
@@ -0,0 +1,29 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/course_header_image
Example context (json):
{
"courseimage": "http://domain.name/pluginfile.php/123/course/overviewfiles/kitten.jpg"
}
}}
<div class="course-header-image-wrapper">
<div class="course-header-image rounded w-100 h-100" style='background-image: url("{{{courseimage}}}");'>
<div class="sr-only">{{#str}}courseheaderimage, core{{/str}}</div>
</div>
</div>
9 changes: 9 additions & 0 deletions theme/boost/scss/moodle/course.scss
Expand Up @@ -1139,6 +1139,15 @@ span.editinstructions {
opacity: 0.5; opacity: 0.5;
} }


.course-header-image-wrapper {
width: 100px;
height: 100px;
.course-header-image {
background-size: cover;
background-position: center;
}
}

/** /**
* Display sizes: * Display sizes:
* Large displays 1200 + * Large displays 1200 +
Expand Down
7 changes: 7 additions & 0 deletions theme/boost/style/moodle.css
Expand Up @@ -12342,6 +12342,13 @@ span.editinstructions {
.course-being-dragged { .course-being-dragged {
opacity: 0.5; } opacity: 0.5; }


.course-header-image-wrapper {
width: 100px;
height: 100px; }
.course-header-image-wrapper .course-header-image {
background-size: cover;
background-position: center; }

/** /**
* Display sizes: * Display sizes:
* Large displays 1200 + * Large displays 1200 +
Expand Down
11 changes: 11 additions & 0 deletions theme/bootstrapbase/less/moodle/course.less
Expand Up @@ -1124,6 +1124,17 @@ span.editinstructions {
.opacity(50); .opacity(50);
} }


.course-header-image-wrapper {
width: 100px;
height: 100px;
.course-header-image {
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
}
}

/** /**
* Display sizes: * Display sizes:
* Large displays 1200 + * Large displays 1200 +
Expand Down
10 changes: 10 additions & 0 deletions theme/bootstrapbase/style/moodle.css
Expand Up @@ -7004,6 +7004,16 @@ span.editinstructions {
opacity: 0.5; opacity: 0.5;
filter: alpha(opacity=50); filter: alpha(opacity=50);
} }
.course-header-image-wrapper {
width: 100px;
height: 100px;
}
.course-header-image-wrapper .course-header-image {
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
}
/** /**
* Display sizes: * Display sizes:
* Large displays 1200 + * Large displays 1200 +
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@


defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();


$version = 2018102900.00; // YYYYMMDD = weekly release date of this DEV branch. $version = 2018102900.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches. // RR = release increments - 00 in DEV branches.
// .XX = incremental changes. // .XX = incremental changes.


Expand Down

0 comments on commit 77ac4d8

Please sign in to comment.