first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,56 @@
@mod @mod_label @core_completion
Feature: View activity completion information for the label
In order to have visibility of Label completion requirements
As a student
I need to be able to view my Label completion progress
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Vinnie | Student1 | student1@example.com |
| teacher1 | Darrell | Teacher1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
And the following "activity" exists:
| activity | label |
| course | C1 |
| idnumber | mh1 |
| section | 1 |
| completion | 1 |
@javascript
Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to No
Given I am on the "Course 1" course page logged in as teacher1
# Teacher view.
And "Test label 1" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"
And I am on "Course 1" course homepage
Then the manual completion button for "Test label 1" should exist
And the manual completion button of "Test label 1" is displayed as "Mark as done"
And I toggle the manual completion state of "Test label 1"
And the manual completion button of "Test label 1" is displayed as "Done"
@javascript
Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to Yes
Given I am on the "Course 1" course page logged in as teacher1
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the field "Show activity completion conditions" to "Yes"
And I press "Save and display"
# Teacher view.
And "Test label 1" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"
And I am on "Course 1" course homepage
Then the manual completion button for "Test label 1" should exist
And the manual completion button of "Test label 1" is displayed as "Mark as done"
And I toggle the manual completion state of "Test label 1"
And the manual completion button of "Test label 1" is displayed as "Done"
@@ -0,0 +1,36 @@
@mod @mod_label
Feature: set label idnumber
In order to set label idnumber
As a teacher
I should create label activity and set an ID number
Scenario: label ID number input box should be shown.
Given the following "courses" exist:
| fullname | shortname | category |
| Test | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher | Teacher | First | teacher1@example.com |
| student | Student | First | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
| student | C1 | student |
And the following "activities" exist:
| activity | course | section | intro | idnumber |
| label | C1 | 1 | Label with ID number set | C1LABEL1 |
When I log in as "teacher"
And I am on "Test" course homepage with editing mode on
Then "Label with ID number set" activity should be visible
And I turn editing mode off
And "Label with ID number set" activity should be visible
And I log out
And I log in as "student"
And I am on "Test" course homepage
And I should see "Label with ID number set"
And I log out
And I am on the "Label with ID number set" "label activity editing" page logged in as teacher
And I expand all fieldsets
And I should see "ID number" in the "Common module settings" "fieldset"
And the field "ID number" matches value "C1LABEL1"
+30
View File
@@ -0,0 +1,30 @@
@mod @mod_label
Feature: Set label name
As a teacher
I should be able to create a label activity and set a name
Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Test | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher | Teacher | First | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And the following "activities" exist:
| activity | course | section | intro | idnumber |
| label | C1 | 1 | Intro Text | C1LABEL1 |
Scenario: label name input box should be shown and can be set
When I log in as "teacher"
And I am on "Test" course homepage
And "Intro Text" activity should be visible
And I am on the "Intro Text" "label activity editing" page logged in as teacher
And I should see "Title in course index" in the "General" "fieldset"
And I set the field "Title in course index" to "Test Label 1"
And I press "Save and return to course"
And I am on "Test" course homepage
Then "Test Label 1" activity should be visible
@@ -0,0 +1,64 @@
@mod @mod_label
Feature: Check label visibility works
In order to check label visibility works
As a teacher
I should create label activity
Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Test | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher | Teacher | First | teacher1@example.com |
| student | Student | First | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
| student | C1 | student |
And the following "activities" exist:
| activity | course | section | intro | idnumber | visible |
| label | C1 | 1 | Swanky label | 1 | 1 |
| label | C1 | 1 | Swanky label 2 | 2 | 0 |
Scenario: Hidden label activity should be show as hidden.
Given I log in as "teacher"
When I am on "Test" course homepage with editing mode on
Then "Swanky label 2" label should be hidden
And I turn editing mode off
And "Swanky label 2" label should be hidden
And I log out
And I log in as "student"
And I am on "Test" course homepage
And I should not see "Swanky label 2"
And I log out
Scenario: Visible label activity should be shown as visible.
Given I log in as "teacher"
When I am on "Test" course homepage with editing mode on
Then "Swanky label" activity should be visible
And I log out
And I log in as "student"
And I am on "Test" course homepage
And "Swanky label" activity should be visible
And I log out
@javascript
Scenario: Teacher can not show label inside the hidden section
Given I log in as "teacher"
And I am on "Test" course homepage with editing mode on
When I hide section "1"
Then "Swanky label" label should be hidden
And I open "Swanky label" actions menu
And "Swanky label" actions menu should not have "Availability" item
And I click on "Edit settings" "link" in the "Swanky label" activity
And I expand all fieldsets
And the "Availability" select box should contain "Hide on course page"
And the "Availability" select box should not contain "Make available but don't show on course page"
And the "Availability" select box should not contain "Show on course page"
And I log out
And I log in as "student"
And I am on "Test" course homepage
And I should not see "Swanky label"
And I log out
+158
View File
@@ -0,0 +1,158 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_label;
use core_external\external_api;
use externallib_advanced_testcase;
use mod_label_external;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
/**
* External mod_label functions unit tests
*
* @package mod_label
* @category external
* @copyright 2017 Juan Leyva <juan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 3.3
*/
class externallib_test extends externallib_advanced_testcase {
/**
* Test test_mod_label_get_labels_by_courses
*/
public function test_mod_label_get_labels_by_courses(): void {
global $DB;
$this->resetAfterTest(true);
$course1 = self::getDataGenerator()->create_course();
$course2 = self::getDataGenerator()->create_course();
$student = self::getDataGenerator()->create_user();
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->getDataGenerator()->enrol_user($student->id, $course1->id, $studentrole->id);
// First label.
$record = new \stdClass();
$record->course = $course1->id;
$label1 = self::getDataGenerator()->create_module('label', $record);
// Second label.
$record = new \stdClass();
$record->course = $course2->id;
$label2 = self::getDataGenerator()->create_module('label', $record);
// Execute real Moodle enrolment as we'll call unenrol() method on the instance later.
$enrol = enrol_get_plugin('manual');
$enrolinstances = enrol_get_instances($course2->id, true);
foreach ($enrolinstances as $courseenrolinstance) {
if ($courseenrolinstance->enrol == "manual") {
$instance2 = $courseenrolinstance;
break;
}
}
$enrol->enrol_user($instance2, $student->id, $studentrole->id);
self::setUser($student);
$returndescription = mod_label_external::get_labels_by_courses_returns();
// Create what we expect to be returned when querying the two courses.
$expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles', 'timemodified',
'section', 'visible', 'groupmode', 'groupingid', 'lang');
// Add expected coursemodule and data.
$label1->coursemodule = $label1->cmid;
$label1->introformat = 1;
$label1->section = 0;
$label1->visible = true;
$label1->groupmode = 0;
$label1->groupingid = 0;
$label1->introfiles = [];
$label1->lang = '';
$label2->coursemodule = $label2->cmid;
$label2->introformat = 1;
$label2->section = 0;
$label2->visible = true;
$label2->groupmode = 0;
$label2->groupingid = 0;
$label2->introfiles = [];
$label2->lang = '';
foreach ($expectedfields as $field) {
$expected1[$field] = $label1->{$field};
$expected2[$field] = $label2->{$field};
}
$expectedlabels = array($expected2, $expected1);
// Call the external function passing course ids.
$result = mod_label_external::get_labels_by_courses(array($course2->id, $course1->id));
$result = external_api::clean_returnvalue($returndescription, $result);
$this->assertEquals($expectedlabels, $result['labels']);
$this->assertCount(0, $result['warnings']);
// Call the external function without passing course id.
$result = mod_label_external::get_labels_by_courses();
$result = external_api::clean_returnvalue($returndescription, $result);
$this->assertEquals($expectedlabels, $result['labels']);
$this->assertCount(0, $result['warnings']);
// Add a file to the intro.
$filename = "file.txt";
$filerecordinline = array(
'contextid' => \context_module::instance($label2->cmid)->id,
'component' => 'mod_label',
'filearea' => 'intro',
'itemid' => 0,
'filepath' => '/',
'filename' => $filename,
);
$fs = get_file_storage();
$timepost = time();
$fs->create_file_from_string($filerecordinline, 'image contents (not really)');
$result = mod_label_external::get_labels_by_courses(array($course2->id, $course1->id));
$result = external_api::clean_returnvalue($returndescription, $result);
$this->assertCount(1, $result['labels'][0]['introfiles']);
$this->assertEquals($filename, $result['labels'][0]['introfiles'][0]['filename']);
// Unenrol user from second course.
$enrol->unenrol_user($instance2, $student->id);
array_shift($expectedlabels);
// Call the external function without passing course id.
$result = mod_label_external::get_labels_by_courses();
$result = external_api::clean_returnvalue($returndescription, $result);
$this->assertEquals($expectedlabels, $result['labels']);
// Call for the second course we unenrolled the user from, expected warning.
$result = mod_label_external::get_labels_by_courses(array($course2->id));
$this->assertCount(1, $result['warnings']);
$this->assertEquals('1', $result['warnings'][0]['warningcode']);
$this->assertEquals($course2->id, $result['warnings'][0]['itemid']);
}
}
+44
View File
@@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_label data generator
*
* @package mod_label
* @category test
* @copyright 2013 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Label module data generator class
*
* @package mod_label
* @category test
* @copyright 2013 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_label_generator extends testing_module_generator {
public function create_instance($record = null, array $options = null) {
$record = (array)$record;
$record['showdescription'] = 1;
return parent::create_instance($record, $options);
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_label;
/**
* PHPUnit label generator testcase
*
* @package mod_label
* @category phpunit
* @copyright 2013 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class generator_test extends \advanced_testcase {
public function test_generator(): void {
global $DB;
$this->resetAfterTest(true);
$this->assertEquals(0, $DB->count_records('label'));
$course = $this->getDataGenerator()->create_course();
/** @var mod_label_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('mod_label');
$this->assertInstanceOf('mod_label_generator', $generator);
$this->assertEquals('label', $generator->get_modulename());
$generator->create_instance(array('course'=>$course->id));
$generator->create_instance(array('course'=>$course->id));
$label = $generator->create_instance(array('course'=>$course->id));
$this->assertEquals(3, $DB->count_records('label'));
$cm = get_coursemodule_from_instance('label', $label->id);
$this->assertEquals($label->id, $cm->instance);
$this->assertEquals('label', $cm->modname);
$this->assertEquals($course->id, $cm->course);
$context = \context_module::instance($cm->id);
$this->assertEquals($label->cmid, $context->instanceid);
}
}
+364
View File
@@ -0,0 +1,364 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_label;
/**
* Unit tests for the activity label's lib.
*
* @package mod_label
* @category test
* @copyright 2017 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class lib_test extends \advanced_testcase {
/**
* Set up.
*/
public function setUp(): void {
$this->resetAfterTest();
$this->setAdminUser();
}
public function test_label_core_calendar_provide_event_action(): void {
// Create the activity.
$course = $this->getDataGenerator()->create_course();
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
// Create a calendar event.
$event = $this->create_action_event($course->id, $label->id,
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Decorate action event.
$actionevent = mod_label_core_calendar_provide_event_action($event, $factory);
// Confirm the event was decorated.
$this->assertInstanceOf('\core_calendar\local\event\value_objects\action', $actionevent);
$this->assertEquals(get_string('view'), $actionevent->get_name());
$this->assertInstanceOf('moodle_url', $actionevent->get_url());
$this->assertEquals(1, $actionevent->get_item_count());
$this->assertTrue($actionevent->is_actionable());
}
public function test_label_core_calendar_provide_event_action_as_non_user(): void {
global $CFG;
// Create the activity.
$course = $this->getDataGenerator()->create_course();
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
// Create a calendar event.
$event = $this->create_action_event($course->id, $label->id,
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Now log out.
$CFG->forcelogin = true; // We don't want to be logged in as guest, as guest users might still have some capabilities.
$this->setUser();
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Decorate action event.
$actionevent = mod_label_core_calendar_provide_event_action($event, $factory);
// Confirm the event is not shown at all.
$this->assertNull($actionevent);
}
public function test_label_core_calendar_provide_event_action_in_hidden_section(): void {
// Create the activity.
$course = $this->getDataGenerator()->create_course();
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
// Create a student.
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
// Create a calendar event.
$event = $this->create_action_event($course->id, $label->id,
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Set sections 0 as hidden.
set_section_visible($course->id, 0, 0);
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Decorate action event for the student.
$actionevent = mod_label_core_calendar_provide_event_action($event, $factory, $student->id);
// Confirm the event is not shown at all.
$this->assertNull($actionevent);
}
public function test_label_core_calendar_provide_event_action_for_user(): void {
global $CFG;
// Create the activity.
$course = $this->getDataGenerator()->create_course();
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
// Enrol a student in the course.
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
// Create a calendar event.
$event = $this->create_action_event($course->id, $label->id,
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Now, log out.
$CFG->forcelogin = true; // We don't want to be logged in as guest, as guest users might still have some capabilities.
$this->setUser();
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Decorate action event for the student.
$actionevent = mod_label_core_calendar_provide_event_action($event, $factory, $student->id);
// Confirm the event was decorated.
$this->assertInstanceOf('\core_calendar\local\event\value_objects\action', $actionevent);
$this->assertEquals(get_string('view'), $actionevent->get_name());
$this->assertInstanceOf('moodle_url', $actionevent->get_url());
$this->assertEquals(1, $actionevent->get_item_count());
$this->assertTrue($actionevent->is_actionable());
}
public function test_label_core_calendar_provide_event_action_already_completed(): void {
global $CFG;
$CFG->enablecompletion = 1;
// Create the activity.
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id),
array('completion' => 2, 'completionview' => 1, 'completionexpected' => time() + DAYSECS));
// Get some additional data.
$cm = get_coursemodule_from_instance('label', $label->id);
// Create a calendar event.
$event = $this->create_action_event($course->id, $label->id,
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Mark the activity as completed.
$completion = new \completion_info($course);
$completion->set_module_viewed($cm);
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Decorate action event.
$actionevent = mod_label_core_calendar_provide_event_action($event, $factory);
// Ensure result was null.
$this->assertNull($actionevent);
}
public function test_label_core_calendar_provide_event_action_already_completed_for_user(): void {
global $CFG;
$CFG->enablecompletion = 1;
// Create the activity.
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id),
array('completion' => 2, 'completionview' => 1, 'completionexpected' => time() + DAYSECS));
// Enrol a student in the course.
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
// Get some additional data.
$cm = get_coursemodule_from_instance('label', $label->id);
// Create a calendar event.
$event = $this->create_action_event($course->id, $label->id,
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Mark the activity as completed for the student.
$completion = new \completion_info($course);
$completion->set_module_viewed($cm, $student->id);
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Decorate action event for the student.
$actionevent = mod_label_core_calendar_provide_event_action($event, $factory, $student->id);
// Ensure result was null.
$this->assertNull($actionevent);
}
/**
* Check label name with different content inserted in the label intro.
*
* @param string $name
* @param string $content
* @param string $format
* @param string $expectedname
* @return void
* @covers \get_label_name
* @dataProvider label_get_name_data_provider
*/
public function test_label_get_label_name(string $name, string $content, string $format, string $expectedname): void {
$course = $this->getDataGenerator()->create_course();
// When creating the module, get_label_name is called and fills label->name.
$label = $this->getDataGenerator()->create_module('label', [
'name' => $name,
'course' => $course->id,
'intro' => $content,
'introformat' => $format
]
);
$this->assertEquals($expectedname, $label->name);
}
/**
* Dataprovider for test_label_get_label_name
*
* @return array
*/
public function label_get_name_data_provider(): array {
return [
'withlabelname' => [
'name' => 'Test label 1',
'content' => '<p>Simple textual content<p>',
'format' => FORMAT_HTML,
'expected' => 'Test label 1'
],
'simple' => [
'name' => '',
'content' => '<p>Simple textual content<p>',
'format' => FORMAT_HTML,
'expected' => 'Simple textual content'
],
'empty' => [
'name' => '',
'content' => '',
'format' => FORMAT_HTML,
'expected' => 'Test label 1'
],
'withaudiocontent' => [
'name' => '',
'content' => '<p>Test with audio</p>
<p>&nbsp; &nbsp;<audio controls="controls">
<source src="@@PLUGINFILE@@/moodle-hit-song.mp3">
@@PLUGINFILE@@/moodle-hit-song.mp3
</audio>&nbsp;</p>',
'format' => FORMAT_HTML,
'expected' => 'Test with audio'
],
'withvideo' => [
'name' => '',
'content' => '<p>Test video</p>
<p>&nbsp;<video controls="controls">
<source src="https://www.youtube.com/watch?v=xxxyy">
https://www.youtube.com/watch?v=xxxyy
</video>&nbsp;</p>',
'format' => FORMAT_HTML,
'expected' => 'Test video https://www.youtube.com/watch?v=xxxyy'
],
'with video trimming' => [
'name' => '',
'content' => '<p>Test with video to be trimmed</p>
<p>&nbsp;<video controls="controls">
<source src="https://www.youtube.com/watch?v=xxxyy">
https://www.youtube.com/watch?v=xxxyy
</video>&nbsp;</p>',
'format' => FORMAT_HTML,
'expected' => 'Test with video to be trimmed https://www.youtube....'
],
'with plain text' => [
'name' => '',
'content' => 'Content with @@PLUGINFILE@@/moodle-hit-song.mp3 nothing',
'format' => FORMAT_HTML,
'expected' => 'Content with nothing'
],
'with several spaces' => [
'name' => '',
'content' => "Content with @@PLUGINFILE@@/moodle-hit-song.mp3 \r &nbsp; several spaces",
'format' => FORMAT_HTML,
'expected' => 'Content with several spaces'
],
'empty spaces' => [
'name' => '',
'content' => ' &nbsp; ',
'format' => FORMAT_HTML,
'expected' => 'Text and media area'
],
'only html' => [
'name' => '',
'content' => '<audio controls="controls"><source src=""></audio>',
'format' => FORMAT_HTML,
'expected' => 'Text and media area'
],
'markdown' => [
'name' => '',
'content' => "##Simple Title\n simple markdown format",
'format' => FORMAT_MARKDOWN,
'expected' => 'Simple Title simple markdown format'
],
'markdown with pluginfile' => [
'name' => '',
'content' => "##Simple Title\n simple markdown format @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_MARKDOWN,
'expected' => 'Simple Title simple markdown format'
],
'plain text' => [
'name' => '',
'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_PLAIN,
'expected' => 'Simple plain text'
],
'moodle format text' => [
'name' => '',
'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_MOODLE,
'expected' => 'Simple plain text'
],
'html format text' => [
'name' => '',
'content' => "<h1>Simple plain title</h1><p> with plain text</p> @@PLUGINFILE@@/moodle-hit-song.mp3",
'format' => FORMAT_HTML,
'expected' => 'Simple plain title with plain text'
],
];
}
/**
* Creates an action event.
*
* @param int $courseid The course id.
* @param int $instanceid The instance id.
* @param string $eventtype The event type.
* @return bool|calendar_event
*/
private function create_action_event($courseid, $instanceid, $eventtype) {
$event = new \stdClass();
$event->name = 'Calendar event';
$event->modulename = 'label';
$event->courseid = $courseid;
$event->instance = $instanceid;
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->eventtype = $eventtype;
$event->timestart = time();
return \calendar_event::create($event);
}
}