MDL-63988 core_my: add course shortname to dashboard blocks …
authorBas Brands <bas@moodle.com>
Mon, 26 Nov 2018 15:10:09 +0000 (16:10 +0100)
committerBas Brands <bas@moodle.com>
Wed, 28 Nov 2018 16:36:20 +0000 (17:36 +0100)
* all dashboard card templates moved to /course/templates/
* added aria labels for course short name
* removed ":" from other course aria strings to improve screenreader output

15 files changed:
blocks/myoverview/templates/course-action-menu.mustache
blocks/myoverview/templates/view-cards.mustache
blocks/myoverview/templates/view-list.mustache
blocks/myoverview/templates/view-summary.mustache
blocks/recentlyaccessedcourses/templates/view-cards.mustache
blocks/starredcourses/templates/view-cards.mustache
course/classes/external/course_summary_exporter.php
course/templates/coursecards.mustache [new file with mode: 0644]
course/templates/favouriteicon.mustache
lang/en/course.php
theme/boost/scss/moodle/blocks.scss
theme/boost/style/moodle.css
theme/bootstrapbase/less/moodle/blocks.less
theme/bootstrapbase/style/moodle.css
theme/bootstrapbase/templates/block_myoverview/course-action-menu.mustache

index 1ce2d5a..e1f70d2 100644 (file)
@@ -39,7 +39,7 @@
         <a class="dropdown-item {{#isfavourite}}hidden{{/isfavourite}}" href="#"
             data-action="add-favourite"
             data-course-id="{{id}}"
