Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
620896cf
Commit
620896cf
authored
Apr 30, 2019
by
bas
Browse files
MDL-65449 themes: allow overriding course patterns
* moving course pattern generation to core_renderer
parent
a411b499
Changes
3
Show whitespace changes
Inline
Side-by-side
course/classes/external/course_summary_exporter.php
View file @
620896cf
...
...
@@ -57,7 +57,7 @@ class course_summary_exporter extends \core\external\exporter {
global
$CFG
;
$courseimage
=
self
::
get_course_image
(
$this
->
data
);
if
(
!
$courseimage
)
{
$courseimage
=
self
::
get_course_pattern
(
$this
->
data
);
$courseimage
=
$output
->
get_generated_image_for_id
(
$this
->
data
->
id
);
}
$progress
=
self
::
get_course_progress
(
$this
->
data
);
$hasprogress
=
false
;
...
...
@@ -190,11 +190,10 @@ class course_summary_exporter extends \core\external\exporter {
* @return string datauri
*/
public
static
function
get_course_pattern
(
$course
)
{
$color
=
self
::
coursecolor
(
$course
->
id
);
$pattern
=
new
\
core_geopattern
();
$pattern
->
setColor
(
$color
);
$pattern
->
patternbyid
(
$course
->
id
);
return
$pattern
->
datauri
();
global
$OUTPUT
;
debugging
(
'course_summary_exporter::get_course_pattern() is deprecated. '
.
'Please use $OUTPUT->get_generated_image_for_id() instead.'
,
DEBUG_DEVELOPER
);
return
$OUTPUT
->
get_generated_image_for_id
(
$course
->
id
);
}
/**
...
...
@@ -214,11 +213,9 @@ class course_summary_exporter extends \core\external\exporter {
* @return string hex color code.
*/
public
static
function
coursecolor
(
$courseid
)
{
// The colour palette is hardcoded for now. It would make sense to combine it with theme settings.
$basecolors
=
[
'#81ecec'
,
'#74b9ff'
,
'#a29bfe'
,
'#dfe6e9'
,
'#00b894'
,
'#0984e3'
,
'#b2bec3'
,
'#fdcb6e'
,
'#fd79a8'
,
'#6c5ce7'
];
$color
=
$basecolors
[
$courseid
%
10
];
return
$color
;
global
$OUTPUT
;
debugging
(
'course_summary_exporter::coursecolor() is deprecated. '
.
'Please use $OUTPUT->get_generated_color_for_id() instead.'
,
DEBUG_DEVELOPER
);
return
$OUTPUT
->
get_generated_color_for_id
(
$courseid
);
}
}
course/upgrade.txt
View file @
620896cf
...
...
@@ -3,6 +3,8 @@ information provided here is intended especially for developers.
=== 3.7 ===
* The course pattern function in course_summary_exporter::get_course_pattern has been moved to $OUTPUT->get_generated_image_for_id.
* The course color function in course_summary_exporter::coursecolor has been moved to $OUTPUT->get_generated_color_for_id.
* External function core_course_external::get_course_contents new returns the following additional completiondata field:
- valueused (indicates whether the completion state affects the availability of other content)
* External function core_course_external::get_course_contents now returns a new contentsinfo field with summary files information.
...
...
lib/outputrenderers.php
View file @
620896cf
...
...
@@ -1548,6 +1548,36 @@ class core_renderer extends renderer_base {
return
''
;
}
/**
* Get the course pattern datauri to show on a course card.
*
* The datauri is an encoded svg that can be passed as a url.
* @param int $id Id to use when generating the pattern
* @return string datauri
*/
public
function
get_generated_image_for_id
(
$id
)
{
$color
=
$this
->
get_generated_color_for_id
(
$id
);
$pattern
=
new
\
core_geopattern
();
$pattern
->
setColor
(
$color
);
$pattern
->
patternbyid
(
$id
);
return
$pattern
->
datauri
();
}
/**
* Get the course color to show on a course card.
*
* @param int $id Id to use when generating the color.
* @return string hex color code.
*/
public
function
get_generated_color_for_id
(
$id
)
{
// The colour palette is hardcoded for now. It would make sense to combine it with theme settings.
$basecolors
=
[
'#81ecec'
,
'#74b9ff'
,
'#a29bfe'
,
'#dfe6e9'
,
'#00b894'
,
'#0984e3'
,
'#b2bec3'
,
'#fdcb6e'
,
'#fd79a8'
,
'#6c5ce7'
];
$color
=
$basecolors
[
$id
%
10
];
return
$color
;
}
/**
* Returns lang menu or '', this method also checks forcing of languages in courses.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment