From 89eed9e368429b3c6c7c3708fd80b1120f0e3b84 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 24 Aug 2022 15:49:48 +0200 Subject: [PATCH] MDL-75412 mod_data: Add journal preset --- mod/data/preset/journal/addtemplate.html | 10 +++ mod/data/preset/journal/asearchtemplate.html | 12 +++ .../journal/classes/privacy/provider.php | 37 +++++++++ mod/data/preset/journal/csstemplate.css | 16 ++++ mod/data/preset/journal/jstemplate.js | 0 .../journal/lang/en/datapreset_journal.php | 28 +++++++ mod/data/preset/journal/listtemplate.html | 11 +++ .../preset/journal/listtemplatefooter.html | 1 + .../preset/journal/listtemplateheader.html | 1 + mod/data/preset/journal/preset.xml | 32 ++++++++ mod/data/preset/journal/rsstemplate.html | 21 +++++ mod/data/preset/journal/rsstitletemplate.html | 1 + mod/data/preset/journal/singletemplate.html | 22 ++++++ .../tests/behat/journal_preset.feature | 78 +++++++++++++++++++ mod/data/preset/journal/version.php | 29 +++++++ mod/data/styles.css | 4 - 16 files changed, 299 insertions(+), 4 deletions(-) create mode 100644 mod/data/preset/journal/addtemplate.html create mode 100644 mod/data/preset/journal/asearchtemplate.html create mode 100644 mod/data/preset/journal/classes/privacy/provider.php create mode 100644 mod/data/preset/journal/csstemplate.css create mode 100644 mod/data/preset/journal/jstemplate.js create mode 100644 mod/data/preset/journal/lang/en/datapreset_journal.php create mode 100644 mod/data/preset/journal/listtemplate.html create mode 100644 mod/data/preset/journal/listtemplatefooter.html create mode 100644 mod/data/preset/journal/listtemplateheader.html create mode 100644 mod/data/preset/journal/preset.xml create mode 100644 mod/data/preset/journal/rsstemplate.html create mode 100644 mod/data/preset/journal/rsstitletemplate.html create mode 100644 mod/data/preset/journal/singletemplate.html create mode 100644 mod/data/preset/journal/tests/behat/journal_preset.feature create mode 100644 mod/data/preset/journal/version.php diff --git a/mod/data/preset/journal/addtemplate.html b/mod/data/preset/journal/addtemplate.html new file mode 100644 index 00000000000..1725035595e --- /dev/null +++ b/mod/data/preset/journal/addtemplate.html @@ -0,0 +1,10 @@ +
+
+
+ [[Title]] +
+
+
+ [[Content]] +
+
diff --git a/mod/data/preset/journal/asearchtemplate.html b/mod/data/preset/journal/asearchtemplate.html new file mode 100644 index 00000000000..1c9f2e1f242 --- /dev/null +++ b/mod/data/preset/journal/asearchtemplate.html @@ -0,0 +1,12 @@ +
+
+
+
+ [[title]] +
+
+
+ [[content]] +
+
+
diff --git a/mod/data/preset/journal/classes/privacy/provider.php b/mod/data/preset/journal/classes/privacy/provider.php new file mode 100644 index 00000000000..73bbdb93536 --- /dev/null +++ b/mod/data/preset/journal/classes/privacy/provider.php @@ -0,0 +1,37 @@ +. + +namespace datapreset_journal\privacy; + +/** + * Privacy provider implementation for datapreset_journal. + * + * @package datapreset_journal + * @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/journal/csstemplate.css b/mod/data/preset/journal/csstemplate.css new file mode 100644 index 00000000000..6246e64e655 --- /dev/null +++ b/mod/data/preset/journal/csstemplate.css @@ -0,0 +1,16 @@ +/****** List View CSS ******/ + +.truncate-overflow { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; +} + +/***** Add entry CSS *****/ + +.journal-addentry .form-group label, +.journal-asearch .form-group label { + font-weight: bold; + padding-top: 20px; +} diff --git a/mod/data/preset/journal/jstemplate.js b/mod/data/preset/journal/jstemplate.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mod/data/preset/journal/lang/en/datapreset_journal.php b/mod/data/preset/journal/lang/en/datapreset_journal.php new file mode 100644 index 00000000000..cb4e6ba01bf --- /dev/null +++ b/mod/data/preset/journal/lang/en/datapreset_journal.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for component 'datapreset_journal', language 'en'. + * + * @package datapreset_journal + * @copyright 2022 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['modulename'] = 'Journal'; +$string['modulename_help'] = 'Use this preset for a journal, diary, reflections tool or research log.'; +$string['pluginname'] = 'Journal'; +$string['privacy:metadata'] = 'The Reflections plugin does not store any personal data.'; diff --git a/mod/data/preset/journal/listtemplate.html b/mod/data/preset/journal/listtemplate.html new file mode 100644 index 00000000000..0d97a960cc9 --- /dev/null +++ b/mod/data/preset/journal/listtemplate.html @@ -0,0 +1,11 @@ +
+
+
+

[[Title]]

+
##actionsmenu##
+
+
[[Content]]
+

##userpicture## ##user##

+

##timeadded##

