diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index c1855d0a856..d0bb5f27593 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1852,6 +1852,7 @@ class core_plugin_manager { 'datapreset' => array( 'imagegallery', 'proposals', + 'resources', ), 'fileconverter' => array( diff --git a/mod/data/preset/resources/addtemplate.html b/mod/data/preset/resources/addtemplate.html new file mode 100644 index 00000000000..5001c09c585 --- /dev/null +++ b/mod/data/preset/resources/addtemplate.html @@ -0,0 +1,26 @@ +
+
+
+ [[Title]] +
+
+
+ [[Author]] +
+
+
+ [[Cover]] +
+
+
+ [[Description]] +
+
+
+ [[Web link]] +
+
+
+ [[Type]] +
+
diff --git a/mod/data/preset/resources/asearchtemplate.html b/mod/data/preset/resources/asearchtemplate.html new file mode 100644 index 00000000000..ca94269af91 --- /dev/null +++ b/mod/data/preset/resources/asearchtemplate.html @@ -0,0 +1,24 @@ +
+
+
+
+ [[Title]] +
+
+
+ [[Author]] +
+
+
+ [[Description]] +
+
+
+ [[Web link]] +
+
+
+ [[Type]] +
+
+
diff --git a/mod/data/preset/resources/classes/privacy/provider.php b/mod/data/preset/resources/classes/privacy/provider.php new file mode 100644 index 00000000000..2fa45123091 --- /dev/null +++ b/mod/data/preset/resources/classes/privacy/provider.php @@ -0,0 +1,37 @@ +. + +namespace datapreset_resources\privacy; + +/** + * Privacy provider implementation for datapreset_resources. + * + * @package datapreset_resources + * @copyright 2022 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class provider implements \core_privacy\local\metadata\null_provider { + + /** + * Get the language string identifier with the component's language + * file to explain why this plugin stores no data. + * + * @return string + */ + public static function get_reason() : string { + return 'privacy:metadata'; + } +} diff --git a/mod/data/preset/resources/csstemplate.css b/mod/data/preset/resources/csstemplate.css new file mode 100644 index 00000000000..1a057ce07c1 --- /dev/null +++ b/mod/data/preset/resources/csstemplate.css @@ -0,0 +1,14 @@ +/****** Single View CSS ******/ + +.resources-single .img-wrapper img { + flex-shrink: 0; + width: 200px; +} + +/***** Add entry CSS *****/ + +.resources-addentry .form-group label, +.resources-asearch .form-group label { + font-weight: bold; + padding-top: 20px; +} diff --git a/mod/data/preset/resources/jstemplate.js b/mod/data/preset/resources/jstemplate.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mod/data/preset/resources/lang/en/datapreset_resources.php b/mod/data/preset/resources/lang/en/datapreset_resources.php new file mode 100644 index 00000000000..7b081d70c98 --- /dev/null +++ b/mod/data/preset/resources/lang/en/datapreset_resources.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for component 'datapreset_resources', language 'en'. + * + * @package datapreset_resources + * @copyright 2022 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['modulename'] = 'Resources'; +$string['modulename_help'] = 'Collect resources such as web links or book reviews in a table, with links to the detailed view.'; +$string['pluginname'] = 'Resources'; +$string['privacy:metadata'] = 'The Resources plugin does not store any personal data.'; diff --git a/mod/data/preset/resources/listtemplate.html b/mod/data/preset/resources/listtemplate.html new file mode 100644 index 00000000000..77580173393 --- /dev/null +++ b/mod/data/preset/resources/listtemplate.html @@ -0,0 +1,7 @@ + + [[Title]] + [[Type]] + [[Author]] + [[Web link]] + ##actionsmenu## + diff --git a/mod/data/preset/resources/listtemplatefooter.html b/mod/data/preset/resources/listtemplatefooter.html new file mode 100644 index 00000000000..21a93bc1bc8 --- /dev/null +++ b/mod/data/preset/resources/listtemplatefooter.html @@ -0,0 +1,2 @@ + + diff --git a/mod/data/preset/resources/listtemplateheader.html b/mod/data/preset/resources/listtemplateheader.html new file mode 100644 index 00000000000..f7c1b4aaf37 --- /dev/null +++ b/mod/data/preset/resources/listtemplateheader.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/mod/data/preset/resources/preset.xml b/mod/data/preset/resources/preset.xml new file mode 100644 index 00000000000..24da6424456 --- /dev/null +++ b/mod/data/preset/resources/preset.xml @@ -0,0 +1,62 @@ + + + + +0 +0 +0 +0 +0 +0 +1 +0 +0 + + + +text +Title +0 + + + +text +Author +0 + + + +picture +Cover +0 +0 + + + +textarea +Description +0 +60 +10 +1 +0 + + + +url +Web link +0 +1 +1 + + + +menu +Type +0 +Type1 +Type2 +Type3 + + + diff --git a/mod/data/preset/resources/rsstemplate.html b/mod/data/preset/resources/rsstemplate.html new file mode 100644 index 00000000000..4096f11de72 --- /dev/null +++ b/mod/data/preset/resources/rsstemplate.html @@ -0,0 +1,29 @@ +
+

[[Title]]

+
+
+
+
+
Author
+
[[Author]]
+
+
+
Type
+
[[Type]]
+
+
+
Link
+
[[Web link]]
+
+
+
[[Cover]]
+
+ +
+
+

Description

+ [[Description]] +
+
+
+
diff --git a/mod/data/preset/resources/rsstitletemplate.html b/mod/data/preset/resources/rsstitletemplate.html new file mode 100644 index 00000000000..c865f7655cb --- /dev/null +++ b/mod/data/preset/resources/rsstitletemplate.html @@ -0,0 +1 @@ +[[Title]] diff --git a/mod/data/preset/resources/singletemplate.html b/mod/data/preset/resources/singletemplate.html new file mode 100644 index 00000000000..40ce12d8751 --- /dev/null +++ b/mod/data/preset/resources/singletemplate.html @@ -0,0 +1,32 @@ +
+
+

[[Title]]

+
##actionsmenu##
+
+
+
+
+
+
Author
+
[[Author]]
+
+
+
Type
+
[[Type]]
+
+
+
Link
+
[[Web link]]
+
+
+
[[Cover]]
+
+ +
+
+

Description

+ [[Description]] +
+
+
+
diff --git a/mod/data/preset/resources/tests/behat/resources_preset.feature b/mod/data/preset/resources/tests/behat/resources_preset.feature new file mode 100644 index 00000000000..c288acae6c9 --- /dev/null +++ b/mod/data/preset/resources/tests/behat/resources_preset.feature @@ -0,0 +1,101 @@ +@mod @mod_data @datapreset @datapreset_resources +Feature: Users can use the Resources preset + In order to create a Resources database + As a user + I need to apply and use the Resources preset + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Alice | Student | student1@example.com | + | teacher1 | Pau | Teacher | teacher1@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 | + And the following "activities" exist: + | activity | name | intro | course | idnumber | + | data | Student resources | Database intro | C1 | data1 | + And I am on the "Student resources" "data activity" page logged in as teacher1 + And I follow "Presets" + And I click on "fullname" "radio" in the "Resources" "table_row" + And I click on "Use preset" "button" + And I click on "Continue" "button" + And I click on "Continue" "button" + And the following "mod_data > entries" exist: + | database | user | Title | Description | Type | Author | Web link | Cover | + | data1 | student1 | My favourite book | Book content | Type1 | The book author | http://myfavouritebook.cat | first.png | + | data1 | teacher1 | My favourite podcast | Podcast content| Type2 | The podcast author | http://myfavouritepodcast.cat | second.png | + + @javascript + Scenario: Resources. Users view entries + When I am on the "Student resources" "data activity" page logged in as student1 + Then I should see "My favourite book" + And I should see "Type1" + And I should see "The book author" + And I should see "http://myfavouritebook.cat" + And I should not see "Book content" + And "Actions" "icon" should exist in the "#resources-list" "css_element" + And I should see "My favourite podcast" + And I should see "Type2" + And I should see "The podcast author" + And I should see "http://myfavouritepodcast.cat" + And I should not see "Podcast content" + # Single view. + And I select "Single view" from the "jump" singleselect + And I should see "My favourite book" + And I should see "Type1" + And I should see "The book author" + And I should see "http://myfavouritebook.cat" + And I should see "Book content" + And "Actions" "icon" should exist in the ".resources-single" "css_element" + And I should not see "My favourite podcast" + And I should not see "Type2" + And I should not see "The podcast author" + And I should not see "http://myfavouritepodcast.cat" + And I should not see "Podcast content" + And I follow "Next" + And I should see "My favourite podcast" + And I should see "Type2" + And I should see "The podcast author" + And I should see "http://myfavouritepodcast.cat" + And I should see "Podcast content" + # This student can't edit or delete this entry, so the Actions menu shouldn't be displayed. + And "Actions" "icon" should not exist in the ".resources-single" "css_element" + And I should not see "My favourite book" + And I should not see "Type1" + And I should not see "The book author" + And I should not see "http://myfavouritebook.cat" + And I should not see "Book content" + + @javascript + Scenario: Resources. Users can search entries + Given I am on the "Student resources" "data activity" page logged in as student1 + And "My favourite book" "text" should appear before "My favourite podcast" "text" + When I click on "Advanced search" "checkbox" + And I set the field "Title" to "book" + And I press "Save settings" + Then I should see "My favourite book" + And I should not see "My favourite podcast" + But I set the field "Title" to "favourite" + And I set the field "Order" to "Descending" + And I press "Save settings" + And "My favourite podcast" "text" should appear before "My favourite book" "text" + + @javascript + Scenario: Resources. Users can add entries + Given I am on the "Student resources" "data activity" page logged in as student1 + When I press "Add entry" + And I set the field "Title" to "This is the title" + And I set the field "Author" to "This is the author" + And I set the field "Description" to "This is description." + And I set the field "Web link" to "https://thisisthelink.cat" + And I set the field "Type" to "Type2" + And I press "Save" + Then I should see "This is the title" + And I should see "This is the author" + And I should see "https://thisisthelink.cat" + And I should see "Type2" diff --git a/mod/data/preset/resources/version.php b/mod/data/preset/resources/version.php new file mode 100644 index 00000000000..daa5353243f --- /dev/null +++ b/mod/data/preset/resources/version.php @@ -0,0 +1,29 @@ +. + +/** + * Data Resources preset version information. + * + * @package datapreset_resources + * @copyright 2022 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2022041200; // Requires this Moodle version. +$plugin->component = 'datapreset_resources'; // Full name of the plugin (used for diagnostics).
TitleTypeAuthorLink