Skip to content

Commit 77ac4d8

Browse files
author
David Monllao
committed
Merge branch 'MDL-63445-master' of git://github.com/bmbrands/moodle
2 parents f3d80b4 + a7712a9 commit 77ac4d8

File tree

10 files changed

+88
-3
lines changed

10 files changed

+88
-3
lines changed

admin/settings/courses.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
122122
array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
123123

124+
$temp->add(new admin_setting_configcheckbox('moodlecourse/showcourseimages', get_string('showcourseimages'),
125+
get_string('showcourseimages_desc'), 1));
126+
124127
// Files and uploads.
125128
$temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
126129

@@ -155,7 +158,6 @@
155158

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

158-
159161
// "courserequests" settingpage.
160162
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
161163
$temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));

lang/en/moodle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@
327327
$string['courseformats'] = 'Course formats';
328328
$string['courseformatoptions'] = 'Formatting options for {$a}';
329329
$string['courseformatudpate'] = 'Update format';
330+
$string['courseheaderimage'] = 'Course header image';
330331
$string['courseprofiles'] = 'Course profiles';
331332
$string['coursepreferences'] = 'Course preferences';
332333
$string['coursegrades'] = 'Course grades';
@@ -1822,6 +1823,8 @@
18221823
$string['showblockcourse'] = 'Show list of courses containing block';
18231824
$string['showcategory'] = 'Show {$a}';
18241825
$string['showchartdata'] = 'Show chart data';
1826+
$string['showcourseimages'] = 'Show course images';
1827+
$string['showcourseimages_desc'] = 'Show the course image or image placeholder in the course header.';
18251828
$string['showcomments'] = 'Show/hide comments';
18261829
$string['showcommentsnonjs'] = 'Show comments';
18271830
$string['showdescription'] = 'Display description on course page';

lib/db/upgrade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,5 +2666,11 @@ function xmldb_main_upgrade($oldversion) {
26662666
upgrade_main_savepoint(true, 2018102900.00);
26672667
}
26682668

2669+
if ($oldversion < 2018102900.01) {
2670+
// Show course images by default.
2671+
set_config('showcourseimages', 1, 'moodlecourse');
2672+
upgrade_main_savepoint(true, 2018102900.01);
2673+
}
2674+
26692675
return true;
26702676
}

lib/outputrenderers.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4153,7 +4153,7 @@ public function render_preferences_group(preferences_group $renderable) {
41534153
}
41544154

41554155
public function context_header($headerinfo = null, $headinglevel = 1) {
4156-
global $DB, $USER, $CFG;
4156+
global $DB, $USER, $CFG, $COURSE;
41574157
require_once($CFG->dirroot . '/user/lib.php');
41584158
$context = $this->page->context;
41594159
$heading = null;
@@ -4164,6 +4164,14 @@ public function context_header($headerinfo = null, $headinglevel = 1) {
41644164
if (isset($headerinfo['heading'])) {
41654165
$heading = $headerinfo['heading'];
41664166
}
4167+
4168+
// Show a course image if enabled.
4169+
if ($context->contextlevel == CONTEXT_COURSE && get_config('moodlecourse', 'showcourseimages')) {
4170+
$exporter = new core_course\external\course_summary_exporter($COURSE, ['context' => $context]);
4171+
$courseinfo = $exporter->export($this);
4172+
$imagedata = $this->render_from_template('core/course_header_image', $courseinfo);
4173+
}
4174+
41674175
// The user context currently has images and buttons. Other contexts may follow.
41684176
if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) {
41694177
if (isset($headerinfo['user'])) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{!
2+
This file is part of Moodle - http://moodle.org/
3+
4+
Moodle is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
Moodle is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
}}
17+
{{!
18+
@template core/course_header_image
19+
20+
Example context (json):
21+
{
22+
"courseimage": "http://domain.name/pluginfile.php/123/course/overviewfiles/kitten.jpg"
23+
}
24+
}}
25+
<div class="course-header-image-wrapper">
26+
<div class="course-header-image rounded w-100 h-100" style='background-image: url("{{{courseimage}}}");'>
27+
<div class="sr-only">{{#str}}courseheaderimage, core{{/str}}</div>
28+
</div>
29+
</div>

theme/boost/scss/moodle/course.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,15 @@ span.editinstructions {
11391139
opacity: 0.5;
11401140
}
11411141

1142+
.course-header-image-wrapper {
1143+
width: 100px;
1144+
height: 100px;
1145+
.course-header-image {
1146+
background-size: cover;
1147+
background-position: center;
1148+
}
1149+
}
1150+
11421151
/**
11431152
* Display sizes:
11441153
* Large displays 1200 +

theme/boost/style/moodle.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12342,6 +12342,13 @@ span.editinstructions {
1234212342
.course-being-dragged {
1234312343
opacity: 0.5; }
1234412344

12345+
.course-header-image-wrapper {
12346+
width: 100px;
12347+
height: 100px; }
12348+
.course-header-image-wrapper .course-header-image {
12349+
background-size: cover;
12350+
background-position: center; }
12351+
1234512352
/**
1234612353
* Display sizes:
1234712354
* Large displays 1200 +

theme/bootstrapbase/less/moodle/course.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,17 @@ span.editinstructions {
11241124
.opacity(50);
11251125
}
11261126

1127+
.course-header-image-wrapper {
1128+
width: 100px;
1129+
height: 100px;
1130+
.course-header-image {
1131+
width: 100%;
1132+
height: 100%;
1133+
background-size: cover;
1134+
background-position: center;
1135+
}
1136+
}
1137+
11271138
/**
11281139
* Display sizes:
11291140
* Large displays 1200 +

theme/bootstrapbase/style/moodle.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7004,6 +7004,16 @@ span.editinstructions {
70047004
opacity: 0.5;
70057005
filter: alpha(opacity=50);
70067006
}
7007+
.course-header-image-wrapper {
7008+
width: 100px;
7009+
height: 100px;
7010+
}
7011+
.course-header-image-wrapper .course-header-image {
7012+
width: 100%;
7013+
height: 100%;
7014+
background-size: cover;
7015+
background-position: center;
7016+
}
70077017
/**
70087018
* Display sizes:
70097019
* Large displays 1200 +

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

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

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

0 commit comments

Comments
 (0)