Skip to content

Commit

Permalink
More accessible open all / close all - #67.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Nov 16, 2019
1 parent ec9aae1 commit c2221dc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Version 3.7.1.1
1. Fix Collapsed topics format zoom issue - CONTRIB-7893.
2. Adjust position of 'view only' icon.
3. More accessible open all / close all - #67.

Version 3.7.1.0
1. Add missing Moodle define.
Expand Down
7 changes: 7 additions & 0 deletions lang/en/format_topcoll.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
$string['topcollall'] = 'sections.'; // Leave as AMOS maintains only the latest translation - so previous versions are still supported.
$string['topcollopened'] = 'Open all';
$string['topcollclosed'] = 'Close all';
$string['sctopenall'] = 'Open all {$a}';
$string['sctcloseall'] = 'Close all {$a}';

$string['settoggleallenabled'] = 'Toggle all enabled';
$string['settoggleallenabled_help'] = 'Toggle all functionality enabled.';
$string['defaulttoggleallenabled'] = 'Toggle all enabled';
Expand Down Expand Up @@ -114,6 +117,10 @@
$string['setlayoutstructureday'] = 'Day';
$string['resetlayout'] = 'Layout'; // CONTRIB-3529.
$string['resetalllayout'] = 'Layouts';
$string['layoutstructuretopics'] = 'topics';
$string['layoutstructureweeks'] = 'weeks';
$string['layoutstructuredays'] = 'days';


// Colour enhancement - Moodle Tracker CONTRIB-3529.
$string['setcolour'] = 'Colour';
Expand Down
26 changes: 26 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,32 @@ public function get_section_dates($section, $course = null, $tcsettings = null)
return $o;
}

/**
* What structure collection type are we using?
*
* @return string Structure collection type.
*/
public function get_structure_collection_type() {
$tcsettings = $this->get_settings();
$o = '';

switch($tcsettings['layoutstructure']) {
case 1:
case 4:
$o = get_string('layoutstructuretopics', 'format_topcoll');
break;
case 2:
case 3:
$o = get_string('layoutstructureweeks', 'format_topcoll');
break;
case 5:
$o = get_string('layoutstructuredays', 'format_topcoll');
break;
}

return $o;
}

/**
* The URL to use for the specified course (with section)
*
Expand Down
7 changes: 5 additions & 2 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,13 +1151,16 @@ protected function toggle_all() {
}
$o .= html_writer::start_tag('div', array('class' => 'sectionbody' . $iconsetclass));
$o .= html_writer::start_tag('h4', null);
$sct = $this->courseformat->get_structure_collection_type();
$o .= html_writer::tag('span', get_string('topcollopened', 'format_topcoll'),
array('class' => 'on ' . $this->tctoggleiconsize, 'id' => 'toggles-all-opened',
'role' => 'button', 'tabindex' => '0')
'role' => 'button', 'tabindex' => '0',
'title' => get_string('sctopenall', 'format_topcoll', $sct))
);
$o .= html_writer::tag('span', get_string('topcollclosed', 'format_topcoll'),
array('class' => 'off ' . $this->tctoggleiconsize, 'id' => 'toggles-all-closed',
'role' => 'button', 'tabindex' => '0')
'role' => 'button', 'tabindex' => '0',
'title' => get_string('sctcloseall', 'format_topcoll', $sct))
);
$o .= html_writer::end_tag('h4');
$o .= html_writer::end_tag('div');
Expand Down
5 changes: 3 additions & 2 deletions tests/courseformatrenderer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ public function test_toggle_all() {
$thevalue .= '</div>';
$thevalue .= '<div class="content">';
$thevalue .= '<div class="sectionbody toggle-arrow-hover toggle-arrow"><h4><span class="on tc-medium" id="';
$thevalue .= 'toggles-all-opened" role="button" tabindex="0">Open all</span><span class="off tc-medium" id="toggles-all-closed" ';
$thevalue .= 'role="button" tabindex="0">Close all</span></h4></div></div>';
$thevalue .= 'toggles-all-opened" role="button" tabindex="0" title="Open all topics">Open all</span>';
$thevalue .= '<span class="off tc-medium" id="toggles-all-closed" role="button" tabindex="0" ';
$thevalue .= 'title="Close all topics">Close all</span></h4></div></div>';
$thevalue .= '<div class="right side"><img class="icon spacer" width="1" height="1" alt="" '.$ariahidden.'src="';
$thevalue .= $CFG->wwwroot.'/theme/image.php/_s/boost/core/1/spacer" /></div>';
$thevalue .= '</li>';
Expand Down

0 comments on commit c2221dc

Please sign in to comment.