From 63bdc847193ef1fbdff6415612ae272d8491fbdd Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Tue, 16 Aug 2022 08:18:27 +0200 Subject: [PATCH] MDL-75411 mod_data: Add proposals preset Co-author: Laurent David --- lib/classes/plugin_manager.php | 3 +- mod/data/preset/proposals/addtemplate.html | 18 ++++ .../preset/proposals/asearchtemplate.html | 20 ++++ .../proposals/classes/privacy/provider.php | 37 +++++++ mod/data/preset/proposals/csstemplate.css | 18 ++++ mod/data/preset/proposals/jstemplate.js | 0 .../lang/en/datapreset_proposals.php | 28 ++++++ mod/data/preset/proposals/listtemplate.html | 23 +++++ .../preset/proposals/listtemplatefooter.html | 1 + .../preset/proposals/listtemplateheader.html | 1 + mod/data/preset/proposals/preset.xml | 48 +++++++++ mod/data/preset/proposals/rsstemplate.html | 26 +++++ .../preset/proposals/rsstitletemplate.html | 1 + mod/data/preset/proposals/singletemplate.html | 36 +++++++ .../tests/behat/proposals_preset.feature | 98 +++++++++++++++++++ mod/data/preset/proposals/version.php | 29 ++++++ 16 files changed, 386 insertions(+), 1 deletion(-) create mode 100644 mod/data/preset/proposals/addtemplate.html create mode 100644 mod/data/preset/proposals/asearchtemplate.html create mode 100644 mod/data/preset/proposals/classes/privacy/provider.php create mode 100644 mod/data/preset/proposals/csstemplate.css create mode 100644 mod/data/preset/proposals/jstemplate.js create mode 100644 mod/data/preset/proposals/lang/en/datapreset_proposals.php create mode 100644 mod/data/preset/proposals/listtemplate.html create mode 100644 mod/data/preset/proposals/listtemplatefooter.html create mode 100644 mod/data/preset/proposals/listtemplateheader.html create mode 100644 mod/data/preset/proposals/preset.xml create mode 100644 mod/data/preset/proposals/rsstemplate.html create mode 100644 mod/data/preset/proposals/rsstitletemplate.html create mode 100644 mod/data/preset/proposals/singletemplate.html create mode 100644 mod/data/preset/proposals/tests/behat/proposals_preset.feature create mode 100644 mod/data/preset/proposals/version.php diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 30731d6f18a..c1855d0a856 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1850,7 +1850,8 @@ class core_plugin_manager { ), 'datapreset' => array( - 'imagegallery' + 'imagegallery', + 'proposals', ), 'fileconverter' => array( diff --git a/mod/data/preset/proposals/addtemplate.html b/mod/data/preset/proposals/addtemplate.html new file mode 100644 index 00000000000..c42ab97d55c --- /dev/null +++ b/mod/data/preset/proposals/addtemplate.html @@ -0,0 +1,18 @@ +
+
+
+ [[Title]] +
+
+
+ [[Status]] +
+
+
+ [[Summary]] +
+
+
+ [[Content]] +
+
diff --git a/mod/data/preset/proposals/asearchtemplate.html b/mod/data/preset/proposals/asearchtemplate.html new file mode 100644 index 00000000000..7b42d4ae8b3 --- /dev/null +++ b/mod/data/preset/proposals/asearchtemplate.html @@ -0,0 +1,20 @@ +
+
+
+
+ [[Title]] +
+
+
+ [[Status]] +
+
+
+ [[Summary]] +
+
+
+ [[Content]] +
+
+
diff --git a/mod/data/preset/proposals/classes/privacy/provider.php b/mod/data/preset/proposals/classes/privacy/provider.php new file mode 100644 index 00000000000..9b9d45e2546 --- /dev/null +++ b/mod/data/preset/proposals/classes/privacy/provider.php @@ -0,0 +1,37 @@ +. + +namespace datapreset_proposals\privacy; + +/** + * Privacy provider implementation for datapreset_proposals. + * + * @package datapreset_proposals + * @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/proposals/csstemplate.css b/mod/data/preset/proposals/csstemplate.css new file mode 100644 index 00000000000..eb4879100d9 --- /dev/null +++ b/mod/data/preset/proposals/csstemplate.css @@ -0,0 +1,18 @@ +/****** List View CSS ******/ + +#proposals-list .card-header a.d-block { + color: black; + font-weight: bold; +} + +#proposals-list .card { + overflow: visible; +} + +/***** Add entry CSS *****/ + +.proposals-addentry .form-group label, +.proposals-asearch .form-group label { + font-weight: bold; + padding-top: 20px; +} diff --git a/mod/data/preset/proposals/jstemplate.js b/mod/data/preset/proposals/jstemplate.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mod/data/preset/proposals/lang/en/datapreset_proposals.php b/mod/data/preset/proposals/lang/en/datapreset_proposals.php new file mode 100644 index 00000000000..73500fb4a9b --- /dev/null +++ b/mod/data/preset/proposals/lang/en/datapreset_proposals.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for component 'datapreset_proposals', language 'en'. + * + * @package datapreset_proposals + * @copyright 2022 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['modulename'] = 'Proposals'; +$string['modulename_help'] = 'Use this preset to collect proposals for topics, research, projects, etc. Fields include status such as approved, declined, revise or pending.'; +$string['pluginname'] = 'Proposals'; +$string['privacy:metadata'] = 'The Proposals plugin does not store any personal data.'; diff --git a/mod/data/preset/proposals/listtemplate.html b/mod/data/preset/proposals/listtemplate.html new file mode 100644 index 00000000000..857500d6117 --- /dev/null +++ b/mod/data/preset/proposals/listtemplate.html @@ -0,0 +1,23 @@ +
+ + +
+
+ [[Summary]] +

View the full proposal

+
+
+
diff --git a/mod/data/preset/proposals/listtemplatefooter.html b/mod/data/preset/proposals/listtemplatefooter.html new file mode 100644 index 00000000000..04f5b844997 --- /dev/null +++ b/mod/data/preset/proposals/listtemplatefooter.html @@ -0,0 +1 @@ + diff --git a/mod/data/preset/proposals/listtemplateheader.html b/mod/data/preset/proposals/listtemplateheader.html new file mode 100644 index 00000000000..618aff72792 --- /dev/null +++ b/mod/data/preset/proposals/listtemplateheader.html @@ -0,0 +1 @@ +
diff --git a/mod/data/preset/proposals/preset.xml b/mod/data/preset/proposals/preset.xml new file mode 100644 index 00000000000..8319b56008b --- /dev/null +++ b/mod/data/preset/proposals/preset.xml @@ -0,0 +1,48 @@ + + + + +0 +0 +0 +0 +0 +0 +1 +0 +0 + + + +text +Title +0 + + + +menu +Status +0 +Approved +In review +Rejected +Pending + + + +text +Summary +0 + + + +textarea +Content +0 +60 +10 +1 +0 + + + diff --git a/mod/data/preset/proposals/rsstemplate.html b/mod/data/preset/proposals/rsstemplate.html new file mode 100644 index 00000000000..2724369f704 --- /dev/null +++ b/mod/data/preset/proposals/rsstemplate.html @@ -0,0 +1,26 @@ +
+
+

[[Title]]

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

Summary

+ [[Summary]] +
+
+
+

Description

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

[[Title]]

+
##actionsmenu##
+
+
+
+
Author
+
##userpicture## ##user##
+
+
+
Status
+
[[Status]]
+
+
+
Date added
+
##timeadded##
+
+
+
Date modified
+
##timemodified##
+
+
+
+

Summary

+ [[Summary]] +
+
+
+
+

Content

+ [[Content]] +
+
+
+
diff --git a/mod/data/preset/proposals/tests/behat/proposals_preset.feature b/mod/data/preset/proposals/tests/behat/proposals_preset.feature new file mode 100644 index 00000000000..d14c498175d --- /dev/null +++ b/mod/data/preset/proposals/tests/behat/proposals_preset.feature @@ -0,0 +1,98 @@ +@mod @mod_data @datapreset @datapreset_proposals +Feature: Users can use the Proposals preset + In order to create a Proposals database + As a user + I need to apply and use the Proposals 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 projects | Database intro | C1 | data1 | + And I am on the "Student projects" "data activity" page logged in as teacher1 + And I follow "Presets" + And I click on "fullname" "radio" in the "Proposals" "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 | Summary | Content | Status | + | data1 | student1 | Project created by student | Summary 1 | Content for entry 1 | Pending | + | data1 | teacher1 | Project created by teacher | Summary 2 | And content for entry 2 | Rejected | + + @javascript + Scenario: Proposals. Users view entries + When I am on the "Student projects" "data activity" page logged in as student1 + Then I should see "Project created by student" + And I should see "Pending" + And "Summary 1" "text" should exist + And "Actions" "icon" should exist in the "#proposals-list" "css_element" + And I should see "Project created by teacher" + And I should see "Rejected" + And "Summary 2" "text" should exist + And I click on "Project created by student" "link" + And I click on "Project created by teacher" "link" + And I should see "Summary 1" + And I should not see "Content for entry 1" + And I should see "Summary 2" + And I should not see "And content for entry 2" + # Single view. + And I select "Single view" from the "jump" singleselect + And I should see "Project created by student" + And I should see "Summary 1" + And I should see "Content for entry 1" + And I should see "Pending" + And "Actions" "icon" should exist in the ".proposals-single" "css_element" + And I should not see "Project created by teacher" + And I should not see "Summary 2" + And I should not see "And content for entry 2" + And I should not see "Rejected" + And I follow "Next" + And I should see "Project created by teacher" + And I should see "Summary 2" + And I should see "And content for entry 2" + And I should see "Rejected" + # 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 ".proposals-single" "css_element" + And I should not see "Project created by student" + And I should not see "Summary 1" + And I should not see "Content for entry 1" + And I should not see "Pending" + + @javascript + Scenario: Proposals. Users can search entries + Given I am on the "Student projects" "data activity" page logged in as student1 + And "Project created by student" "text" should appear before "Project 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 "Project created by student" + And I should not see "Project created by teacher" + But I set the field "Title" to "Project" + And I set the field "Order" to "Descending" + And I press "Save settings" + And "Project created by teacher" "text" should appear before "Project created by student" "text" + + @javascript + Scenario: Proposals. Users can add entries + Given I am on the "Student projects" "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 "Summary" to "This is the summary for the new entry." + And I set the field "Content" to "This is the content for the new entry." + And I set the field "Status" to "Approved" + And I press "Save" + Then I should see "This is the title" + And I should see "Approved" + And I should see "This is the summary for the new entry." + And I should see "This is the content for the new entry." diff --git a/mod/data/preset/proposals/version.php b/mod/data/preset/proposals/version.php new file mode 100644 index 00000000000..5990f19c324 --- /dev/null +++ b/mod/data/preset/proposals/version.php @@ -0,0 +1,29 @@ +. + +/** + * Data Proposals preset version information. + * + * @package datapreset_proposals + * @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_proposals'; // Full name of the plugin (used for diagnostics).