-            aria-controls="favorite-icon-{{ id }}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}"
             >
             <span class="text-primary">{{#pix}} i/star, core, {{#str}} favourites, block_myoverview {{/str}} {{/pix}}</span>
             {{#str}} addtofavourites, block_myoverview {{/str}}
@@ -50,7 +50,7 @@
         <a class="dropdown-item {{^isfavourite}}hidden{{/isfavourite}}" href="#"
             data-action="remove-favourite"
             data-course-id="{{id}}"
-            aria-controls="favorite-icon-{{ id }}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}"
             >
             {{#str}} removefromfavourites, block_myoverview {{/str}}
             <div class="sr-only">
@@ -60,7 +60,7 @@
         <a class="dropdown-item {{^hidden}}hidden{{/hidden}}" href="#"
             data-action="show-course"
             data-course-id="{{id}}"
-            aria-controls="favorite-icon-{{ id }}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}"
             >
             {{#pix}} i/show, core, {{#str}} hidden, block_myoverview {{/str}} {{/pix}}
             {{#str}} show, block_myoverview {{/str}}
@@ -71,7 +71,7 @@
         <a class="dropdown-item {{#hidden}}hidden{{/hidden}}" href="#"
             data-action="hide-course"
             data-course-id="{{id}}"
-            aria-controls="favorite-icon-{{ id }}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}"
             >
             {{#pix}} i/hide, core, {{#str}} hidden, block_myoverview {{/str}} {{/pix}}
             {{#str}} hidecourse, block_myoverview {{/str}}
index 5e4bf56..f74554a 100644 (file)
     }
 }}
 
-<div class="card-deck dashboard-card-deck" role="list">
-{{#courses}}
-    <div class="card dashboard-card" role="listitem"
-        data-region="course-content"
-        data-course-id="{{{id}}}">
-        <a href="{{viewurl}}" tabindex="-1">
-            <div class="card-img dashboard-card-img" style='background-image: url("{{{courseimage}}}");'>
-                <span class="sr-only">{{#str}}aria:courseimage, core_course{{/str}}</span>
-            </div>
-        </a>
-        <div class="card-body pr-1 course-info-container" id="course-info-container-{{id}}">
-            <div class="d-flex align-items-start">
-                <div class="card-title mb-0 mr-2">
-                    {{> core_course/favouriteicon }}
-                    <a href="{{viewurl}}" class="coursename">
-                        <span class="sr-only">{{#str}}aria:coursename, core_course{{/str}}</span>
-                        {{#shortentext}}30, {{{fullname}}} {{/shortentext}}
-                    </a>
-                </div>
-                {{> block_myoverview/course-action-menu }}
-            </div>
-        </div>
+{{< core_course/coursecards }}
+    {{$menu}}
+        {{> block_myoverview/course-action-menu }}
+    {{/menu}}
+    {{$progress}}
         {{#hasprogress}}
-        <div class="card-footer dashboard-card-footer border-0 bg-white">
-            {{> block_myoverview/progress-bar}}
-        </div>
+            <div class="card-footer dashboard-card-footer border-0 bg-white">
+                {{> block_myoverview/progress-bar}}
+            </div>
         {{/hasprogress}}
-    </div>
-{{/courses}}
-</div>
\ No newline at end of file
+    {{/progress}}
+    {{$coursename}}
+        <span class="multiline">
+            {{#shortentext}}50, {{{fullname}}} {{/shortentext}}
+        </span>
+    {{/coursename}}
+{{/ core_course/coursecards }}
index 6661455..1291301 100644 (file)
         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">
-                <div class="d-block">
+                <a href="{{viewurl}}" class="coursename">
+                    <span class="sr-only">
+                        {{#str}}aria:courseshortname, core_course{{/str}}
+                    </span>
+                    <div class="text-muted muted">
+                        {{{shortname}}}
+                    </div>
                     {{> core_course/favouriteicon }}
-                    <a href="{{viewurl}}" class="coursename">
-                        <span class="sr-only">{{#str}}aria:coursename, core_course{{/str}}</span>
-                        {{{fullname}}}
-                    </a>
-                </div>
+                    <span class="sr-only">
+                        {{#str}}aria:coursename, core_course{{/str}}
+                    </span>
+                    {{{fullname}}}
+                </a>
             </div>
             {{#hasprogress}}
             <div class="col-md-5 span5 pt-1">
index abc725f..b2b640c 100644 (file)
 
             <div class="align-self-stretch d-flex flex-column w-100">
                 <div class="d-flex mb-1">
-                    <div class="d-block">
+                    <a href="{{viewurl}}" class="coursename">
+                        <span class="sr-only">
+                            {{#str}}aria:courseshortname, core_course{{/str}}
+                        </span>
+                        <div class="h5 mb-0 text-muted muted">
+                            {{{shortname}}}
+                        </div>
                         {{> core_course/favouriteicon }}
-                        <a href="{{viewurl}}" class="coursename">
-                            <span class="sr-only">{{#str}}aria:coursename, core_course{{/str}}</span>
-                            {{{fullname}}}
-                        </a>
-                    </div>
+                        <span class="sr-only">
+                            {{#str}}aria:coursename, core_course{{/str}}
+                        </span>
+                        <h4 class="d-inline mb-2">{{{fullname}}}</h4>
+                    </a>
                     {{> block_myoverview/course-action-menu }}
                 </div>
                 <div class="summary">
index 2f0db9c..7964d9f 100644 (file)
     }
 }}
 
-<div class="card-deck dashboard-card-deck one-row" role="list">
-    {{#courses}}
-        <div class="card dashboard-card m-b-1" role="listitem">
-            <a href="{{viewurl}}" tabindex="-1">
-                <div class="card-img dashboard-card-img" style='background-image: url("{{{courseimage}}}");'>
-                    <span class="sr-only">{{#str}}aria:courseimage, core_course{{/str}}</span>
-                </div>
-            </a>
-            <div class="card-body pr-1 course-info-container" id="course-info-container-{{id}}-{{uniqid}}">
-                <div class="d-flex align-items-start">
-                    <div class="card-title mb-0 mr-2">
-                        {{> core_course/favouriteicon }}
-                        <a href="{{viewurl}}" class="coursename">
-                            <span class="sr-only">{{#str}}aria:coursename, core_course{{/str}}</span>
-                            {{#shortentext}}30, {{{fullname}}} {{/shortentext}}
-                        </a>
-                    </div>
-                </div>
-            </div>
-        </div>
-    {{/courses}}
-</div>
\ No newline at end of file
+
+{{< core_course/coursecards }}
+    {{$classes}}one-row{{/classes}}
+    {{$coursename}} {{fullname}} {{/coursename}}
+{{/ core_course/coursecards }}
index 0ae646a..b84d24e 100644 (file)
         ]
     }
 }}
-<div class="card-deck dashboard-card-deck one-row" role="list">
-{{#courses}}
-    <div class="card dashboard-card m-b-1" role="listitem">
-        <a href="{{viewurl}}" tabindex="-1">
-            <div class="card-img dashboard-card-img" style='background-image: url("{{{courseimage}}}");'>
-                <span class="sr-only">{{#str}}aria:courseimage, core_course{{/str}}</span>
-            </div>
-        </a>
-        <div class="card-body pr-1 course-info-container" id="course-info-container-{{id}}">
-            <div class="d-flex align-items-start">
-                <div class="card-title mr-2 mb-0">
-                    {{>core_course/favouriteicon }}
-                    <a href="{{viewurl}}" class="coursename">
-                        <span class="sr-only">{{#str}}aria:coursename, core_course{{/str}}</span>
-                        {{#shortentext}}30, {{{fullname}}} {{/shortentext}}
-                    </a>
-                </div>
-            </div>
-        </div>
-    </div>
-{{/courses}}
-</div>
+
+{{< core_course/coursecards }}
+    {{$classes}}one-row{{/classes}}
+    {{$coursename}} {{fullname}} {{/coursename}}
+{{/ core_course/coursecards }}
index 2a1416c..bef5cad 100644 (file)
@@ -54,7 +54,7 @@ class course_summary_exporter extends \core\external\exporter {
     }
 
     protected function get_other_values(renderer_base $output) {
-
+        global $CFG;
         $courseimage = self::get_course_image($this->data);
         if (!$courseimage) {
             $courseimage = self::get_course_pattern($this->data);
@@ -72,7 +72,8 @@ class course_summary_exporter extends \core\external\exporter {
             'progress' => $progress,
             'hasprogress' => $hasprogress,
             'isfavourite' => $this->related['isfavourite'],
-            'hidden' => boolval(get_user_preferences('block_myoverview_hidden_course_' . $this->data->id, 0))
+            'hidden' => boolval(get_user_preferences('block_myoverview_hidden_course_' . $this->data->id, 0)),
+            'showshortname' => $CFG->courselistshortnames ? true : false
         );
     }
 
@@ -145,6 +146,9 @@ class course_summary_exporter extends \core\external\exporter {
             'timeaccess' => array(
                 'type' => PARAM_INT,
                 'optional' => true
+            ),
+            'showshortname' => array(
+                'type' => PARAM_BOOL
             )
         );
     }
diff --git a/course/templates/coursecards.mustache b/course/templates/coursecards.mustache
new file mode 100644 (file)
index 0000000..00cb892
--- /dev/null
@@ -0,0 +1,70 @@
+{{!
+    This file is part of Moodle - http://moodle.org/
+
+    Moodle is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Moodle is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+}}
+{{!
+    @template block_myoverview/view-cards
+
+    This template renders the cards view for the myoverview block.
+
+    Example context (json):
+    {
+        "courses": [
+            {
+                "name": "Assignment due 1",
+                "viewurl": "https://moodlesite/course/view.php?id=2",
+                "courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
+                "fullname": "course 3",
+                "hasprogress": true,
+                "progress": 10
+            }
+        ]
+    }
+}}
+
+<div class="card-deck dashboard-card-deck {{$classes}}{{/classes}}" role="list">
+{{#courses}}
+    <div class="card dashboard-card" role="listitem"
+        data-region="course-content"
+        data-course-id="{{{id}}}">
+        <a href="{{viewurl}}" tabindex="-1">
+            <div class="card-img dashboard-card-img" style='background-image: url("{{{courseimage}}}");'>
+                <span class="sr-only">{{#str}}aria:courseimage, core_course{{/str}}</span>
+            </div>
+        </a>
+        <div class="card-body pr-1 course-info-container" id="course-info-container-{{id}}-{{uniqid}}">
+            <div class="d-flex align-items-start">
+                <a href="{{viewurl}}" class="coursename mr-2 text-truncate">
+                    <span class="sr-only">
+                        {{#str}}aria:courseshortname, core_course{{/str}}
+                    </span>
+                    {{#showshortname}}
+                    <div class="text-muted muted w-100 mb-1 text-truncate">
+                        {{{shortname}}}
+                    </div>
+                    {{/showshortname}}
+                    {{> core_course/favouriteicon }}
+                    <span class="sr-only">
+                        {{#str}}aria:coursename, core_course{{/str}}
+                    </span>
+                    {{$coursename}}{{/coursename}}
+                </a>
+                {{$menu}}{{/menu}}
+            </div>
+        </div>
+        {{$progress}}{{/progress}}
+    </div>
+{{/courses}}
+</div>
index 31292a8..5f2cc13 100644 (file)
@@ -25,7 +25,7 @@
         "isfavourite": true
     }
 }}
-<span id="favorite-icon-{{ id }}-{{uniqid}}"
+<span id="favorite-icon-{{ id }}-{{ uniqid }}"
     data-region="favourite-icon"
     data-course-id="{{id}}"
     >
index 3e32f80..84b17be 100644 (file)
@@ -22,8 +22,9 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$string['aria:courseimage'] = 'Course image:';
-$string['aria:coursename'] = 'Course name:';
+$string['aria:courseimage'] = 'Course image';
+$string['aria:courseshortname'] = 'Course short name';
+$string['aria:coursename'] = 'Course name';
 $string['aria:favourite'] = 'Course is starred';
 $string['favourite'] = 'Starred course';
 $string['privacy:perpage'] = 'The number of courses to show per page.';
index 8661198..7151c72 100644 (file)
@@ -102,6 +102,9 @@ $card-gutter : $card-deck-margin * 2;
     .btn-link {
         color: inherit;
     }
+    .multiline {
+        white-space: normal;
+    }
     .btn.btn-link.btn-icon {
         height: 36px;
         width: 36px;
index 7791d6d..0fd1139 100644 (file)
@@ -11240,6 +11240,9 @@ div.editor_atto_toolbar button .icon {
 .block .block-cards .btn-link {
   color: inherit; }
 
+.block .block-cards .multiline {
+  white-space: normal; }
+
 .block .block-cards .btn.btn-link.btn-icon, .block .block-cards #page-grade-grading-manage .actions .btn-link.btn-icon.action, #page-grade-grading-manage .actions .block .block-cards .btn-link.btn-icon.action, .block .block-cards #rubric-rubric.gradingform_rubric #rubric-criteria .criterion .addlevel input.btn-link.btn-icon, #rubric-rubric.gradingform_rubric #rubric-criteria .criterion .addlevel .block .block-cards input.btn-link.btn-icon, .block .block-cards #rubric-rubric.gradingform_rubric .btn-link.btn-icon.addcriterion, #rubric-rubric.gradingform_rubric .block .block-cards .btn-link.btn-icon.addcriterion {
   height: 36px;
   width: 36px;
index 94d568a..c117749 100644 (file)
         border: 1px solid @tableBorder;
         .border-radius(@baseBorderRadius);
     }
+    .multiline {
+        white-space: normal;
+    }
     .summary img {
         max-width: 100%;
     }
index cc303cf..3e9c6ae 100644 (file)
@@ -16376,6 +16376,9 @@ body {
   -moz-border-radius: 4px;
   border-radius: 4px;
 }
+.block .block-cards .multiline {
+  white-space: normal;
+}
 .block .block-cards .summary img {
   max-width: 100%;
 }
index 5819ea8..7dfca46 100644 (file)
         {{#pix}} i/moremenu, core {{/pix}}
     </button>
     <ul class="dropdown-menu pull-right">
-        <li class="{{#isfavourite}}hidden{{/isfavourite}}" data-action="add-favourite" data-course-id="{{id}}">
+        <li class="{{#isfavourite}}hidden{{/isfavourite}}"
+            data-action="add-favourite"
+            data-course-id="{{id}}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}"
+            >
             <a class="dropdown-item p-x-1" href="#">
                 {{#pix}} i/star, core, {{#str}} starred, block_myoverview {{/str}} {{/pix}}
                 {{#str}} addtofavourites, block_myoverview {{/str}}
             </a>
         </li>
-        <li class="{{^isfavourite}}hidden{{/isfavourite}}" data-action="remove-favourite" data-course-id="{{id}}">
+        <li class="{{^isfavourite}}hidden{{/isfavourite}}"
+            data-action="remove-favourite"
+            data-course-id="{{id}}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}"
+            >
             <a class="dropdown-item p-x-1" href="#">
                 {{#str}} removefromfavourites, block_myoverview {{/str}}
             </a>
         </li>
-        <li class="{{^hidden}}hidden{{/hidden}}" data-action="show-course" data-course-id="{{id}}">
+        <li class="{{^hidden}}hidden{{/hidden}}"
+            data-action="show-course"
+            data-course-id="{{id}}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}">
             <a class="dropdown-item p-x-1" href="#">
                 {{#pix}} i/show, core, {{#str}} hidden, block_myoverview {{/str}} {{/pix}}
                 {{#str}} show, block_myoverview {{/str}}
             </a>
         </li>
-        <li class="{{#hidden}}hidden{{/hidden}}" data-action="hide-course" data-course-id="{{id}}">
+        <li class="{{#hidden}}hidden{{/hidden}}"
+            data-action="hide-course"
+            data-course-id="{{id}}"
+            aria-controls="favorite-icon-{{ id }}-{{ uniqid }}">
             <a class="dropdown-item p-x-1" href="#">
                 {{#pix}} i/hide, core, {{#str}} hidden, block_myoverview {{/str}} {{/pix}}
                 {{#str}} hidecourse, block_myoverview {{/str}}