diff --git a/invitations.php b/invitations.php index 1096bfd..40382ea 100644 --- a/invitations.php +++ b/invitations.php @@ -22,12 +22,9 @@ */ require_once("../../config.php"); - require_once($CFG->libdir.'/weblib.php'); require_once($CFG->dirroot.'/grade/querylib.php'); -$invitedurl = "{$CFG->wwwroot}/local/treestudyplan/invited.php"; - $systemcontext = context_system::instance(); $PAGE->set_url("/local/treestudyplan/invitations.php", []); @@ -46,7 +43,6 @@ $sent = optional_param('sent', '', PARAM_INT); if (!empty($sent)) { $invite = $DB->get_record('local_treestudyplan_invit', ['id' => $sent]); \core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite)); - }; if (!get_config("local_treestudyplan", "enableplansharing")) { @@ -54,71 +50,22 @@ if (!get_config("local_treestudyplan", "enableplansharing")) { $PAGE->set_heading(get_string('accessdenied', 'admin')); print $OUTPUT->header(); - - // Render page for skill level 0 (global). - - print "
"; - print get_string('accessdenied', 'admin'); - print "
"; - + print $OUTPUT->render_from_template('local_treestudyplan/error', [ + "title" => get_string('accessdenied', 'admin'), + "message" => get_string('error:invitationsdisabled', 'local_treestudyplan'), + ]); print $OUTPUT->footer(); - exit; + exit; // Just in case some code is added after this if statement erroneously later. } else { print $OUTPUT->header(); - - print "

".get_string('invite_description', 'local_treestudyplan')."

"; - $invites = $DB->get_records('local_treestudyplan_invit', ['user_id' => $USER->id]); - - print "

".get_string('invite_tablecaption', 'local_treestudyplan')."

"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - print ""; - if (count($invites) > 0) { - foreach ($invites as $invite) { - $testlink = $invitedurl."?key={$invite->invitekey}"; - print ""; - print ""; - print ""; - print ""; - print ""; - } - } else { - print ""; - } - print "
".get_string('invite_name', 'local_treestudyplan')."".get_string('invite_email', 'local_treestudyplan')."".get_string('invite_date', 'local_treestudyplan')." 
{$invite->name}{$invite->email}".userdate($invite->idate, "%x").""; - - print ""; - - print "name)."'"; - print " data-confirmbtn='".get_string('send', 'local_treestudyplan')."'"; - print " href='#' data-actionhref='{$CFG->wwwroot}/local/treestudyplan/edit-invite.php?resend={$invite->id}' title='" - .get_string('invite_tooltip_resend', 'local_treestudyplan')."'"; - print " >"; - - print ""; - print "name)."'"; - print " data-confirmbtn='".get_string('delete')."'"; - print " href='#' data-actionhref='{$CFG->wwwroot}/local/treestudyplan/edit-invite.php?delete={$invite->id}' title='" - .get_string('invite_tooltip_delete', 'local_treestudyplan')."'"; - print " >"; - - print "
".get_string('invite_table_empty', 'local_treestudyplan')."
"; - - print ""; - print " ".get_string('invite_button_new', 'local_treestudyplan').""; - + $data = [ + "invites" => array_values($invites), + "hasinvites" => boolval(count($invites) > 0), + "invitedurl" => "{$CFG->wwwroot}/local/treestudyplan/invited.php", + ]; + print $OUTPUT->render_from_template('local_treestudyplan/invitations', $data); print $OUTPUT->footer(); } diff --git a/invited.php b/invited.php index 231b23c..2f5da7c 100644 --- a/invited.php +++ b/invited.php @@ -52,13 +52,10 @@ if (!get_config("local_treestudyplan", "enableplansharing")) { $PAGE->set_heading(get_string('accessdenied', 'admin')); print $OUTPUT->header(); - - // Render page for skill level 0 (global). - - print "
"; - print get_string('accessdenied', 'admin'); - print "
"; - + print $OUTPUT->render_from_template('local_treestudyplan/error', [ + "title" => get_string('accessdenied', 'admin'), + "message" => get_string('error:invitationsdisabled', 'local_treestudyplan'), + ]); print $OUTPUT->footer(); exit; @@ -67,13 +64,9 @@ if (!get_config("local_treestudyplan", "enableplansharing")) { $PAGE->set_heading(get_string('invalid_invitekey_title', 'local_treestudyplan')); print $OUTPUT->header(); - - // Render page for skill level 0 (global). - - print "
"; - print get_string('invalid_invitekey_error', 'local_treestudyplan'); - print "
"; - + print $OUTPUT->render_from_template('local_treestudyplan/error', [ + "message" => get_string('error:invalid_invitekey', 'local_treestudyplan'), + ]); print $OUTPUT->footer(); exit; @@ -90,18 +83,6 @@ if (!get_config("local_treestudyplan", "enableplansharing")) { $PAGE->set_heading(get_string('report_invited', 'local_treestudyplan', "{$student->firstname} {$student->lastname}")); print $OUTPUT->header(); - print " -
-
-
- Loading... -
-
-
- -
-
- "; - + print $OUTPUT->render_from_template('local_treestudyplan/invited', []); print $OUTPUT->footer(); } diff --git a/lang/en/local_treestudyplan.php b/lang/en/local_treestudyplan.php index 3ab8ed9..8bf3d02 100644 --- a/lang/en/local_treestudyplan.php +++ b/lang/en/local_treestudyplan.php @@ -64,7 +64,7 @@ $string["report_index"] = 'View student progress reports'; $string["manage_invites"] = 'Share study plan access'; $string["share_report"] = 'Share'; $string["invalid_invitekey_title"] = "Invite key required"; -$string["invalid_invitekey_error"] = "You need an invitation to view data via this portal"; +$string["error:invalid_invitekey"] = "You need an invitation to view data via this portal"; $string["invite_description"] = "You can invite your parents or guardians to view your results. Those who receive your sharing link can view your grades until you revoke the invite"; $string["invite_tablecaption"] = "Active invites"; $string["invite_table_empty"] = "No active invites"; @@ -518,8 +518,9 @@ $string["error:nostudyplanviewaccess"] = 'Error: You do not have access to view $string["error:nostudyplaneditaccess"] = 'Error: You do not have access to manage study plans in this category or context: {$a}'; $string["error:nocategoriesvisible"] = 'Error: You have no viewing permissions in any category. Therefore the course list remains empty.'; $string["error:usernotassociated"] = 'Error: Requested student is not associated with this studyplan'; - +$string["error:invitationsdisabled"] = "Sharing studyplans with 3rd parties has been disabled on this site."; $string["error:coachdisabled"] = "The coach page has been disabled by the system administrator"; + $string["overall"] = 'Course'; $string["studyplan_report"] = 'Studyplan result overview'; $string["overviewreport:all"] = 'Result overview'; diff --git a/lang/nl/local_treestudyplan.php b/lang/nl/local_treestudyplan.php index 4b91060..e0ebdf6 100644 --- a/lang/nl/local_treestudyplan.php +++ b/lang/nl/local_treestudyplan.php @@ -64,7 +64,7 @@ $string["report_index"] = 'Studieplannen van studenten inzien'; $string["manage_invites"] = 'Studieplan delen'; $string["share_report"] = 'Delen'; $string["invalid_invitekey_title"] = "Uitnodiging vereist"; -$string["invalid_invitekey_error"] = "Je moet een uitnodiging hebben om via deze portal informatie te bekijken"; +$string["error:invalid_invitekey"] = "Je moet een uitnodiging hebben om via deze portal informatie te bekijken"; $string["invite_description"] = "Je kunt je ouders/verzorgers een uitnodiging sturen waarmee je live inzage in jouw studieplan en voortgang met ze deelt. Degene die de uitnodiging krijgt kan jouw studieplan inzien totdat je de uitnodiging weer intrekt."; $string["invite_tablecaption"] = "Actieve uitnodigingen"; $string["invite_table_empty"] = "Geen openstaande uitnodigingen"; @@ -518,8 +518,9 @@ $string["error:nostudyplanviewaccess"] = 'Fout: Je hebt geen rechten om studiepl $string["error:nostudyplaneditaccess"] = 'Fout: Je hebt geen rechten om studieplannen in deze categorie of context te beheren: {$a}'; $string["error:nocategoriesvisible"] = 'Fout: Je kunt geen cursussen in een categorie bekijken. Daarom blijft de cursuslijst leeg'; $string["error:usernotassociated"] = 'Fout: De gevraagde student is niet gekoppeld aan dit studieplan'; - +$string["error:invitationsdisabled"] = "De optie om een studieplan te kunnen delen is uitgeschakeld op deze site."; $string["error:coachdisabled"] = "De coach functie is uitgeschakeld"; + $string["overall"] = 'Cursus voltooid'; $string["studyplan_report"] = 'Studieplan resultatenoverzicht'; $string["overviewreport:all"] = 'Resultatenoverzicht'; diff --git a/templates/error.mustache b/templates/error.mustache new file mode 100644 index 0000000..18da094 --- /dev/null +++ b/templates/error.mustache @@ -0,0 +1,44 @@ +{{! + This file is part of Moodle - https://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 . +}} +{{! + @template local_treestudyplan/error + + Template for error messages like access denied + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * none + + Example context (json): + { + "title": "test", + "message": "detailed html message", + } +}} +
+{{#title}} +

{{title}}

+{{/title}} +{{#message}} + {{message}} +{{/message}} +
\ No newline at end of file diff --git a/templates/form/element_text_integer.mustache b/templates/form/element_text_integer.mustache index cf80373..2a41ccc 100644 --- a/templates/form/element_text_integer.mustache +++ b/templates/form/element_text_integer.mustache @@ -1,5 +1,5 @@ {{! - @template local_treestudyplan/element_text_integer + @template local_treestudyplan/form/element_text_integer Template for integer only field diff --git a/templates/invitations.mustache b/templates/invitations.mustache new file mode 100644 index 0000000..7897f2c --- /dev/null +++ b/templates/invitations.mustache @@ -0,0 +1,92 @@ +{{! + This file is part of Moodle - https://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 . +}} +{{! + @template local_treestudyplan/invitations + + Template for rendering the invitations page + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * none + + Example context (json): + { + "invites": array_values($DB->get_records('local_treestudyplan_invit', ['user_id' => $USER->id])); + "hasinvites": true, + } +}} +
+

{{#str}} invite_description, local_treestudyplan {{/str}}

+ + +

{{#str}} invite_tablecaption, local_treestudyplan {{/str}}

+ + + + + + + + + + {{#hasinvites}} + {{#invites}} + + + + + + + {{/invites}} + {{/hasinvites}} + {{^hasinvites}} + + {{/hasinvites}} + +
 {{#str}} invite_name, local_treestudyplan {{/str}} {{#str}} invite_email, local_treestudyplan {{/str}} {{#str}} invite_date, local_treestudyplan {{/str}}  
{{name}}{{email}}{{#userdate}} {{idate}}, %x {{/userdate}} + + + + + + +
{{#str}} invite_table_empty, local_treestudyplan {{/str}}
+ + + {{#str}} invite_button_new, local_treestudyplan {{/str}} + +
\ No newline at end of file diff --git a/templates/invited.mustache b/templates/invited.mustache new file mode 100644 index 0000000..a346e0b --- /dev/null +++ b/templates/invited.mustache @@ -0,0 +1,44 @@ +{{! + This file is part of Moodle - https://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 . +}} +{{! + @template local_treestudyplan/invitations + + Template for rendering the invitations page + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * none + + Example context (json): + { + + } +}} +
+
+
+ Loading... +
+
+
+ +
+
\ No newline at end of file