+
+
diff --git a/mod/data/preset/journal/listtemplatefooter.html b/mod/data/preset/journal/listtemplatefooter.html new file mode 100644 index 00000000000..04f5b844997 --- /dev/null +++ b/mod/data/preset/journal/listtemplatefooter.html @@ -0,0 +1 @@ + diff --git a/mod/data/preset/journal/listtemplateheader.html b/mod/data/preset/journal/listtemplateheader.html new file mode 100644 index 00000000000..d8aaf9f3e3d --- /dev/null +++ b/mod/data/preset/journal/listtemplateheader.html @@ -0,0 +1 @@ +
diff --git a/mod/data/preset/journal/preset.xml b/mod/data/preset/journal/preset.xml new file mode 100644 index 00000000000..725118c77d1 --- /dev/null +++ b/mod/data/preset/journal/preset.xml @@ -0,0 +1,32 @@ + + + + +0 +0 +0 +0 +0 +0 +1 +0 +0 + + + +text +Title +0 + + + +textarea +Content +0 +60 +10 +1 +0 + + + diff --git a/mod/data/preset/journal/rsstemplate.html b/mod/data/preset/journal/rsstemplate.html new file mode 100644 index 00000000000..90521468818 --- /dev/null +++ b/mod/data/preset/journal/rsstemplate.html @@ -0,0 +1,21 @@ +
+
+

[[Title]]

+
+
+
+
Author
+
##userpicture## ##user##
+
+
+
Status
+
[[Content status]]
+
+
+
+

Description

+ [[Content]] +
+
+
+
diff --git a/mod/data/preset/journal/rsstitletemplate.html b/mod/data/preset/journal/rsstitletemplate.html new file mode 100644 index 00000000000..c865f7655cb --- /dev/null +++ b/mod/data/preset/journal/rsstitletemplate.html @@ -0,0 +1 @@ +[[Title]] diff --git a/mod/data/preset/journal/singletemplate.html b/mod/data/preset/journal/singletemplate.html new file mode 100644 index 00000000000..fa7b4ea6aeb --- /dev/null +++ b/mod/data/preset/journal/singletemplate.html @@ -0,0 +1,22 @@ +
+
+

[[Title]]

+
##actionsmenu##
+
+
+
+
Author
+
##userpicture## ##user##
+
+
+
Date
+
##timeadded##
+
+
+
+

Reflections

+ [[Content]] +
+
+
+
diff --git a/mod/data/preset/journal/tests/behat/journal_preset.feature b/mod/data/preset/journal/tests/behat/journal_preset.feature new file mode 100644 index 00000000000..d138c6ba13b --- /dev/null +++ b/mod/data/preset/journal/tests/behat/journal_preset.feature @@ -0,0 +1,78 @@ +@mod @mod_data @datapreset @datapreset_journal +Feature: Users can use the Journal preset + In order to create a Journal database + As a user + I need to apply and use the Journal 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 reflections | Database intro | C1 | data1 | + And I am on the "Student reflections" "data activity" page logged in as teacher1 + And I follow "Presets" + And I click on "fullname" "radio" in the "Journal" "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 | Content | + | data1 | student1 | Reflection created by student | This is the content for the entry 1 | + | data1 | teacher1 | Reflection created by teacher | And this is the content for the entry 2 | + + @javascript + Scenario: Journal. Users view entries + When I am on the "Student reflections" "data activity" page logged in as student1 + Then I should see "Reflection created by student" + And I should see "This is the content for the entry 1" + And "Actions" "icon" should exist in the "#journal-list" "css_element" + And I should see "Reflection created by teacher" + And I should see "And this is the content for the entry 2" + # Single view. + And I select "Single view" from the "jump" singleselect + And I should see "Reflection created by student" + And I should see "This is the content for the entry 1" + And "Actions" "icon" should exist in the ".journal-single" "css_element" + And I should not see "Reflection created by teacher" + And I should not see "And this is the content for the entry 2" + And I follow "Next" + And I should see "Reflection created by teacher" + And I should see "And this is the content for the entry 2" + # 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 ".journal-single" "css_element" + And I should not see "Reflection created by student" + And I should not see "This is the content for the entry 1" + + @javascript + Scenario: Journal. Users can search entries + Given I am on the "Student reflections" "data activity" page logged in as student1 + And "Reflection created by student" "text" should appear before "Reflection created by teacher" "text" + When I click on "Advanced search" "checkbox" + And I set the field "Title" to "student" + And I press "Save settings" + Then I should see "Reflection created by student" + And I should not see "Reflection created by teacher" + But I set the field "Title" to "Reflection" + And I set the field "Order" to "Descending" + And I press "Save settings" + And "Reflection created by teacher" "text" should appear before "Reflection created by student" "text" + + @javascript + Scenario: Journal. Users can add entries + Given I am on the "Student reflections" "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 "Content" to "This is the content for the new entry." + And I press "Save" + Then I should see "This is the title" + And I should see "This is the content for the new entry." diff --git a/mod/data/preset/journal/version.php b/mod/data/preset/journal/version.php new file mode 100644 index 00000000000..97f77b1e0cf --- /dev/null +++ b/mod/data/preset/journal/version.php @@ -0,0 +1,29 @@ +. + +/** + * Data Journal preset version information. + * + * @package datapreset_journal + * @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_journal'; // Full name of the plugin (used for diagnostics). diff --git a/mod/data/styles.css b/mod/data/styles.css index ff8d7f96e05..70a9e18a8fe 100644 --- a/mod/data/styles.css +++ b/mod/data/styles.css @@ -141,10 +141,6 @@ text-align: left; } -#page-mod-data-edit .mod-data-input { - margin-left: 10px; -} - #page-mod-data-edit .datatagcontrol { padding-left: 10px; }