Merge branch 'master_MDL-52168' of git://github.com/danmarsden/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 2 Jan 2017 12:20:34 +0000 (12:20 +0000)
committerDan Poltawski <dan@moodle.com>
Mon, 2 Jan 2017 12:20:34 +0000 (12:20 +0000)
mod/scorm/datamodels/scorm_12.js
mod/scorm/tests/behat/missing_org.feature [new file with mode: 0644]
mod/scorm/tests/packages/readme_moodle.txt
mod/scorm/tests/packages/singlescobasic_missingorg.zip [new file with mode: 0644]

index 6a34db8..2adb083 100644 (file)
@@ -169,7 +169,7 @@ function SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebu
     var Initialized = false;
 
     function LMSInitialize (param) {
-        scoid = scorm_current_node ? scorm_current_node.scoid : scoid;
+        scoid = (scorm_current_node && scorm_current_node.scoid) ?  scorm_current_node.scoid : scoid;
         initdatamodel(scoid);
 
         errorCode = "0";
diff --git a/mod/scorm/tests/behat/missing_org.feature b/mod/scorm/tests/behat/missing_org.feature
new file mode 100644 (file)
index 0000000..a9024d7
--- /dev/null
@@ -0,0 +1,36 @@
+@mod @mod_scorm @_file_upload @_switch_iframe
+Feature: Check a SCORM package with missing Organisational structure.
+
+  @javascript
+  Scenario: Add a scorm activity to a course
+    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 |
+    When I log in as "teacher1"
+    And I follow "Course 1"
+    And I turn editing mode on
+    And I add a "SCORM package" to section "1"
+    And I set the following fields to these values:
+      | Name | MissingOrg SCORM package |
+      | Description | Description |
+    And I upload "mod/scorm/tests/packages/singlescobasic_missingorg.zip" file to "Package file" filemanager
+    And I click on "Save and display" "button"
+    Then I should see "MissingOrg SCORM package"
+    And I should see "Normal"
+    And I should see "Preview"
+    And I log out
+    And I log in as "student1"
+    And I follow "Course 1"
+    And I follow "MissingOrg 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"
index 0d0c003..6c69131 100644 (file)
@@ -17,4 +17,5 @@ Other test packages
 * invalid.zip - zip file with an single html file, no SCORM config files, used for validation check.
 * validscorm.zip - non functional package with an imsmanifest.xml, used for validation check.
 * validaicc.zip - non functional package with AICC config files, used for validation check.
-* complexscorm.zip - copied from: https://github.com/jleyva/scorm-debugger
+* complexscorm.zip - copied from: https://github.com/jleyva/scorm-debugger.
+* singlescobasic_missingorg.zip - copy of scorm.com package but with missing org definition.
diff --git a/mod/scorm/tests/packages/singlescobasic_missingorg.zip b/mod/scorm/tests/packages/singlescobasic_missingorg.zip
new file mode 100644 (file)
index 0000000..deaeb30
Binary files /dev/null and b/mod/scorm/tests/packages/singlescobasic_missingorg.zip differ