mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-70821 course: Render activity information output component in course
Use the activity information output component to render activity completion details and activity dates for activities on the course homepage. Includes fixup from Shamim Rezaie <shamim@moodle.com>
This commit is contained in:
parent
18aafd0ed4
commit
abc5d76175
@ -24,13 +24,14 @@
|
||||
|
||||
namespace core_course\output;
|
||||
|
||||
use core_course\course_format;
|
||||
use section_info;
|
||||
use completion_info;
|
||||
use renderable;
|
||||
use templatable;
|
||||
use cm_info;
|
||||
use core\activity_dates;
|
||||
use core_completion\cm_completion_details;
|
||||
use core_course\course_format;
|
||||
use renderable;
|
||||
use section_info;
|
||||
use stdClass;
|
||||
use templatable;
|
||||
|
||||
/**
|
||||
* Base class to render a course module inside a course format.
|
||||
@ -82,20 +83,26 @@ class cm_format implements renderable, templatable {
|
||||
* @return stdClass data context for a mustache template
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output): stdClass {
|
||||
global $USER;
|
||||
|
||||
$format = $this->format;
|
||||
$course = $format->get_course();
|
||||
$mod = $this->mod;
|
||||
$displayoptions = $this->displayoptions;
|
||||
$course = $mod->get_course();
|
||||
|
||||
$completiondetails = cm_completion_details::get_instance($mod, $USER->id, $course->showcompletionconditions);
|
||||
$activitydates = [];
|
||||
if ($course->showactivitydates) {
|
||||
$activitydates = activity_dates::get_dates_for_module($mod, $USER->id);
|
||||
}
|
||||
$activityinfo = new activity_information($mod, $completiondetails, $activitydates);
|
||||
$data = (object)[
|
||||
'cmname' => $output->course_section_cm_name($mod, $displayoptions),
|
||||
'afterlink' => $mod->afterlink,
|
||||
'altcontent' => $output->course_section_cm_text($mod, $displayoptions),
|
||||
'availability' => $output->course_section_cm_availability($mod, $displayoptions),
|
||||
'url' => $mod->url,
|
||||
'completion' => $output->course_section_cm_completion(
|
||||
$course, $this->completioninfo, $mod, $displayoptions
|
||||
),
|
||||
'activityinfo' => $activityinfo->export_for_template($output),
|
||||
];
|
||||
|
||||
if (!empty($mod->indent)) {
|
||||
@ -125,7 +132,7 @@ class cm_format implements renderable, templatable {
|
||||
$data->moveicon = course_get_cm_move($mod, $returnsection);
|
||||
}
|
||||
|
||||
if (!empty($data->completion) || !empty($data->extras)) {
|
||||
if (!empty($data->extras)) {
|
||||
$data->hasextras = true;
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,19 @@ class cmitem implements renderable, templatable {
|
||||
$data = new stdClass();
|
||||
$data->cms = [];
|
||||
|
||||
$showactivityconditions = $course->showcompletionconditions == COMPLETION_SHOW_CONDITIONS;
|
||||
$showactivitydates = !empty($course->showactivitydates);
|
||||
|
||||
// This will apply styles to the course homepage when the activity information output component is displayed.
|
||||
$hasinfo = $showactivityconditions || $showactivitydates;
|
||||
|
||||
$item = new $this->cmclass($format, $this->section, $completioninfo, $mod, $this->displayoptions);
|
||||
return (object)[
|
||||
'id' => $mod->id,
|
||||
'module' => $mod->modname,
|
||||
'extraclasses' => $mod->extraclasses,
|
||||
'cmformat' => $item->export_for_template($output),
|
||||
'hasinfo' => $hasinfo,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -848,14 +848,6 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
*
|
||||
* @deprecated since 4.0 - use core_course output components instead.
|
||||
*
|
||||
* This function calls:
|
||||
* {@link core_course_renderer::course_section_cm_name()}
|
||||
* {@link core_course_renderer::course_section_cm_text()}
|
||||
* {@link core_course_renderer::course_section_cm_availability()}
|
||||
* {@link core_course_renderer::course_section_cm_completion()}
|
||||
* {@link course_get_cm_edit_actions()}
|
||||
* {@link core_course_renderer::course_section_cm_edit_actions()}
|
||||
*
|
||||
* @param stdClass $course
|
||||
* @param completion_info $completioninfo
|
||||
* @param cm_info $mod
|
||||
|
@ -28,9 +28,17 @@
|
||||
"afterlink": "<span class=\"badge badge-primary\">30 unread messages</span>",
|
||||
"hasextras": true,
|
||||
"extras": ["<span class=\"badge badge-secondary\">[extras]</span>"],
|
||||
"completion": "<span class=\"badge badge-success\">Completed!</span>",
|
||||
"activityinfo": {
|
||||
"activityname": "Activity example",
|
||||
"hascompletion": true,
|
||||
"uservisible": true,
|
||||
"hasdates": true,
|
||||
"isautomatic": true,
|
||||
"istrackeduser": true,
|
||||
"activitydates": [{ "label": "Opens:", "timestamp": 1293876000 }],
|
||||
"completiondetails": [{ "statusincomplete": 1, "description": "Receive a grade" }]
|
||||
},
|
||||
"availability": "<div><span class=\"badge badge-info\">Restricted</span> Available from <strong>3 Dec 2029</strong></div>"
|
||||
|
||||
}
|
||||
}}
|
||||
<div>
|
||||
@ -57,10 +65,12 @@
|
||||
{{#hasextras}}
|
||||
<div class="actions">
|
||||
{{#extras}} {{{.}}} {{/extras}}
|
||||
{{{completion}}}
|
||||
</div>
|
||||
{{/hasextras}}
|
||||
|
||||
{{#activityinfo}}
|
||||
{{> core_course/activity_info}}
|
||||
{{/activityinfo}}
|
||||
{{{availability}}}
|
||||
|
||||
{{#hasurl}} {{{altcontent}}} {{/hasurl}}
|
||||
|
@ -36,7 +36,7 @@
|
||||
"extraclasses": "newmessages"
|
||||
}
|
||||
}}
|
||||
<li class="activity {{module}} modtype_{{module}} {{extraclasses}}" id="module-{{id}}">
|
||||
<li class="activity {{module}} modtype_{{module}} {{extraclasses}} {{#hasinfo}}hasinfo{{/hasinfo}}" id="module-{{id}}">
|
||||
{{#cmformat}}
|
||||
{{> core_course/local/cm_format}}
|
||||
{{/cmformat}}
|
||||
|
@ -205,8 +205,19 @@ body:not(.editing) .sitetopic ul.section {
|
||||
}
|
||||
|
||||
.section li.activity {
|
||||
padding: .2em;
|
||||
padding: 0.2em;
|
||||
clear: both;
|
||||
|
||||
&.hasinfo {
|
||||
border-bottom: $border-width solid $table-border-color;
|
||||
padding-top: map-get($spacers, 3);
|
||||
padding-bottom: map-get($spacers, 3);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section .activity .activityinstance .groupinglabel {
|
||||
|
@ -13375,8 +13375,15 @@ body:not(.editing) .sitetopic ul.section {
|
||||
padding: .2em; }
|
||||
|
||||
.section li.activity {
|
||||
padding: .2em;
|
||||
padding: 0.2em;
|
||||
clear: both; }
|
||||
.section li.activity.hasinfo {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 1rem; }
|
||||
.section li.activity.hasinfo:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0; }
|
||||
|
||||
.section .activity .activityinstance .groupinglabel {
|
||||
padding-left: 30px; }
|
||||
|
@ -13589,8 +13589,15 @@ body:not(.editing) .sitetopic ul.section {
|
||||
padding: .2em; }
|
||||
|
||||
.section li.activity {
|
||||
padding: .2em;
|
||||
padding: 0.2em;
|
||||
clear: both; }
|
||||
.section li.activity.hasinfo {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 1rem; }
|
||||
.section li.activity.hasinfo:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0; }
|
||||
|
||||
.section .activity .activityinstance .groupinglabel {
|
||||
padding-left: 30px; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user