MDL-66433 block_myoverview: tag courses as "hidden from students"

This is intended to visually separate hidden course from open courses in the course overview block
by applying a "Hidden from students" tag to the various views in this block.
To achive this, the course summary exporter's output must be augmented with a "visiblity" attribute,
carrying the given course's corresponding visibility setting.
Since the exporter now expects this data point as part of its input, the output of the course_get_recent_courses()
function had to also be augmented with the course visibility setting to provide this value.
This commit is contained in:
Stefan Topfstedt
2019-09-19 10:09:39 -07:00
parent f1246ad631
commit 7f9e015071
6 changed files with 56 additions and 30 deletions
@@ -28,7 +28,8 @@
"courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
"fullname": "course 3",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
+21 -13
View File
@@ -28,7 +28,8 @@
"courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
"fullname": "course 3",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
@@ -41,21 +42,28 @@
data-course-id="{{{id}}}">
<div class="row-fluid">
<div class="{{#hasprogress}}col-md-6 span6{{/hasprogress}}{{^hasprogress}}col-md-11 span11{{/hasprogress}} d-flex align-items-center">
<a href="{{viewurl}}" class="coursename">
{{#showshortname}}
<div>
<a href="{{viewurl}}" class="coursename">
{{#showshortname}}
<span class="sr-only">
{{#str}}aria:courseshortname, core_course{{/str}}
</span>
<div class="text-muted muted">
{{{shortname}}}
</div>
{{/showshortname}}
{{> core_course/favouriteicon }}
<span class="sr-only">
{{#str}}aria:courseshortname, core_course{{/str}}
{{#str}}aria:coursename, core_course{{/str}}
</span>
<div class="text-muted muted">
{{{shortname}}}
{{{fullname}}}
</a>
{{^visible}}
<div class="hiddenmessage">
<span class="badge badge-info">{{#str}} hiddenfromstudents {{/str}}</span>
</div>
{{/showshortname}}
{{> core_course/favouriteicon }}
<span class="sr-only">
{{#str}}aria:coursename, core_course{{/str}}
</span>
{{{fullname}}}
</a>
{{/visible}}
</div>
</div>
{{#hasprogress}}
<div class="col-md-5 span5 pt-1">
@@ -29,7 +29,8 @@
"fullname": "course 3",
"summary": "This course is about assignments",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
@@ -48,21 +49,28 @@
<div class="align-self-stretch d-flex flex-column w-100">
<div class="d-flex mb-1">
<a href="{{viewurl}}" class="coursename">
{{#showshortname}}
<div>
<a href="{{viewurl}}" class="coursename">
{{#showshortname}}
<span class="sr-only">
{{#str}}aria:courseshortname, core_course{{/str}}
</span>
<div class="text-muted muted mb-1">
{{{shortname}}}
</div>
{{/showshortname}}
{{> core_course/favouriteicon }}
<span class="sr-only">
{{#str}}aria:courseshortname, core_course{{/str}}
{{#str}}aria:coursename, core_course{{/str}}
</span>
<div class="text-muted muted mb-1">
{{{shortname}}}
<h6 class="d-inline h5">{{{fullname}}}</h6>
</a>
{{^visible}}
<div class="hiddenmessage">
<span class="badge badge-info">{{#str}} hiddenfromstudents {{/str}}</span>
</div>
{{/showshortname}}
{{> core_course/favouriteicon }}
<span class="sr-only">
{{#str}}aria:coursename, core_course{{/str}}
</span>
<h6 class="d-inline h5">{{{fullname}}}</h6>
</a>
{{/visible}}
</div>
{{> block_myoverview/course-action-menu }}
</div>
<div class="summary">
@@ -78,4 +86,4 @@
</div>
</div>
{{/courses}}
</div>
</div>
+3
View File
@@ -103,6 +103,9 @@ class course_summary_exporter extends \core\external\exporter {
),
'enddate' => array(
'type' => PARAM_INT,
),
'visible' => array(
'type' => PARAM_BOOL,
)
);
}
+1 -1
View File
@@ -4577,7 +4577,7 @@ function course_get_recent_courses(int $userid = null, int $limit = 0, int $offs
}
$basefields = array('id', 'idnumber', 'summary', 'summaryformat', 'startdate', 'enddate', 'category',
'shortname', 'fullname', 'timeaccess', 'component');
'shortname', 'fullname', 'timeaccess', 'component', 'visible');
$sort = trim($sort);
if (empty($sort)) {
+7 -1
View File
@@ -28,7 +28,8 @@
"courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
"fullname": "course 3",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
@@ -63,6 +64,11 @@
</a>
{{$menu}}{{/menu}}
</div>
{{^visible}}
<div class="hiddenmessage">
<span class="badge badge-info">{{#str}} hiddenfromstudents {{/str}}</span>
</div>
{{/visible}}
</div>
{{$progress}}{{/progress}}
</div>