Skip to content

Commit

Permalink
Merge branch 'MDL-68918-master' of git://github.com/ferranrecio/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 8, 2020
2 parents 346c516 + 2bdd6b1 commit 99de0bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ protected static function define_other_properties() {
'coursemodule' => [
'type' => PARAM_INT
],
'context' => [
'type' => PARAM_INT
],
'introfiles' => [
'type' => external_files::get_properties_for_exporter(),
'multiple' => true
Expand Down Expand Up @@ -197,6 +200,7 @@ protected function get_other_values(renderer_base $output) {

$values = [
'coursemodule' => $context->instanceid,
'context' => $context->id,
];

$values['introfiles'] = external_util::get_area_files($context->id, 'mod_h5pactivity', 'intro', false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,21 @@ public function test_get_h5pactivities_by_courses() {
'introformat' => 1
];
$activities[] = $this->getDataGenerator()->create_module('h5pactivity', $params);
// Add filename to make easier the asserts.
// Add filename and contextid to make easier the asserts.
$activities[0]->filename = 'filltheblanks.h5p';
$context = context_module::instance($activities[0]->cmid);
$activities[0]->contextid = $context->id;

$params = [
'course' => $course1->id,
'packagefilepath' => $CFG->dirroot.'/h5p/tests/fixtures/greeting-card-887.h5p',
'introformat' => 1
];
$activities[] = $this->getDataGenerator()->create_module('h5pactivity', $params);
// Add filename to make easier the asserts.
// Add filename and contextid to make easier the asserts.
$activities[1]->filename = 'greeting-card-887.h5p';
$context = context_module::instance($activities[1]->cmid);
$activities[1]->contextid = $context->id;

$course2 = $this->getDataGenerator()->create_course();
$params = [
Expand All @@ -84,8 +89,9 @@ public function test_get_h5pactivities_by_courses() {
];
$activities[] = $this->getDataGenerator()->create_module('h5pactivity', $params);
$activities[2]->filename = 'guess-the-answer.h5p';

$context = context_module::instance($activities[2]->cmid);
$activities[2]->contextid = $context->id;

// Create a fake deploy H5P file.
$generator = $this->getDataGenerator()->get_plugin_generator('core_h5p');
$deployedfile = $generator->create_export_file($activities[2]->filename, $context->id, 'mod_h5pactivity', 'package');
Expand Down Expand Up @@ -176,6 +182,7 @@ protected function assert_activities(array $activities, array $result): void {
$this->assertEquals($activities[$i]->enabletracking, $result['h5pactivities'][$i]['enabletracking']);
$this->assertEquals($activities[$i]->grademethod, $result['h5pactivities'][$i]['grademethod']);
$this->assertEquals($activities[$i]->cmid, $result['h5pactivities'][$i]['coursemodule']);
$this->assertEquals($activities[$i]->contextid, $result['h5pactivities'][$i]['context']);
$this->assertEquals($activities[$i]->filename, $result['h5pactivities'][$i]['package'][0]['filename']);
}
}
Expand Down

0 comments on commit 99de0bb

Please sign in to comment.