Skip to content

Commit

Permalink
MDL-66433 block_myoverview: tag courses as "hidden from students"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stopfstedt committed Sep 19, 2019
1 parent f1246ad commit 7f9e015
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 30 deletions.
3 changes: 2 additions & 1 deletion blocks/myoverview/templates/view-cards.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
"fullname": "course 3",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
Expand Down
34 changes: 21 additions & 13 deletions blocks/myoverview/templates/view-list.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
"fullname": "course 3",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
Expand All @@ -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">
Expand Down
36 changes: 22 additions & 14 deletions blocks/myoverview/templates/view-summary.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"fullname": "course 3",
"summary": "This course is about assignments",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
Expand All @@ -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">
Expand All @@ -78,4 +86,4 @@
</div>
</div>
{{/courses}}
</div>
</div>
3 changes: 3 additions & 0 deletions course/classes/external/course_summary_exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public static function define_properties() {
),
'enddate' => array(
'type' => PARAM_INT,
),
'visible' => array(
'type' => PARAM_BOOL,
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 7 additions & 1 deletion course/templates/coursecards.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
"fullname": "course 3",
"hasprogress": true,
"progress": 10
"progress": 10,
"visible": true
}
]
}
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 7f9e015

Please sign in to comment.