Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'm32_MDL-46782' of git://github.com/danmarsden/moodle in…
Browse files Browse the repository at this point in the history
…to MOODLE_32_STABLE
  • Loading branch information
danpoltawski committed Jan 23, 2017
2 parents 98f246a + dbf70de commit 92f57f8
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 14 deletions.
31 changes: 23 additions & 8 deletions mod/scorm/locallib.php
Expand Up @@ -888,7 +888,7 @@ function scorm_get_all_attempts($scormid, $userid) {
* @param stdClass $cm course module object
*/
function scorm_print_launch ($user, $scorm, $action, $cm) {
global $CFG, $DB, $PAGE, $OUTPUT, $COURSE;
global $CFG, $DB, $OUTPUT;

if ($scorm->updatefreq == SCORM_UPDATE_EVERYTIME) {
scorm_parse($scorm, false);
Expand Down Expand Up @@ -931,6 +931,13 @@ function scorm_print_launch ($user, $scorm, $action, $cm) {

$result = scorm_get_toc($user, $scorm, $cm->id, TOCFULLURL, $orgidentifier);
$incomplete = $result->incomplete;
// Get latest incomplete sco to launch first.
if (!empty($result->sco->id)) {
$launchsco = $result->sco->id;
} else {
// Use launch defined by SCORM package.
$launchsco = $scorm->launch;
}

// Do we want the TOC to be displayed?
if ($scorm->displaycoursestructure == 1) {
Expand Down Expand Up @@ -976,7 +983,7 @@ function scorm_print_launch ($user, $scorm, $action, $cm) {
}

echo html_writer::empty_tag('br');
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scoid', 'value' => $scorm->launch));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scoid', 'value' => $launchsco));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cm', 'value' => $cm->id));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentorg', 'value' => $orgidentifier));
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('enter', 'scorm'),
Expand Down Expand Up @@ -1013,12 +1020,19 @@ function scorm_simple_play($scorm, $user, $context, $cmid) {
}
if ($scorm->skipview >= SCORM_SKIPVIEW_FIRST) {
$sco = current($scoes);
$url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id,
'currentorg' => $orgidentifier,
'scoid' => $sco->id));
$result = scorm_get_toc($user, $scorm, $cmid, TOCFULLURL, $orgidentifier);
$url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id, 'currentorg' => $orgidentifier));

// Set last incomplete sco to launch first.
if (!empty($result->sco->id)) {
$url->param('scoid', $result->sco->id);
} else {
$url->param('scoid', $sco->id);
}

if ($scorm->skipview == SCORM_SKIPVIEW_ALWAYS || !scorm_has_tracks($scorm->id, $user->id)) {
if (!empty($scorm->forcenewattempt)) {
$result = scorm_get_toc($user, $scorm, $cmid, TOCFULLURL, $orgidentifier);

if ($result->incomplete === false) {
$url->param('newattempt', 'on');
}
Expand Down Expand Up @@ -1522,6 +1536,7 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n

if ($sco->isvisible === 'true') {
if (!empty($sco->launch)) {
// Set first sco to launch if in browse/review mode.
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
}
Expand All @@ -1542,7 +1557,7 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
($usertrack->status == 'incomplete') ||
($usertrack->status == 'browsed')) {
$incomplete = true;
if ($play && empty($scoid)) {
if (empty($scoid)) {
$scoid = $sco->id;
}
}
Expand All @@ -1561,7 +1576,7 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
}

} else {
if ($play && empty($scoid)) {
if (empty($scoid)) {
$scoid = $sco->id;
}

Expand Down
57 changes: 57 additions & 0 deletions mod/scorm/tests/behat/multisco_reentry.feature
@@ -0,0 +1,57 @@
@mod @mod_scorm @_file_upload @_switch_iframe
Feature: Scorm multi-sco review mode.
In order to let students access a scorm package
As a teacher
I need to add scorm activity to a course
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |

@javascript
Scenario: Test re-entry and make sure next uncompleted SCO is shown on second entry.
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| Enable completion tracking | Yes |
And I press "Save and display"
And I add a "SCORM package" to section "1"
And I set the following fields to these values:
| Name | Multi-sco SCORM package |
| Description | Description |
| Completion tracking | Show activity as complete when conditions are met |
| Require all scos to return completion status | 1 |
And I set the field "Completed" to "1"
And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12.zip" file to "Package file" filemanager
And I click on "Save and display" "button"
And I should see "Multi-sco SCORM package"
And I log out
And I log in as "student1"
And I follow "Course 1"
And I follow "Multi-sco SCORM package"
And I should see "Normal"
And I press "Enter"
And I switch to "scorm_object" iframe
And I should see "Play of the game"
And I switch to the main frame
And I click on "Par?" "list_item"
And I switch to "scorm_object" iframe
And I should see "Par"
And I switch to the main frame
And I follow "Exit activity"
And I wait until the page is ready
And I follow "Multi-sco SCORM package"
And I should see "Normal"
And I press "Enter"
And I switch to "scorm_object" iframe
Then I should see "Scoring"
19 changes: 13 additions & 6 deletions mod/scorm/view.php
Expand Up @@ -70,13 +70,20 @@

$scoid = 0;
$orgidentifier = '';
if ($sco = scorm_get_sco($scorm->launch, SCO_ONLY)) {
if (($sco->organization == '') && ($sco->launch == '')) {
$orgidentifier = $sco->identifier;
} else {
$orgidentifier = $sco->organization;

$result = scorm_get_toc($USER, $scorm, $cm->id, TOCFULLURL);
// Set last incomplete sco to launch first.
if (!empty($result->sco->id)) {
$scoid = $result->sco->id;
} else {
if ($sco = scorm_get_sco($scorm->launch, SCO_ONLY)) {
if (($sco->organization == '') && ($sco->launch == '')) {
$orgidentifier = $sco->identifier;
} else {
$orgidentifier = $sco->organization;
}
$scoid = $sco->id;
}
$scoid = $sco->id;
}

if (empty($preventskip) && $scorm->skipview >= SCORM_SKIPVIEW_FIRST &&
Expand Down

0 comments on commit 92f57f8

Please sign in to comment.