This commit is contained in:
Mihail Geshoski
2025-12-03 23:27:25 +08:00
6 changed files with 48 additions and 27 deletions
+2
View File
@@ -73,6 +73,7 @@ $string['badarchive'] = 'You must provide a valid zip file';
$string['browse'] = 'Preview';
$string['browsed'] = 'Browsed';
$string['browsemode'] = 'Preview mode';
$string['browsemodewithname'] = 'Preview mode: {$a}';
$string['browserepository'] = 'Browse repository';
$string['cachedef_elements'] = 'Element cache';
$string['calculatedweight'] = 'Calculated weight';
@@ -425,6 +426,7 @@ $string['syntax'] = 'Syntax error';
$string['tag_error'] = 'Unknown tag ({$a->tag}) with this content: {$a->value}';
$string['time'] = 'Time';
$string['title'] = 'Title';
$string['toggletableofcontents'] = 'Toggle table of contents';
$string['toolbar'] = 'Show the toolbar';
$string['too_many_attributes'] = 'Tag {$a->tag} has too many attributes';
$string['too_many_children'] = 'Tag {$a->tag} has too many children';
+10 -1
View File
@@ -2018,7 +2018,16 @@ function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='',
if ($tocheader) {
$result->toc .= html_writer::end_div().html_writer::end_div();
$result->toc .= html_writer::start_div('loading', array('id' => 'scorm_toc_toggle'));
$result->toc .= html_writer::tag('button', '', array('id' => 'scorm_toc_toggle_btn')).html_writer::end_div();
$toggletoclabel = get_string('toggletableofcontents', 'scorm');
$toggletocbutton = html_writer::tag('button', '', [
'id' => 'scorm_toc_toggle_btn',
'type' => 'button',
'class' => 'btn btn-secondary btn-sm mb-1',
'title' => $toggletoclabel,
'aria-label' => $toggletoclabel,
'aria-controls' => 'scorm_toc',
]);
$result->toc .= $toggletocbutton . html_writer::end_div();
$result->toc .= html_writer::start_div('', array('id' => 'scorm_content'));
$result->toc .= html_writer::div('', '', array('id' => 'scorm_navpanel'));
$result->toc .= html_writer::end_div().html_writer::end_div();
+7 -7
View File
@@ -192,6 +192,7 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
obj.setAttribute('allowfullscreen', 'allowfullscreen');
obj.setAttribute('webkitallowfullscreen', 'webkitallowfullscreen');
obj.setAttribute('mozallowfullscreen', 'mozallowfullscreen');
obj.setAttribute('title', toc_title);
if (!window_name && node.title != null) {
obj.setAttribute('src', url_prefix + node.title);
}
@@ -292,14 +293,14 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
toc.addClass(cssclasses.disabled)
.setAttribute('disabled-by', 'screen-size');
scorm_toc_toggle_btn.setHTML('>')
.set('title', M.util.get_string('show', 'moodle'));
.set('aria-expanded', false);
scorm_content.removeClass(cssclasses.scorm_grid_content_toc_visible)
.addClass(cssclasses.scorm_grid_content_toc_hidden);
} else if (body.get('winWidth') > collapsetocwinsize) {
toc.removeClass(cssclasses.disabled)
.removeAttribute('disabled-by');
scorm_toc_toggle_btn.setHTML('<')
.set('title', M.util.get_string('hide', 'moodle'));
.set('aria-expanded', true);
scorm_content.removeClass(cssclasses.scorm_grid_content_toc_hidden)
.addClass(cssclasses.scorm_grid_content_toc_visible);
}
@@ -309,14 +310,14 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
toc.removeClass(cssclasses.disabled)
.removeAttribute('disabled-by');
scorm_toc_toggle_btn.setHTML('<')
.set('title', M.util.get_string('hide', 'moodle'));
.set('aria-expanded', true);
scorm_content.removeClass(cssclasses.scorm_grid_content_toc_hidden)
.addClass(cssclasses.scorm_grid_content_toc_visible);
} else {
toc.addClass(cssclasses.disabled)
.setAttribute('disabled-by', 'user');
scorm_toc_toggle_btn.setHTML('>')
.set('title', M.util.get_string('show', 'moodle'));
.set('aria-expanded', false);
scorm_content.removeClass(cssclasses.scorm_grid_content_toc_visible)
.addClass(cssclasses.scorm_grid_content_toc_hidden);
}
@@ -633,7 +634,7 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
Y.one('#scorm_toc_toggle').addClass(cssclasses.scorm_grid_toggle);
Y.one('#scorm_toc_toggle_btn')
.setHTML('<')
.setAttribute('title', M.util.get_string('hide', 'moodle'));
.setAttribute('aria-expanded', true);
Y.one('#scorm_content').addClass(cssclasses.scorm_grid_content_toc_visible);
scorm_toggle_toc(true);
}
@@ -644,7 +645,7 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
Y.one('#scorm_toc').addClass(cssclasses.disabled);
Y.one('#scorm_toc_toggle_btn')
.setHTML('>')
.setAttribute('title', M.util.get_string('show', 'moodle'));
.setAttribute('aria-expanded', false);
Y.one('#scorm_content')
.removeClass(cssclasses.scorm_grid_content_toc_visible)
.addClass(cssclasses.scorm_grid_content_toc_hidden);
@@ -860,7 +861,6 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
// Collapse/expand TOC.
Y.one('#scorm_toc_toggle').on('click', scorm_toggle_toc);
Y.one('#scorm_toc_toggle').on('key', scorm_toggle_toc, 'down:enter,32');
// fix layout if window resized
Y.on("windowresize", function() {
scorm_resize_layout();
+21 -6
View File
@@ -106,12 +106,19 @@ $strexit = get_string('exitactivity', 'scorm');
$coursecontext = context_course::instance($course->id);
$scormname = format_string($scorm->name);
if ($mode === 'browse') {
$scormname = get_string('browsemodewithname', 'scorm', $scormname);
}
$titleparts = [
$scormname,
format_string($course->shortname, true, ['context' => $coursecontext]),
];
$PAGE->set_title(implode(moodle_page::TITLE_SEPARATOR, $titleparts));
if ($displaymode == 'popup') {
$PAGE->set_pagelayout('embedded');
} else {
$shortname = format_string($course->shortname, true, array('context' => $coursecontext));
$pagetitle = strip_tags("$shortname: ".format_string($scorm->name));
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
}
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', context_module::instance($cm->id))) {
@@ -221,7 +228,8 @@ echo html_writer::div(html_writer::tag('script', '', array('id' => 'external-sco
if ($scorm->hidetoc == SCORM_TOC_POPUP or $mode == 'browse' or $mode == 'review') {
echo html_writer::start_div('mb-3', array('id' => 'scormtop'));
if ($mode == 'browse' || $mode == 'review') {
echo html_writer::div(get_string("{$mode}mode", 'scorm'), 'scorm-left h3', ['id' => 'scormmode']);
$headinglevel = $PAGE->activityheader->get_heading_level();
echo $OUTPUT->heading(get_string("{$mode}mode", 'scorm'), $headinglevel, 'scorm-left', 'scormmode');
}
if ($scorm->hidetoc == SCORM_TOC_POPUP) {
echo html_writer::div($result->tocmenu, 'scorm-right', array('id' => 'scormnav'));
@@ -258,8 +266,15 @@ if ($result->prerequisites) {
js_writer::function_call('scorm_openpopup', Array($url->out(false),
$name, $scorm->options,
$scorm->width, $scorm->height)));
echo html_writer::tag('noscript', html_writer::tag('iframe', '', array('id' => 'main',
'class' => 'scoframe', 'name' => 'main', 'src' => 'loadSCO.php?id='.$cm->id.$scoidstr.$modestr)));
$frametitle = $result->toctitle ?? get_string('contents', 'scorm');
$iframe = html_writer::tag('iframe', '', [
'id' => 'main',
'class' => 'scoframe',
'name' => 'main',
'src' => 'loadSCO.php?id=' . $cm->id . $scoidstr . $modestr,
'title' => $frametitle,
]);
echo html_writer::tag('noscript', $iframe);
}
} else {
echo $OUTPUT->box(get_string('noprerequisites', 'scorm'));
-5
View File
@@ -164,11 +164,6 @@
padding: 0;
}
#page-mod-scorm-player #scormmode {
float: left;
border: 0;
}
#page-mod-scorm-player.pagelayout-popup #page-content .region-content {
padding: 0;
}
@@ -29,20 +29,20 @@ Feature: Scorm display options
When I press "Preview"
# Confirm TOC display
# Used css_element to check > and < button display in TOC since similar buttons also exist in navigation
Then I <tocdisplay> see "Golf Explained - Minimum Run-time Calls"
And "[title='Show']" "css_element" <showdisplay> exist
And "[title='Hide']" "css_element" <hidedisplay> exist
Then I <tocdisplay> see "Golf Explained - Minimum Run-time Calls" in the "#scorm_toc" "css_element"
And "Toggle table of contents" "button" <toggletoc> be visible
# Confirm TOC dropdown display
And "scoid" "select" <tocdropdown> exist
# Confirm the navigation display
And "[id='scorm_nav']" "css_element" <navbar> exist
Examples:
| toc | shownavigation | tocdisplay | showdisplay | hidedisplay | tocdropdown | navbar |
| 1 | | should not | should | should not | should not | should not |
| 2 | 1 | should | should | should not | should | should not |
| 0 | 0 | should | should not | should | should not | should not |
| 0 | 1 | should | should not | should | should not | should |
| toc | shownavigation | tocdisplay | toggletoc | tocdropdown | navbar |
| 1 | | should not | should | should not | should not |
| 2 | 1 | should not | should | should | should not |
| 0 | 0 | should | should | should not | should not |
| 0 | 1 | should | should | should not | should |
| 3 | 0 | should not | should not | should not | should not |
Scenario: Student can exit Scorm activity in single activity course format
Given the following "activities" exist: