mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'MDL-66554-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
f37035cb04
@ -859,7 +859,9 @@ class mod_scorm_external extends external_api {
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function launch_sco($scormid, $scoid = 0) {
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
|
||||
$params = self::validate_parameters(self::launch_sco_parameters(),
|
||||
array(
|
||||
@ -882,6 +884,10 @@ class mod_scorm_external extends external_api {
|
||||
throw new moodle_exception('cannotfindsco', 'scorm');
|
||||
}
|
||||
|
||||
// Mark module viewed.
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
list($sco, $scolaunchurl) = scorm_get_sco_and_launch_url($scorm, $params['scoid'], $context);
|
||||
// Trigger the SCO launched event.
|
||||
scorm_launch_sco($scorm, $sco, $cm, $context, $scolaunchurl);
|
||||
|
@ -46,13 +46,15 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase {
|
||||
* Set up for every test
|
||||
*/
|
||||
public function setUp() {
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$CFG->enablecompletion = 1;
|
||||
// Setup test data.
|
||||
$this->course = $this->getDataGenerator()->create_course();
|
||||
$this->scorm = $this->getDataGenerator()->create_module('scorm', array('course' => $this->course->id));
|
||||
$this->course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$this->scorm = $this->getDataGenerator()->create_module('scorm', array('course' => $this->course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$this->context = context_module::instance($this->scorm->cmid);
|
||||
$this->cm = get_coursemodule_from_instance('scorm', $this->scorm->id);
|
||||
|
||||
@ -849,8 +851,8 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external_api::clean_returnvalue(mod_scorm_external::launch_sco_returns(), $result);
|
||||
|
||||
$events = $sink->get_events();
|
||||
$this->assertCount(1, $events);
|
||||
$event = array_shift($events);
|
||||
$this->assertCount(3, $events);
|
||||
$event = array_pop($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_scorm\event\sco_launched', $event);
|
||||
@ -860,6 +862,14 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
$event = array_shift($events);
|
||||
$this->assertInstanceOf('\core\event\course_module_completion_updated', $event);
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($this->course);
|
||||
$completiondata = $completion->get_data($this->cm);
|
||||
$this->assertEquals(COMPLETION_VIEWED, $completiondata->completionstate);
|
||||
|
||||
// Invalid SCO.
|
||||
try {
|
||||
mod_scorm_external::launch_sco($this->scorm->id, -1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user