1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-23 09:23:09 +02:00

MDL-71914 mod_feedback: Add tertiary nav in feedback

This commit is contained in:
Peter Dias 2021-06-16 12:55:02 +08:00
parent 10b7badd61
commit 773051b98f
41 changed files with 1629 additions and 254 deletions

@ -0,0 +1,2 @@
define ("mod_feedback/createtemplate",["exports","core_form/modalform","core/notification","core/str","core/toast"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=f(b);c=f(c);function f(a){return a&&a.__esModule?a:{default:a}}var g={modaltrigger:"[data-action=\"createtemplate\"]"};a.init=function init(){var a=document.querySelector(g.modaltrigger);a.addEventListener("click",function(a){a.preventDefault();var f=a.currentTarget,g=new b.default({modalConfig:{title:(0,d.get_string)("save_as_new_template","mod_feedback")},formClass:"mod_feedback\\form\\create_template_form",args:{id:f.dataset.dataid},saveButtonText:(0,d.get_string)("save","core")});g.addEventListener(g.events.FORM_SUBMITTED,function(a){if(a.detail.result){(0,d.get_string)("template_saved","feedback").then(e.add).catch()}else{(0,d.get_string)("saving_failed","feedback").then(function(a){return c.default.addNotification({type:"error",message:a})}).catch()}});g.show()})}});
//# sourceMappingURL=createtemplate.min.js.map

@ -0,0 +1 @@
{"version":3,"sources":["../src/createtemplate.js"],"names":["selectors","modaltrigger","init","trigger","document","querySelector","addEventListener","event","preventDefault","ele","currentTarget","modalForm","ModalForm","modalConfig","title","formClass","args","id","dataset","dataid","saveButtonText","events","FORM_SUBMITTED","detail","result","then","addToast","catch","string","Notification","addNotification","type","message","show"],"mappings":"oNAuBA,OACA,O,sDAIMA,CAAAA,CAAS,CAAG,CACdC,YAAY,CAAE,kCADA,C,QAOE,QAAPC,CAAAA,IAAO,EAAM,CACtB,GAAMC,CAAAA,CAAO,CAAGC,QAAQ,CAACC,aAAT,CAAuBL,CAAS,CAACC,YAAjC,CAAhB,CAEAE,CAAO,CAACG,gBAAR,CAAyB,OAAzB,CAAkC,SAAAC,CAAK,CAAI,CACvCA,CAAK,CAACC,cAAN,GADuC,GAEjCC,CAAAA,CAAG,CAAGF,CAAK,CAACG,aAFqB,CAIjCC,CAAS,CAAG,GAAIC,UAAJ,CAAc,CAC5BC,WAAW,CAAE,CACTC,KAAK,CAAE,iBAAU,sBAAV,CAAkC,cAAlC,CADE,CADe,CAI5BC,SAAS,CAAE,0CAJiB,CAK5BC,IAAI,CAAE,CACFC,EAAE,CAAER,CAAG,CAACS,OAAJ,CAAYC,MADd,CALsB,CAQ5BC,cAAc,CAAE,iBAAU,MAAV,CAAkB,MAAlB,CARY,CAAd,CAJqB,CAgBvCT,CAAS,CAACL,gBAAV,CAA2BK,CAAS,CAACU,MAAV,CAAiBC,cAA5C,CAA4D,SAAAf,CAAK,CAAI,CACjE,GAAIA,CAAK,CAACgB,MAAN,CAAaC,MAAjB,CAAyB,CACrB,iBAAU,gBAAV,CAA4B,UAA5B,EAAwCC,IAAxC,CAA6CC,KAA7C,EAAuDC,KAAvD,EACH,CAFD,IAEO,CACH,iBAAU,eAAV,CAA2B,UAA3B,EAAuCF,IAAvC,CAA4C,SAAAG,CAAM,CAAI,CAClD,MAAOC,WAAaC,eAAb,CAA6B,CAChCC,IAAI,CAAE,OAD0B,CAEhCC,OAAO,CAAEJ,CAFuB,CAA7B,CAIV,CALD,EAKGD,KALH,EAMH,CACJ,CAXD,EAaAhB,CAAS,CAACsB,IAAV,EACH,CA9BD,CA+BH,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript module for saving a new template.\n *\n * @module mod_feedback/createtemplate\n * @copyright 2021 Peter Dias\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport {add as addToast} from 'core/toast';\n\nconst selectors = {\n modaltrigger: '[data-action=\"createtemplate\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const trigger = document.querySelector(selectors.modaltrigger);\n\n trigger.addEventListener('click', event => {\n event.preventDefault();\n const ele = event.currentTarget;\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('save_as_new_template', 'mod_feedback'),\n },\n formClass: 'mod_feedback\\\\form\\\\create_template_form',\n args: {\n id: ele.dataset.dataid\n },\n saveButtonText: getString('save', 'core')\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n getString('template_saved', 'feedback').then(addToast).catch();\n } else {\n getString('saving_failed', 'feedback').then(string => {\n return Notification.addNotification({\n type: 'error',\n message: string\n });\n }).catch();\n }\n });\n\n modalForm.show();\n });\n};\n"],"file":"createtemplate.min.js"}

@ -0,0 +1,2 @@
define ("mod_feedback/usetemplate",["exports","core_form/modalform","core/notification","core/str"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=e(b);c=e(c);function e(a){return a&&a.__esModule?a:{default:a}}var f={modaltrigger:"[data-action=\"usetemplate\"]"};a.init=function init(){var a=document.querySelector(f.modaltrigger);a.addEventListener("click",function(e){e.preventDefault();var f=new b.default({modalConfig:{title:(0,d.get_string)("use_this_template","mod_feedback")},formClass:"mod_feedback\\form\\use_template_form",args:{id:a.getAttribute("data-dataid"),templateid:a.getAttribute("data-templateid")},saveButtonText:(0,d.get_string)("save","core")});f.addEventListener(f.events.FORM_SUBMITTED,function(a){if(a.detail.result){window.location.assign(a.detail.url)}else{c.default.addNotification({type:"error",message:(0,d.get_string)("saving_failed","mod_feedback")})}});f.show()})}});
//# sourceMappingURL=usetemplate.min.js.map

@ -0,0 +1 @@
{"version":3,"sources":["../src/usetemplate.js"],"names":["selectors","modaltrigger","init","trigger","document","querySelector","addEventListener","event","preventDefault","modalForm","ModalForm","modalConfig","title","formClass","args","id","getAttribute","templateid","saveButtonText","events","FORM_SUBMITTED","detail","result","window","location","assign","url","Notification","addNotification","type","message","show"],"mappings":"kMAuBA,OACA,O,sDAGMA,CAAAA,CAAS,CAAG,CACdC,YAAY,CAAE,+BADA,C,QAOE,QAAPC,CAAAA,IAAO,EAAM,CACtB,GAAMC,CAAAA,CAAO,CAAGC,QAAQ,CAACC,aAAT,CAAuBL,CAAS,CAACC,YAAjC,CAAhB,CAEAE,CAAO,CAACG,gBAAR,CAAyB,OAAzB,CAAkC,SAAAC,CAAK,CAAI,CACvCA,CAAK,CAACC,cAAN,GAEA,GAAMC,CAAAA,CAAS,CAAG,GAAIC,UAAJ,CAAc,CAC5BC,WAAW,CAAE,CACTC,KAAK,CAAE,iBAAU,mBAAV,CAA+B,cAA/B,CADE,CADe,CAI5BC,SAAS,CAAE,uCAJiB,CAK5BC,IAAI,CAAE,CACFC,EAAE,CAAEZ,CAAO,CAACa,YAAR,CAAqB,aAArB,CADF,CAEFC,UAAU,CAAEd,CAAO,CAACa,YAAR,CAAqB,iBAArB,CAFV,CALsB,CAS5BE,cAAc,CAAE,iBAAU,MAAV,CAAkB,MAAlB,CATY,CAAd,CAAlB,CAaAT,CAAS,CAACH,gBAAV,CAA2BG,CAAS,CAACU,MAAV,CAAiBC,cAA5C,CAA4D,SAAAb,CAAK,CAAI,CACjE,GAAIA,CAAK,CAACc,MAAN,CAAaC,MAAjB,CAAyB,CACrBC,MAAM,CAACC,QAAP,CAAgBC,MAAhB,CAAuBlB,CAAK,CAACc,MAAN,CAAaK,GAApC,CACH,CAFD,IAEO,CACHC,UAAaC,eAAb,CAA6B,CACzBC,IAAI,CAAE,OADmB,CAEzBC,OAAO,CAAG,iBAAU,eAAV,CAA2B,cAA3B,CAFe,CAA7B,CAIH,CACJ,CATD,EAWArB,CAAS,CAACsB,IAAV,EACH,CA5BD,CA6BH,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript module for using an existing template\n *\n * @module mod_feedback/usetemplate\n * @copyright 2021 Peter Dias\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalForm from 'core_form/modalform';\nimport Notification from 'core/notification';\nimport {get_string as getString} from 'core/str';\n\nconst selectors = {\n modaltrigger: '[data-action=\"usetemplate\"]',\n};\n\n/**\n * Initialize module\n */\nexport const init = () => {\n const trigger = document.querySelector(selectors.modaltrigger);\n\n trigger.addEventListener('click', event => {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n modalConfig: {\n title: getString('use_this_template', 'mod_feedback'),\n },\n formClass: 'mod_feedback\\\\form\\\\use_template_form',\n args: {\n id: trigger.getAttribute('data-dataid'),\n templateid: trigger.getAttribute('data-templateid')\n },\n saveButtonText: getString('save', 'core')\n });\n\n // Show a toast notification when the form is submitted.\n modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {\n if (event.detail.result) {\n window.location.assign(event.detail.url);\n } else {\n Notification.addNotification({\n type: 'error',\n message: getString('saving_failed', 'mod_feedback')\n });\n }\n });\n\n modalForm.show();\n });\n};\n"],"file":"usetemplate.min.js"}

@ -0,0 +1,70 @@
// 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/>.
/**
* Javascript module for saving a new template.
*
* @module mod_feedback/createtemplate
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import ModalForm from 'core_form/modalform';
import Notification from 'core/notification';
import {get_string as getString} from 'core/str';
import {add as addToast} from 'core/toast';
const selectors = {
modaltrigger: '[data-action="createtemplate"]',
};
/**
* Initialize module
*/
export const init = () => {
const trigger = document.querySelector(selectors.modaltrigger);
trigger.addEventListener('click', event => {
event.preventDefault();
const ele = event.currentTarget;
const modalForm = new ModalForm({
modalConfig: {
title: getString('save_as_new_template', 'mod_feedback'),
},
formClass: 'mod_feedback\\form\\create_template_form',
args: {
id: ele.dataset.dataid
},
saveButtonText: getString('save', 'core')
});
// Show a toast notification when the form is submitted.
modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {
if (event.detail.result) {
getString('template_saved', 'feedback').then(addToast).catch();
} else {
getString('saving_failed', 'feedback').then(string => {
return Notification.addNotification({
type: 'error',
message: string
});
}).catch();
}
});
modalForm.show();
});
};

@ -0,0 +1,67 @@
// 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/>.
/**
* Javascript module for using an existing template
*
* @module mod_feedback/usetemplate
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import ModalForm from 'core_form/modalform';
import Notification from 'core/notification';
import {get_string as getString} from 'core/str';
const selectors = {
modaltrigger: '[data-action="usetemplate"]',
};
/**
* Initialize module
*/
export const init = () => {
const trigger = document.querySelector(selectors.modaltrigger);
trigger.addEventListener('click', event => {
event.preventDefault();
const modalForm = new ModalForm({
modalConfig: {
title: getString('use_this_template', 'mod_feedback'),
},
formClass: 'mod_feedback\\form\\use_template_form',
args: {
id: trigger.getAttribute('data-dataid'),
templateid: trigger.getAttribute('data-templateid')
},
saveButtonText: getString('save', 'core')
});
// Show a toast notification when the form is submitted.
modalForm.addEventListener(modalForm.events.FORM_SUBMITTED, event => {
if (event.detail.result) {
window.location.assign(event.detail.url);
} else {
Notification.addNotification({
type: 'error',
message: getString('saving_failed', 'mod_feedback')
});
}
});
modalForm.show();
});
};

@ -49,11 +49,9 @@ if (!$feedbackstructure->can_view_analysis()) {
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/// print the tabs
require('tabs.php');
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($feedback->name));
}
//get the groupid
$mygroupid = groups_get_activity_group($cm, true);

@ -71,10 +71,9 @@ $strfeedback = get_string("modulename", "feedback");
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/// print the tabs
require('tabs.php');
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($feedback->name));
}
//get the groupid
//lstgroupid is the choosen id

@ -713,7 +713,7 @@ class mod_feedback_completion extends mod_feedback_structure {
if ($this->form->is_cancelled()) {
// Form was cancelled - return to the course page.
$urltogo = course_get_url($this->courseid ?: $this->feedback->course);
$urltogo = new moodle_url('/mod/feedback/view.php', ['id' => $this->get_cm()->id]);
} else if ($this->form->is_submitted() &&
($this->form->is_validated() || $gopreviouspage)) {
// Form was submitted (skip validation for "Previous page" button).

@ -0,0 +1,115 @@
<?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_feedback\form;
use core_form\dynamic_form;
use moodle_url;
use context;
use context_module;
use context_system;
/**
* Prints the create new template form
*
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
class create_template_form extends dynamic_form {
/**
* Define the form
*/
public function definition() {
$mform =& $this->_form;
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('text',
'templatename',
get_string('name', 'feedback'),
['maxlength' => '200', 'size' => '50']);
$mform->setType('templatename', PARAM_TEXT);
if (has_capability('mod/feedback:createpublictemplate', context_system::instance())) {
$mform->addElement('checkbox',
'ispublic', '',
get_string('public', 'feedback'));
}
}
/**
* Returns context where this form is used
*
* @return context
*/
protected function get_context_for_dynamic_submission(): context {
$id = $this->optional_param('id', null, PARAM_INT);
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
return context_module::instance($cm->id);
}
/**
* Checks if current user has access to this form, otherwise throws exception
*
* @throws \moodle_exception User does not have capability to access the form
*/
protected function check_access_for_dynamic_submission(): void {
$context = $this->get_context_for_dynamic_submission();
if (!has_capability('mod/feedback:edititems', $context) ||
!(has_capability('mod/feedback:createprivatetemplate', $context) ||
has_capability('mod/feedback:createpublictemplate', $context))) {
throw new \moodle_exception('nocapabilitytousethisservice');
}
}
/**
* Process the form submission, used if form was submitted via AJAX
*
* @return array Returns whether a new template was created.
*/
public function process_dynamic_submission(): array {
global $PAGE;
$formdata = $this->get_data();
$ispublic = !empty($formdata->ispublic) ? 1 : 0;
$result = feedback_save_as_template($PAGE->activityrecord, $formdata->templatename, $ispublic);
return [
'result' => $result,
];
}
/**
* Load in existing data as form defaults
*/
public function set_data_for_dynamic_submission(): void {
$this->set_data((object)[
'id' => $this->optional_param('id', null, PARAM_INT),
]);
}
/**
* Returns url to set in $PAGE->set_url() when form is being rendered or submitted via AJAX
*
* @return moodle_url
*/
protected function get_page_url_for_dynamic_submission(): moodle_url {
$params = [
'id' => $this->optional_param('id', null, PARAM_INT),
];
return new moodle_url('/mod/feedback/edit.php', $params);
}
}

@ -0,0 +1,120 @@
<?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_feedback\form;
use core_form\dynamic_form;
use moodle_url;
use context;
use context_module;
/**
* Prints the confirm use template form
*
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
class use_template_form extends dynamic_form {
/**
* Define the form
*/
public function definition() {
$mform =& $this->_form;
$mform->addElement('static', 'generalheader', '', get_string("whatfor", 'feedback'));
$mform->addElement('radio', 'deleteolditems', '', get_string('delete_old_items', 'feedback'), 1);
$mform->addElement('radio', 'deleteolditems', '', get_string('append_new_items', 'feedback'), 0);
$mform->setType('deleteolditems', PARAM_INT);
$mform->setDefault('deleteolditems', 1);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'templateid');
$mform->setType('templateid', PARAM_INT);
}
/**
* Returns context where this form is used
*
* @return context
*/
protected function get_context_for_dynamic_submission(): context {
$id = $this->optional_param('id', null, PARAM_INT);
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
return context_module::instance($cm->id);
}
/**
* Checks if current user has access to this form, otherwise throws exception
*
* @throws \moodle_exception User does not have capability to access the form
*/
protected function check_access_for_dynamic_submission(): void {
if (!has_capability('mod/feedback:edititems', $this->get_context_for_dynamic_submission())) {
throw new \moodle_exception('nocapabilitytousethisservice');
}
}
/**
* Process the form submission, used if form was submitted via AJAX
*
* @return array Returns the following information
* - the template was successfully created/updated from the provided template
* - the redirect url.
*/
public function process_dynamic_submission(): array {
global $PAGE;
$formdata = $this->get_data();
$templateid = $this->optional_param('templateid', null, PARAM_INT);
$id = $this->optional_param('id', null, PARAM_INT);
$response = feedback_items_from_template($PAGE->activityrecord, $templateid, $formdata->deleteolditems);
$url = new moodle_url('/mod/feedback/edit.php', ['id' => $id]);
if ($response !== false) {
// Provide a notification on success as the user will be redirected.
\core\notification::add(get_string('feedbackupdated', 'feedback'), \core\notification::SUCCESS);
}
return [
'result' => $response !== false,
'url' => $url->out()
];
}
/**
* Load in existing data as form defaults
*/
public function set_data_for_dynamic_submission(): void {
$this->set_data((object)[
'id' => $this->optional_param('id', null, PARAM_INT),
'templateid' => $this->optional_param('templateid', null, PARAM_INT)
]);
}
/**
* Returns url to set in $PAGE->set_url() when form is being rendered or submitted via AJAX
*
* @return moodle_url
*/
protected function get_page_url_for_dynamic_submission(): moodle_url {
$params = [
'id' => $this->optional_param('id', null, PARAM_INT),
'templateid' => $this->optional_param('templateid', null, PARAM_INT)
];
return new moodle_url('/mod/feedback/use_templ.php', $params);
}
}

@ -0,0 +1,75 @@
<?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_feedback\local\views;
use core\navigation\views\secondary as core_secondary;
/**
* Custom secondary navigation class
*
* A custom construct of secondary nav for feedback. This rearranges the nodes for the secondary
*
* @package mod_feedback
* @category navigation
* @copyright 2021 onwards Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class secondary extends core_secondary {
protected function get_default_module_mapping(): array {
$basenodes = parent::get_default_module_mapping();
$basenodes[self::TYPE_CUSTOM] += [
'templatenode' => 12,
'mapcourse' => 13,
'feedbackanalysis' => 14,
'responses' => 15,
'nonrespondents' => 15.1
];
return $basenodes;
}
/**
* Custom module construct for feedback
*/
protected function load_module_navigation(): void {
$settingsnav = $this->page->settingsnav;
$mainnode = $settingsnav->find('modulesettings', self::TYPE_SETTING);
$nodes = $this->get_default_module_mapping();
if ($mainnode) {
$url = new \moodle_url('/mod/' . $this->page->activityname . '/view.php', ['id' => $this->page->cm->id]);
$setactive = $url->compare($this->page->url, URL_MATCH_BASE);
$node = $this->add(get_string('modulename', 'feedback'), $url, null, null, 'modulepage');
if ($setactive) {
$node->make_active();
}
// Add the initial nodes.
$nodesordered = $this->get_leaf_nodes($mainnode, $nodes);
$this->add_ordered_nodes($nodesordered);
// Reorder the existing nodes in settings so the active node scan can pick it up.
$existingnode = $settingsnav->find('questionnode', self::TYPE_CUSTOM);
if ($existingnode) {
$node->add_node($existingnode);
$nodes[self::TYPE_CUSTOM] += ['questionnode' => 3];
}
// We have finished inserting the initial structure.
// Populate the menu with the rest of the nodes available.
$this->load_remaining_nodes($mainnode, $nodes);
}
}
}

@ -0,0 +1,101 @@
<?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_feedback\output;
use context_module;
use renderable;
use renderer_base;
use templatable;
/**
* Class base_action_bar
*
* Base class to be inherited by any other feedback action bar
*
* @package mod_feedback
* @copyright 2021 onwards Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class base_action_bar implements renderable, templatable {
/** @var int $cmid The module id */
protected $cmid;
/** @var object $context The context we are in */
protected $context;
/** @var object $course The course we are in */
protected $course;
/** @var array $urlparams The default params to be used when creating urls */
protected $urlparams;
/** @var object $feedback The activity record that is being viewed */
protected $feedback;
/**
* base_action_bar constructor.
*
* @param int $cmid
*/
public function __construct(int $cmid) {
global $PAGE;
$this->cmid = $cmid;
$this->context = context_module::instance($cmid);
[$course, $cm] = get_course_and_cm_from_cmid($cmid);
$this->course = $course;
$this->urlparams = [
'id' => $cmid
];
$this->feedback = $PAGE->activityrecord;
}
/**
* Recursively iterates through to array of renderables and exports
*
* @param array $items Collection of renderables
* @param renderer_base $output
* @return array $items Data to be used in the mustache template
*/
private function export_items_for_template(array $items, renderer_base $output): array {
$items = array_map(function($item) use ($output) {
if (is_array($item)) {
return $this->export_items_for_template($item, $output);
}
if (is_object($item) && method_exists($item, 'export_for_template')) {
return $item->export_for_template($output);
}
return $item;
}, $items);
return $items;
}
/**
* Export the data so it can be used as the context for a mustache template.
*
* @param renderer_base $output
* @return array
*/
public function export_for_template(renderer_base $output): array {
$items = $this->export_items_for_template($this->get_items(), $output);
return $items;
}
/**
* Function to generate a list of renderables to be displayed
* @return array
*/
abstract protected function get_items(): array;
}

@ -0,0 +1,96 @@
<?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_feedback\output;
use moodle_url;
use action_link;
use single_select;
use url_select;
/**
* Class actionbar - Display the action bar
*
* @package mod_feedback
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_action_bar extends base_action_bar {
/** @var moodle_url $currenturl The current page url */
private $currenturl;
/** @var int|null $lastposition The index of the last question type in the feedback module */
private $lastposition;
/**
* edit_action_bar constructor.
*
* @param int $cmid The course module id
* @param moodle_url $pageurl The current page url
* @param int|null $lastposition Index of the last question in the feedback
*/
public function __construct(int $cmid, moodle_url $pageurl, ?int $lastposition = null) {
parent::__construct($cmid);
$this->currenturl = $pageurl;
$this->lastposition = $lastposition;
}
/**
* Return the items to be used for the tertiary nav
*
* @return array
*/
public function get_items(): array {
$url = new moodle_url('/mod/feedback/view.php', ['id' => $this->cmid]);
$items['left'][]['actionlink'] = new action_link($url, get_string('back'), null, ['class' => 'btn btn-secondary']);
if (has_capability('mod/feedback:edititems', $this->context)) {
$editurl = new moodle_url('/mod/feedback/edit.php', $this->urlparams);
$templateurl = new moodle_url('/mod/feedback/manage_templates.php', $this->urlparams);
$importurl = new moodle_url('/mod/feedback/import.php', $this->urlparams);
$options = [
$editurl->out(false) => get_string('add_item', 'feedback'),
$templateurl->out(false) => get_string('using_templates', 'feedback'),
$importurl->out(false) => get_string('import_questions', 'feedback')
];
$selected = $this->currenturl;
// Template pages can have sub pages, so match these.
if ($this->currenturl->compare(new moodle_url('/mod/feedback/use_templ.php'), URL_MATCH_BASE)) {
$selected = $templateurl;
}
$items['left'][]['urlselect'] = new url_select($options, $selected->out(false), null);
$viewquestions = $editurl->compare($this->currenturl);
if ($viewquestions) {
$select = new single_select(new moodle_url('/mod/feedback/edit_item.php',
['cmid' => $this->cmid, 'position' => $this->lastposition, 'sesskey' => sesskey()]),
'typ', feedback_load_feedback_items_options());
$items['left'][]['singleselect'] = $select;
$exporturl = new moodle_url('/mod/feedback/export.php', $this->urlparams + ['action' => 'exportfile']);
$items['export'] = new action_link(
$exporturl,
get_string('export_questions', 'feedback'),
null,
['class' => 'btn btn-secondary']);
}
}
return $items;
}
}

@ -0,0 +1,86 @@
<?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_feedback\output;
use confirm_action;
use context_system;
use moodle_url;
use action_link;
/**
* Class actionbar - Display the action bar
*
* @package mod_feedback
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_template_action_bar extends base_action_bar {
/** @var int $templateid The template that is being edited/used */
private $templateid;
/** @var string $mode The type of view we are dealing with */
private $mode;
/**
* edit_template_action_bar constructor.
* @param int $cmid
* @param int $templateid
* @param string $mode
*/
public function __construct(int $cmid, int $templateid, string $mode) {
parent::__construct($cmid);
$this->templateid = $templateid;
$this->mode = $mode;
}
/**
* Return the items to be used in the tertiary nav
*
* @return array
*/
public function get_items(): array {
global $DB;
$additionalparams = ($this->mode ? ['mode' => $this->mode] : []);
$templateurl = new moodle_url('/mod/feedback/manage_templates.php', $this->urlparams + $additionalparams);
$items['left'][]['actionlink'] = new action_link($templateurl, get_string('back'), null, ['class' => 'btn btn-secondary']);
if (has_capability('mod/feedback:edititems', $this->context)) {
$items['usetemplate'] = $this->urlparams + [
'templateid' => $this->templateid
];
}
$template = $DB->get_record('feedback_template', array('id' => $this->templateid), '*', MUST_EXIST);
$systemcontext = context_system::instance();
$showdelete = has_capability('mod/feedback:deletetemplate', $this->context);
if ($template->ispublic) {
$showdelete = has_capability('mod/feedback:createpublictemplate', $systemcontext) &&
has_capability('mod/feedback:deletetemplate', $systemcontext);
}
if ($showdelete) {
$params = $this->urlparams + $additionalparams + [
'deletetemplate' => $this->templateid,
'sesskey' => sesskey()
];
$deleteurl = new moodle_url('/mod/feedback/manage_templates.php', $params);
$deleteaction = new confirm_action(get_string('confirmdeletetemplate', 'feedback'));
$items['export'] = new action_link($deleteurl, get_string('delete'), $deleteaction, ['class' => 'btn btn-secondary']);
}
return $items;
}
}

@ -0,0 +1,50 @@
<?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_feedback\output;
use plugin_renderer_base;
/**
* Class renderer
*
* @package mod_feedback
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends plugin_renderer_base {
/**
* Generate the tertiary nav
*
* @param base_action_bar $actionmenu
* @return bool|string
*/
public function main_action_bar(base_action_bar $actionmenu) {
$context = $actionmenu->export_for_template($this);
return $this->render_from_template('mod_feedback/main_action_menu', $context);
}
/**
* Render the create template form
*
* @param int $id
* @return bool|string
*/
public function create_template_form(int $id) {
return $this->render_from_template('mod_feedback/create_template', ['id' => $id]);
}
}

@ -0,0 +1,72 @@
<?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_feedback\output;
use moodle_url;
use url_select;
/**
* Class responses_action_bar. The tertiary nav for the responses page
*
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
class responses_action_bar extends base_action_bar {
/** @var moodle_url $currenturl The current page url */
private $currenturl;
/**
* responses_action_bar constructor.
*
* @param int $cmid The cmid for the module we are operating on
* @param moodle_url $pageurl The current page url
*/
public function __construct(int $cmid, moodle_url $pageurl) {
parent::__construct($cmid);
$this->currenturl = $pageurl;
$this->urlparams['courseid'] = $this->course->id;
}
/**
* Return the items to be used in the tertiary nav
*
* @return array
*/
public function get_items(): array {
$items = [];
if (has_capability('mod/feedback:viewreports', $this->context)) {
$reporturl = new moodle_url('/mod/feedback/show_entries.php', $this->urlparams);
$options[$reporturl->out(false)] = get_string('show_entries', 'feedback');
$selected = $this->currenturl->compare($reporturl, URL_MATCH_BASE) ? $reporturl : $this->currenturl;
if ($this->feedback->anonymous == FEEDBACK_ANONYMOUS_NO && $this->course != SITEID) {
$nonrespondenturl = new moodle_url('/mod/feedback/show_nonrespondents.php', $this->urlparams);
$options[$nonrespondenturl->out(false)] = get_string('show_nonrespondents', 'feedback');
$selected = $this->currenturl->compare($nonrespondenturl, URL_MATCH_BASE) ? $nonrespondenturl : $this->currenturl;;
}
// Don't show the dropdown if it's only a single item.
if (count($options) != 1) {
$items['left'][]['urlselect'] = new url_select($options,
$selected->out(false),
null);
}
}
return $items;
}
}

@ -0,0 +1,92 @@
<?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_feedback\output;
use action_link;
use moodle_url;
/**
* Class standard_action_bar
*
* The default tertiary nav on the module landing page
*
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
class standard_action_bar extends base_action_bar {
/** @var int $startpage The page to resume with. */
private $startpage;
/** @var int $viewcompletion Whether or not the user can finish the feedback */
private $viewcompletion;
/**
* standard_action_bar constructor.
*
* @param int $cmid
* @param bool $viewcompletion Whether or not the user can finish the feedback
* @param int|null $startpage The page to resume with.
* @param int|null $courseid The course that the feedback is being accessed from. If null, courseid will be
* set via the $cmid relationship
*/
public function __construct(int $cmid, bool $viewcompletion, ?int $startpage = null, ?int $courseid = null) {
parent::__construct($cmid);
$this->startpage = $startpage;
$this->viewcompletion = $viewcompletion;
if ($courseid && $courseid != $this->course->id) {
$this->course = get_course($courseid);
}
$this->urlparams['courseid'] = $this->course->id;
}
/**
* Return the items to be used in the tertiary nav
*
* @return array
*/
public function get_items(): array {
$items = [];
if (has_capability('mod/feedback:edititems', $this->context)) {
$editurl = new moodle_url('/mod/feedback/edit.php', $this->urlparams);
$items['left'][]['actionlink'] = new action_link($editurl, get_string('edit_items', 'feedback'),
null, ['class' => 'btn btn-secondary']);
}
$previewlnk = new moodle_url('/mod/feedback/print.php', array('id' => $this->cmid));
if ($this->course->id) {
$previewlnk->param('courseid', $this->course->id);
}
$items['left'][]['actionlink'] = new action_link($previewlnk, get_string('previewquestions', 'feedback'),
null, ['class' => 'btn btn-secondary']);
if ($this->viewcompletion) {
// Display a link to complete feedback or resume.
$completeurl = new moodle_url('/mod/feedback/complete.php',
['id' => $this->cmid, 'courseid' => $this->course->id]);
if ($this->startpage) {
$completeurl->param('gopage', $this->startpage);
$label = get_string('continue_the_form', 'feedback');
} else {
$label = get_string('complete_the_form', 'feedback');
}
$items['left'][]['actionlink'] = new action_link($completeurl, $label, null, ['class' => 'btn btn-secondary']);
}
return $items;
}
}

@ -35,17 +35,24 @@ require_once($CFG->libdir . '/tablelib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_feedback_templates_table extends flexible_table {
/** @var string|null Indicate whether we are managing template or not. */
private $mode;
/**
* Constructor
* @param int $uniqueid all tables have to have a unique id, this is used
* as a key when storing table properties like sort order in the session.
* @param moodle_url $baseurl
* @param string $mode Indicate whether we are managing templates
*/
public function __construct($uniqueid, $baseurl) {
public function __construct($uniqueid, $baseurl, ?string $mode = null) {
parent::__construct($uniqueid);
$this->mode = $mode;
$tablecolumns = array('template');
if ($this->mode) {
$tablecolumns[] = 'actions';
}
$tablecolumns = array('template', 'action');
$tableheaders = array(get_string('template', 'feedback'), '');
$this->set_attribute('class', 'templateslist');
@ -54,8 +61,7 @@ class mod_feedback_templates_table extends flexible_table {
$this->define_headers($tableheaders);
$this->define_baseurl($baseurl);
$this->column_class('template', 'template');
$this->column_class('action', 'action');
$this->column_class('actions', 'text-right');
$this->sortable(false);
}
@ -75,12 +81,26 @@ class mod_feedback_templates_table extends flexible_table {
$strdeletefeedback = get_string('delete_template', 'feedback');
foreach ($templates as $template) {
$data = array();
$data[] = format_string($template->name);
$url = new moodle_url($this->baseurl, array('deletetempl' => $template->id, 'sesskey' => sesskey()));
$data = [];
$url = new moodle_url($this->baseurl, array('templateid' => $template->id, 'sesskey' => sesskey()));
$data[] = $OUTPUT->action_link($url, format_string($template->name));
// Only show the actions if we are managing templates.
if ($this->mode && has_capability('mod/feedback:deletetemplate', $this->get_context())) {
$deleteurl = new moodle_url('/mod/feedback/manage_templates.php',
$url->params() + ['deletetemplate' => $template->id]);
$deleteaction = new confirm_action(get_string('confirmdeletetemplate', 'feedback'));
$deleteicon = $OUTPUT->action_icon($deleteurl, new pix_icon('t/delete', $strdeletefeedback), $deleteaction);
if ($template->ispublic) {
$systemcontext = context_system::instance();
if (!(has_capability('mod/feedback:createpublictemplate', $systemcontext) &&
has_capability('mod/feedback:deletetemplate', $systemcontext))) {
$deleteicon = false;
}
}
$data[] = $deleteicon;
}
$deleteaction = new confirm_action(get_string('confirmdeletetemplate', 'feedback'));
$data[] = $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdeletefeedback), $deleteaction);
$this->add_data($data);
}
$this->finish_output();

@ -68,11 +68,14 @@ $PAGE->navbar->add(get_string('feedback:complete', 'feedback'));
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
$PAGE->set_pagelayout('incourse');
$PAGE->set_secondary_active_tab('modulepage');
// Check if the feedback is open (timeopen, timeclose).
if (!$feedbackcompletion->is_open()) {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($feedback->name));
}
echo $OUTPUT->box_start('generalbox boxaligncenter');
echo $OUTPUT->notification(get_string('feedback_is_not_open', 'feedback'));
echo $OUTPUT->continue_button(course_get_url($courseid ?: $feedback->course));
@ -104,7 +107,9 @@ $strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($feedback->name));
}
if ($feedbackcompletion->is_empty()) {
\core\notification::error(get_string('no_items_available_yet', 'feedback'));
@ -115,7 +120,7 @@ if ($feedbackcompletion->is_empty()) {
echo $OUTPUT->box($feedbackcompletion->page_after_submit(),
'generalbox boxaligncenter');
}
if ($feedbackcompletion->can_view_analysis()) {
if (!$PAGE->has_secondary_navigation() && $feedbackcompletion->can_view_analysis()) {
echo '<p align="center">';
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $cm->id, 'courseid' => $courseid));
echo html_writer::link($analysisurl, get_string('completed_feedbacks', 'feedback'));

@ -24,7 +24,6 @@
require_once('../../config.php');
require_once('lib.php');
require_once('edit_form.php');
feedback_init_feedback_session();
@ -34,14 +33,9 @@ if (($formdata = data_submitted()) AND !confirm_sesskey()) {
print_error('invalidsesskey');
}
$do_show = optional_param('do_show', 'edit', PARAM_ALPHA);
$switchitemrequired = optional_param('switchitemrequired', false, PARAM_INT);
$deleteitem = optional_param('deleteitem', false, PARAM_INT);
$current_tab = $do_show;
$url = new moodle_url('/mod/feedback/edit.php', array('id'=>$id, 'do_show'=>$do_show));
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
$context = context_module::instance($cm->id);
@ -49,6 +43,7 @@ require_login($course, false, $cm);
require_capability('mod/feedback:edititems', $context);
$feedback = $PAGE->activityrecord;
$feedbackstructure = new mod_feedback_structure($feedback, $cm);
$url = new moodle_url('/mod/feedback/edit.php', ['id' => $cm->id]);
if ($switchitemrequired) {
require_sesskey();
@ -71,19 +66,6 @@ if ($deleteitem) {
// Process the create template form.
$cancreatetemplates = has_capability('mod/feedback:createprivatetemplate', $context) ||
has_capability('mod/feedback:createpublictemplate', $context);
$create_template_form = new feedback_edit_create_template_form(null, array('id' => $id));
if ($data = $create_template_form->get_data()) {
// Check the capabilities to create templates.
if (!$cancreatetemplates) {
print_error('cannotsavetempl', 'feedback', $url);
}
$ispublic = !empty($data->ispublic) ? 1 : 0;
if (!feedback_save_as_template($feedback, $data->templatename, $ispublic)) {
redirect($url, get_string('saving_failed', 'feedback'), null, \core\output\notification::NOTIFY_ERROR);
} else {
redirect($url, get_string('template_saved', 'feedback'), null, \core\output\notification::NOTIFY_SUCCESS);
}
}
//Get the feedbackitems
$lastposition = 0;
@ -99,79 +81,34 @@ if (is_array($feedbackitems)) {
}
$lastposition++;
//The use_template-form
$use_template_form = new feedback_edit_use_template_form('use_templ.php', array('course' => $course, 'id' => $id));
//Print the page header.
$strfeedbacks = get_string('modulenameplural', 'feedback');
$strfeedback = get_string('modulename', 'feedback');
$PAGE->set_url('/mod/feedback/edit.php', array('id'=>$cm->id, 'do_show'=>$do_show));
$PAGE->set_url($url);
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
$actionbar = new \mod_feedback\output\edit_action_bar($cm->id, $url, $lastposition);
//Adding the javascript module for the items dragdrop.
if (count($feedbackitems) > 1) {
if ($do_show == 'edit') {
$PAGE->requires->strings_for_js(array(
'pluginname',
'move_item',
'position',
), 'feedback');
$PAGE->requires->yui_module('moodle-mod_feedback-dragdrop', 'M.mod_feedback.init_dragdrop',
array(array('cmid' => $cm->id)));
}
$PAGE->requires->strings_for_js(array(
'pluginname',
'move_item',
'position',
), 'feedback');
$PAGE->requires->yui_module('moodle-mod_feedback-dragdrop', 'M.mod_feedback.init_dragdrop',
array(array('cmid' => $cm->id)));
}
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
echo $renderer->main_action_bar($actionbar);
$form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_EDIT,
$feedbackstructure, 'feedback_edit_form');
echo '<div id="feedback_dragarea">'; // The container for the dragging area.
$form->display();
echo '</div>';
/// print the tabs
require('tabs.php');
// Print the main part of the page.
if ($do_show == 'templates') {
// Print the template-section.
$use_template_form->display();
if ($cancreatetemplates) {
$deleteurl = new moodle_url('/mod/feedback/delete_template.php', array('id' => $id));
$create_template_form->display();
echo '<p><a href="'.$deleteurl->out().'">'.
get_string('delete_templates', 'feedback').
'</a></p>';
} else {
echo '&nbsp;';
}
if (has_capability('mod/feedback:edititems', $context)) {
$urlparams = array('action'=>'exportfile', 'id'=>$id);
$exporturl = new moodle_url('/mod/feedback/export.php', $urlparams);
$importurl = new moodle_url('/mod/feedback/import.php', array('id'=>$id));
echo '<p>
<a href="'.$exporturl->out().'">'.get_string('export_questions', 'feedback').'</a>/
<a href="'.$importurl->out().'">'.get_string('import_questions', 'feedback').'</a>
</p>';
}
}
if ($do_show == 'edit') {
// Print the Item-Edit-section.
$select = new single_select(new moodle_url('/mod/feedback/edit_item.php',
array('cmid' => $id, 'position' => $lastposition, 'sesskey' => sesskey())),
'typ', feedback_load_feedback_items_options());
$select->label = get_string('add_item', 'mod_feedback');
echo $OUTPUT->render($select);
$form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_EDIT,
$feedbackstructure, 'feedback_edit_form');
echo '<div id="feedback_dragarea">'; // The container for the dragging area.
$form->display();
echo '</div>';
if ($cancreatetemplates) {
echo $renderer->create_template_form($id);
}
echo $OUTPUT->footer();

@ -29,7 +29,71 @@ if (!defined('MOODLE_INTERNAL')) {
require_once($CFG->libdir.'/formslib.php');
/**
* The feedback_edit_use_template_form
*
* @deprecated since 4.0 new dynamic forms created
*/
class feedback_edit_use_template_form extends moodleform {
public function __construct($action = null, $customdata = null, $method = 'post', $target = '',
$attributes = null, $editable = true, $ajaxformdata = null) {
debugging('Class feedback_edit_use_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
parent::__construct($action, $customdata, $method, $target, $attributes, $editable, $ajaxformdata);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @return array
*/
public static function get_js_module() {
debugging('Class feedback_edit_use_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::get_js_module();
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $simulatedsubmitteddata
* @param array $simulatedsubmittedfiles
* @param string $method
* @param null $formidentifier
* @return array
*/
public static function mock_ajax_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(),
$method = 'post', $formidentifier = null) {
debugging('Class feedback_edit_use_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::mock_ajax_submit($simulatedsubmitteddata, $simulatedsubmittedfiles, $method, $formidentifier);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $data
* @return array
*/
public static function mock_generate_submit_keys($data = []) {
debugging('Class feedback_edit_use_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::mock_generate_submit_keys($data);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $simulatedsubmitteddata
* @param array $simulatedsubmittedfiles
* @param string $method
* @param null $formidentifier
*/
public static function mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(),
$method = 'post', $formidentifier = null) {
debugging('Class feedback_edit_use_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
parent::mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles, $method, $formidentifier);
}
/**
* Form definition
@ -97,7 +161,71 @@ class feedback_edit_use_template_form extends moodleform {
}
}
/**
* The feedback_edit_create_template_form
*
* @deprecated since 4.0, new dynamic forms have been created instead.
*/
class feedback_edit_create_template_form extends moodleform {
public function __construct($action = null, $customdata = null, $method = 'post',
$target = '', $attributes = null, $editable = true, $ajaxformdata = null) {
debugging('Class feedback_edit_create_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
parent::__construct($action, $customdata, $method, $target, $attributes, $editable, $ajaxformdata);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @return array
*/
public static function get_js_module() {
debugging('Class feedback_edit_create_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::get_js_module();
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $simulatedsubmitteddata
* @param array $simulatedsubmittedfiles
* @param string $method
* @param null $formidentifier
* @return array
*/
public static function mock_ajax_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(),
$method = 'post', $formidentifier = null) {
debugging('Class feedback_edit_create_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::mock_ajax_submit($simulatedsubmitteddata, $simulatedsubmittedfiles, $method, $formidentifier);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $data
* @return array
*/
public static function mock_generate_submit_keys($data = []) {
debugging('Class feedback_edit_create_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::mock_generate_submit_keys($data);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $simulatedsubmitteddata
* @param array $simulatedsubmittedfiles
* @param string $method
* @param null $formidentifier
*/
public static function mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(),
$method = 'post', $formidentifier = null) {
debugging('Class feedback_edit_create_template_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
parent::mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles, $method, $formidentifier);
}
/**
* Form definition
@ -110,10 +238,7 @@ class feedback_edit_create_template_form extends moodleform {
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'do_show');
$mform->setType('do_show', PARAM_ALPHANUMEXT);
$mform->setConstant('do_show', 'templates');
//headline
$mform->addElement('header', 'creating_templates', get_string('creating_templates', 'feedback'));
$mform->setConstant('do_show', 'edit');
// visible elements
$elementgroup = array();
@ -121,7 +246,7 @@ class feedback_edit_create_template_form extends moodleform {
$elementgroup[] = $mform->createElement('text',
'templatename',
get_string('name', 'feedback'),
array('size'=>'40', 'maxlength'=>'200'));
['maxlength' => '200']);
if (has_capability('mod/feedback:createpublictemplate', context_system::instance())) {
$elementgroup[] = $mform->createElement('checkbox',

@ -101,13 +101,14 @@ $PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
if (!$PAGE->has_secondary_navigation()) {
// Print the main part of the page.
echo $OUTPUT->heading(format_string($feedback->name));
echo $OUTPUT->heading(format_string($feedback->name));
}
/// print the tabs
$current_tab = 'edit';
$id = $cm->id;
require('tabs.php');
//print errormsg
if (isset($error)) {

@ -57,6 +57,7 @@ $context = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/feedback:edititems', $context);
$actionbar = new \mod_feedback\output\edit_action_bar($cm->id, $url);
$mform = new feedback_import_form();
$newformdata = array('id'=>$id,
@ -95,16 +96,20 @@ $strfeedback = get_string("modulename", "feedback");
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/// print the tabs
$current_tab = 'templates';
require('tabs.php');
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
echo $renderer->main_action_bar($actionbar);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($feedback->name));
}
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
echo $OUTPUT->heading(get_string('import_questions', 'feedback'), 3);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(get_string('import_questions', 'feedback'), 3);
}
if (isset($importerror->msg) AND is_array($importerror->msg)) {
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter');

@ -40,9 +40,6 @@ class feedback_import_form extends moodleform {
$strnodeleteolditmes = get_string('append_new_items', 'feedback').
' ('.get_string('oldvaluespreserved', 'feedback').')';
$mform->addElement('radio', 'deleteolditems', '', $strdeleteolditmes, true);
$mform->addElement('radio', 'deleteolditems', '', $strnodeleteolditmes);
// hidden elements
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
@ -52,8 +49,11 @@ class feedback_import_form extends moodleform {
null,
array('maxbytes' => $CFG->maxbytes, 'filetypes' => '*'));
$mform->addElement('radio', 'deleteolditems', '', $strdeleteolditmes, true);
$mform->addElement('radio', 'deleteolditems', '', $strnodeleteolditmes);
// buttons
$this->add_action_buttons(true, get_string('yes'));
$this->add_action_buttons(false, get_string('save'));
}
}

@ -53,7 +53,9 @@ $PAGE->navbar->add($strfeedbacks);
$PAGE->set_heading($course->fullname);
$PAGE->set_title(get_string('modulename', 'feedback').' '.get_string('activities'));
echo $OUTPUT->header();
echo $OUTPUT->heading($strfeedbacks);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($strfeedbacks);
}
/// Get all the appropriate data

@ -102,7 +102,7 @@ abstract class feedback_item_form extends moodleform {
$mform->setType('clone_item', PARAM_INT);
$buttonarray[] = &$mform->createElement('submit',
'save_item',
get_string('save_item', 'feedback'));
get_string('savechanges'));
}
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);

@ -126,6 +126,7 @@ $string['feedback:receivemail'] = 'Receive email notification';
$string['feedback:view'] = 'View a feedback';
$string['feedback:viewanalysepage'] = 'View the analysis page after submit';
$string['feedback:viewreports'] = 'View reports';
$string['feedbackupdated'] = 'Feedback updated.';
$string['file'] = 'File';
$string['filter_by_course'] = 'Filter by course';
$string['handling_error'] = 'Error occurred in feedback module action handling';
@ -227,6 +228,7 @@ $string['pluginadministration'] = 'Feedback administration';
$string['pluginname'] = 'Feedback';
$string['position'] = 'Position';
$string['previous_page'] = 'Previous page';
$string['previewquestions'] = 'Preview questions';
$string['privacy:metadata:completed'] = 'A record of the submissions to the feedback';
$string['privacy:metadata:completed:anonymousresponse'] = 'Whether the submission is to be used anonymously.';
$string['privacy:metadata:completed:timemodified'] = 'The time when the submission was last modified.';
@ -293,3 +295,4 @@ $string['use_one_line_for_each_value'] = 'Use one line for each answer!';
$string['use_this_template'] = 'Use this template';
$string['using_templates'] = 'Use a template';
$string['vertical'] = 'Vertical';
$string['whatfor'] = 'What do you want to do?';

@ -2801,17 +2801,17 @@ function feedback_extend_settings_navigation(settings_navigation $settings,
global $PAGE;
$hassecondary = $PAGE->has_secondary_navigation();
if (!$context = context_module::instance($PAGE->cm->id, IGNORE_MISSING)) {
print_error('badcontext');
}
if (has_capability('mod/feedback:edititems', $context)) {
$questionnode = $feedbacknode->add(get_string('questions', 'feedback'));
$questionnode = $feedbacknode->add(get_string('questions', 'feedback'), null,
navigation_node::TYPE_CUSTOM, null, 'questionnode');
$questionnode->add(get_string('edit_items', 'feedback'),
new moodle_url('/mod/feedback/edit.php',
array('id' => $PAGE->cm->id,
'do_show' => 'edit')));
['id' => $PAGE->cm->id]));
$questionnode->add(get_string('export_questions', 'feedback'),
new moodle_url('/mod/feedback/export.php',
@ -2822,38 +2822,43 @@ function feedback_extend_settings_navigation(settings_navigation $settings,
new moodle_url('/mod/feedback/import.php',
array('id' => $PAGE->cm->id)));
$questionnode->add(get_string('templates', 'feedback'),
new moodle_url('/mod/feedback/edit.php',
array('id' => $PAGE->cm->id,
'do_show' => 'templates')));
$feedbacknode->add(get_string('templates', 'feedback'),
new moodle_url('/mod/feedback/manage_templates.php', ['id' => $PAGE->cm->id, 'mode' => 'manage']),
navigation_node::TYPE_CUSTOM, null, 'templatenode');
}
if (has_capability('mod/feedback:mapcourse', $context) && $PAGE->course->id == SITEID) {
$feedbacknode->add(get_string('mappedcourses', 'feedback'),
new moodle_url('/mod/feedback/mapcourse.php',
array('id' => $PAGE->cm->id)));
new moodle_url('/mod/feedback/mapcourse.php', ['id' => $PAGE->cm->id]),
navigation_node::TYPE_CUSTOM, null, 'mapcourse');
}
$feedback = $PAGE->activityrecord;
if ($feedback->course == SITEID) {
$analysisnode = navigation_node::create(get_string('analysis', 'feedback'),
new moodle_url('/mod/feedback/analysis_course.php', ['id' => $PAGE->cm->id]),
navigation_node::TYPE_CUSTOM, null, 'feedbackanalysis');
} else {
$analysisnode = navigation_node::create(get_string('analysis', 'feedback'),
new moodle_url('/mod/feedback/analysis.php', ['id' => $PAGE->cm->id]),
navigation_node::TYPE_CUSTOM, null, 'feedbackanalysis');
}
if (has_capability('mod/feedback:viewreports', $context)) {
$feedback = $PAGE->activityrecord;
if ($feedback->course == SITEID) {
$feedbacknode->add(get_string('analysis', 'feedback'),
new moodle_url('/mod/feedback/analysis_course.php',
array('id' => $PAGE->cm->id)));
} else {
$feedbacknode->add(get_string('analysis', 'feedback'),
new moodle_url('/mod/feedback/analysis.php',
array('id' => $PAGE->cm->id)));
}
$feedbacknode->add(get_string('show_entries', 'feedback'),
new moodle_url('/mod/feedback/show_entries.php',
array('id' => $PAGE->cm->id)));
$feedbacknode->add_node($analysisnode);
$feedbacknode->add(get_string(($hassecondary ? 'responses' : 'show_entries'), 'feedback'),
new moodle_url('/mod/feedback/show_entries.php', ['id' => $PAGE->cm->id]),
navigation_node::TYPE_CUSTOM, null, 'responses');
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO AND $feedback->course != SITEID) {
$feedbacknode->add(get_string('show_nonrespondents', 'feedback'),
new moodle_url('/mod/feedback/show_nonrespondents.php',
array('id' => $PAGE->cm->id)));
new moodle_url('/mod/feedback/show_nonrespondents.php', ['id' => $PAGE->cm->id]),
navigation_node::TYPE_CUSTOM, null, 'nonrespondents');
}
} else {
$feedbackcompletion = new mod_feedback_completion($feedback, $context, $PAGE->course->id);
if ($feedbackcompletion->can_view_analysis()) {
$feedbacknode->add_node($analysisnode);
}
}
}

@ -15,9 +15,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* deletes a template
* Manage the various templates available
*
* @author Andreas Grabs
* @author Peter Dias
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
@ -25,27 +26,41 @@
require_once("../../config.php");
require_once("lib.php");
$current_tab = 'templates';
$id = required_param('id', PARAM_INT);
$deletetempl = optional_param('deletetempl', false, PARAM_INT);
$baseurl = new moodle_url('/mod/feedback/delete_template.php', array('id' => $id));
$PAGE->set_url($baseurl);
$mode = optional_param('mode', '', PARAM_ALPHA);
$templateid = optional_param('deletetemplate', 0, PARAM_INT);
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/feedback:deletetemplate', $context);
require_capability('mod/feedback:edititems', $context);
$feedback = $PAGE->activityrecord;
$systemcontext = context_system::instance();
$params = ['id' => $id];
if ($mode) {
$params += ['mode' => $mode];
}
$url = new moodle_url('/mod/feedback/manage_templates.php', $params);
if ($mode == 'manage') {
navigation_node::override_active_url($url);
} else {
navigation_node::override_active_url(new moodle_url('/mod/feedback/view.php', $params));
}
$PAGE->set_url($url);
$actionbar = new \mod_feedback\output\edit_action_bar($cm->id, $url);
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
// Process template deletion.
if ($deletetempl) {
if ($templateid) {
require_sesskey();
$template = $DB->get_record('feedback_template', array('id' => $deletetempl), '*', MUST_EXIST);
require_capability('mod/feedback:deletetemplate', $context);
$template = $DB->get_record('feedback_template', ['id' => $templateid], '*', MUST_EXIST);
if ($template->ispublic) {
require_capability('mod/feedback:createpublictemplate', $systemcontext);
@ -53,46 +68,31 @@ if ($deletetempl) {
}
feedback_delete_template($template);
redirect($baseurl, get_string('template_deleted', 'feedback'));
$successurl = new moodle_url('/mod/feedback/manage_templates.php', ['id' => $id]);
redirect($url, get_string('template_deleted', 'feedback'), null, \core\output\notification::NOTIFY_SUCCESS);
}
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
$strdeletefeedback = get_string('delete_template', 'feedback');
navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php',
array('id' => $id, 'do_show' => 'templates')));
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/// print the tabs
require('tabs.php');
// Print the main part of the page.
echo $OUTPUT->heading($strdeletefeedback, 3);
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
if (!$mode) {
echo $renderer->main_action_bar($actionbar);
}
// First we get the course templates.
$templates = feedback_get_template_list($course, 'own');
echo $OUTPUT->box_start('coursetemplates');
echo $OUTPUT->heading(get_string('course'), 4);
$tablecourse = new mod_feedback_templates_table('feedback_template_course_table', $baseurl);
$baseurl = new moodle_url('/mod/feedback/use_templ.php', $params);
$tablecourse = new mod_feedback_templates_table('feedback_template_course_table', $baseurl, $mode);
$tablecourse->display($templates);
echo $OUTPUT->box_end();
// Now we get the public templates if it is permitted.
if (has_capability('mod/feedback:createpublictemplate', $systemcontext) AND
has_capability('mod/feedback:deletetemplate', $systemcontext)) {
$templates = feedback_get_template_list($course, 'public');
echo $OUTPUT->box_start('publictemplates');
echo $OUTPUT->heading(get_string('public', 'feedback'), 4);
$tablepublic = new mod_feedback_templates_table('feedback_template_public_table', $baseurl);
$tablepublic->display($templates);
echo $OUTPUT->box_end();
}
$url = new moodle_url('/mod/feedback/edit.php', array('id' => $id, 'do_show' => 'templates'));
echo $OUTPUT->single_button($url, get_string('back'), 'post');
$templates = feedback_get_template_list($course, 'public');
echo $OUTPUT->box_start('publictemplates');
echo $OUTPUT->heading(get_string('public', 'feedback'), 4);
$tablepublic = new mod_feedback_templates_table('feedback_template_public_table', $baseurl, $mode);
$tablepublic->display($templates);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();

@ -58,10 +58,9 @@ $strfeedback = get_string("modulename", "feedback");
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
require('tabs.php');
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($feedback->name));
}
echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'));
$form->display();

@ -43,7 +43,6 @@ list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
$baseurl = new moodle_url('/mod/feedback/show_entries.php', array('id' => $cm->id));
$PAGE->set_url(new moodle_url($baseurl, array('userid' => $userid, 'showcompleted' => $showcompleted,
'delete' => $deleteid)));
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
@ -51,6 +50,8 @@ $feedback = $PAGE->activityrecord;
require_capability('mod/feedback:viewreports', $context);
$actionbar = new \mod_feedback\output\responses_action_bar($cm->id, $baseurl);
if ($deleteid) {
// This is a request to delete a reponse.
require_capability('mod/feedback:deletesubmissions', $context);
@ -86,10 +87,12 @@ navigation_node::override_active_url($baseurl);
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
echo $renderer->main_action_bar($actionbar);
$current_tab = 'showentries';
require('tabs.php');
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////

@ -70,6 +70,8 @@ $coursecontext = context_course::instance($course->id);
require_login($course, true, $cm);
$actionbar = new \mod_feedback\output\responses_action_bar($cm->id, $url);
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
print_error('invalidsesskey');
}
@ -136,9 +138,10 @@ if ($action == 'sendmessage' AND $canbulkmessaging) {
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
require('tabs.php');
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
echo $renderer->main_action_bar($actionbar);
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////

@ -0,0 +1,35 @@
{{!
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/>.
}}
{{!
@template mod_feedback/create_template
Trigger button for the create template modal form.
Classes required for JS:
* none
Data attributes required for JS:
* All data attributes are required
Context variables required for this template:
* id - The feedback id.
Example context (json):
{
"id": 1
}
}}
<button type="button" class="btn btn-secondary" data-action="createtemplate" data-dataid={{id}}>
{{#str}}save_as_new_template, mod_feedback{{/str}}
</button>
{{#js}}
require(['mod_feedback/createtemplate'], function(createtemplate) {
createtemplate.init();
});
{{/js}}

@ -0,0 +1,185 @@
{{!
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/>.
}}
{{!
@template mod_feedback/main_action_menu
Tertiary nav for the feedback module
Classes required for JS:
* none
Data attributes required for JS:
* data-region
Context variables required for this template:
* see mod/feedback/classes/output/edit_action_bar.php
* see mod/feedback/classes/output/edit_template_action_bar.php
* see mod/feedback/classes/output/responses_action_bar.php
* see mod/feedback/classes/output/standard_action_bar.php
Example context (json):
{
"left": {
"actionlink": {
"disabled": false,
"url": "#",
"id": "test-id",
"classes": "btn btn-link",
"attributes": [
{
"name": "title",
"value": "Action link's title"
}
],
"icon": {
"attributes": [
{"name": "src", "value": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png"},
{"name": "alt", "value": "Action link's icon"}
]
},
"text": "This is an action link"
},
"urlselect": {
"id": "url_select_test",
"action": "https://example.com/post",
"formid": "url_select_form",
"sesskey": "sesskey",
"label": "core/url_select",
"helpicon": {
"title": "Help with something",
"text": "Help with something",
"url": "http://example.org/help",
"linktext": "",
"icon":{
"extraclasses": "iconhelp",
"attributes": [
{"name": "src", "value": "../../../pix/help.svg"},
{"name": "alt", "value": "Help icon"}
]
}
},
"showbutton": "Go",
"options": [{
"name": "Group 1", "isgroup": true, "options":
[
{"name": "Item 1", "isgroup": false, "value": "1"},
{"name": "Item 2", "isgroup": false, "value": "2"}
]},
{"name": "Group 2", "isgroup": true, "options":
[
{"name": "Item 3", "isgroup": false, "value": "3"},
{"name": "Item 4", "isgroup": false, "value": "4"}
]}],
"disabled": false,
"title": "Some cool title"
},
"singleselect": {
"name": "lang",
"method": "get",
"action": "http://localhost/stable_master/mod/scorm/player.php",
"classes": "langmenu",
"label": "Zombies are coming...",
"disabled": false,
"title": null,
"formid": "randomid",
"id": "single_select5833dd4f4b08d108",
"params": [
{
"name": "scoid",
"value": "12"
},
{
"name": "cm",
"value": "15"
},
{
"name": "mode",
"value": "review"
},
{
"name": "currentorg",
"value": "eXeMapADrive4823c6301cf72b22b72"
}
],
"options": [
{
"value": "en",
"name": "English (en)",
"selected": true,
"optgroup": false
},
{
"value": "ar",
"name": "Muhaaaa..",
"selected": false,
"optgroup": false
}
],
"labelattributes": [],
"helpicon": false
}
},
"usetemplate": {
"id": 1,
"templateid": 2
},
"export": {
"disabled": false,
"url": "#",
"id": "test-id",
"classes": "btn btn-link",
"attributes": [
{
"name": "title",
"value": "Action link's title"
}
],
"icon": {
"attributes": [
{"name": "src", "value": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png"},
{"name": "alt", "value": "Action link's icon"}
]
},
"text": "This is an action link"
}
}
}}
<div class="container-fluid pl-0 pb-1" id="action_bar">
<div class="row pl-0 ml-0">
<div class="d-flex">
{{#left}}
{{#actionlink}}
<div class="col-xs-4 pr-1">
{{> core/action_link}}
</div>
{{/actionlink}}
{{#urlselect}}
<div class="col-xs-4 pr-1">
{{> core/url_select}}
</div>
{{/urlselect}}
{{#singleselect}}
<div class="col-xs-4 pr-1">
{{> core/single_select}}
</div>
{{/singleselect}}
{{/left}}
{{#usetemplate }}
<div class="col-xs-4 pr-1">
{{> mod_feedback/use_template }}
</div>
{{/usetemplate}}
</div>
{{#export}}
<div class="ml-auto">
{{> core/action_link }}
</div>
{{/export}}
</div>
</div>

@ -0,0 +1,37 @@
{{!
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/>.
}}
{{!
@template mod_feedback/use_template
Trigger button for the use template confirmation modal form.
Classes required for JS:
* none
Data attributes required for JS:
* All data attributes are required
Context variables required for this template:
* id - The feedback id.
* templateid - The template id.
Example context (json):
{
"id": 1,
"templateid": 2
}
}}
<button type="button" class="btn btn-secondary" data-action="usetemplate" data-dataid={{id}} data-templateid="{{templateid}}">
{{#str}}use_this_template, mod_feedback{{/str}}
</button>
{{#js}}
require(['mod_feedback/usetemplate'], function(usetemplate) {
usetemplate.init();
});
{{/js}}

@ -1,3 +1,9 @@
=== 4.0 ===
* The following files and classes within them have been deprecated in favour of dynamic forms:
* edit_form.php
* use_templ_form.php
* The page delete_template.php has been removed as it is now handled within manage_templates.php
=== 3.11 ===
The $extradetails parameter in the constructor of the mod_feedback\output\summary class has been deprecated and is not used anymore.

@ -24,10 +24,10 @@
require_once("../../config.php");
require_once("lib.php");
require_once('use_templ_form.php');
$id = required_param('id', PARAM_INT);
$templateid = optional_param('templateid', false, PARAM_INT);
$mode = optional_param('mode', '', PARAM_ALPHA);
if (!$templateid) {
redirect('edit.php?id='.$id);
@ -46,35 +46,29 @@ $feedbackstructure = new mod_feedback_structure($feedback, $cm, 0, $templateid);
require_capability('mod/feedback:edititems', $context);
$mform = new mod_feedback_use_templ_form();
$mform->set_data(array('id' => $id, 'templateid' => $templateid));
if ($mform->is_cancelled()) {
redirect('edit.php?id='.$id.'&do_show=templates');
} else if ($formdata = $mform->get_data()) {
feedback_items_from_template($feedback, $templateid, $formdata->deleteolditems);
redirect('edit.php?id=' . $id);
}
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php',
array('id' => $id, 'do_show' => 'templates')));
$params = ['id' => $id];
$params += ($mode ? ['mode' => $mode] : []);
$activeurl = new moodle_url('/mod/feedback/manage_templates.php', $params);
$PAGE->set_url($activeurl);
if ($mode == 'manage') {
navigation_node::override_active_url($activeurl);
} else {
navigation_node::override_active_url(new moodle_url('/mod/feedback/view.php', $params));
}
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
$actionbar = new \mod_feedback\output\edit_template_action_bar($cm->id, $templateid, $mode);
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
echo $OUTPUT->header();
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
echo $OUTPUT->heading(format_string($feedback->name));
echo $OUTPUT->heading(get_string('confirmusetemplate', 'feedback'), 4);
$mform->display();
echo $renderer->main_action_bar($actionbar);
$form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_VIEW_TEMPLATE,
$feedbackstructure, 'feedback_preview_form', ['templateid' => $templateid]);

@ -28,7 +28,18 @@ if (!defined('MOODLE_INTERNAL')) {
require_once($CFG->libdir.'/formslib.php');
/**
* The mod_feedback_use_templ_form
*
* @deprecated since 4.0. New dynamic forms have been created instead.
*/
class mod_feedback_use_templ_form extends moodleform {
public function __construct($action = null, $customdata = null, $method = 'post', $target = '',
$attributes = null, $editable = true, $ajaxformdata = null) {
debugging('Class mod_feedback_use_templ_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
parent::__construct($action, $customdata, $method, $target, $attributes, $editable, $ajaxformdata);
}
public function definition() {
$mform =& $this->_form;
@ -52,5 +63,59 @@ class mod_feedback_use_templ_form extends moodleform {
$this->add_action_buttons();
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @return array
*/
public static function get_js_module() {
debugging('Class mod_feedback_use_templ_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::get_js_module();
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $simulatedsubmitteddata
* @param array $simulatedsubmittedfiles
* @param string $method
* @param null $formidentifier
* @return array
*/
public static function mock_ajax_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(),
$method = 'post', $formidentifier = null) {
debugging('Class mod_feedback_use_templ_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::mock_ajax_submit($simulatedsubmitteddata, $simulatedsubmittedfiles, $method, $formidentifier);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $data
* @return array
*/
public static function mock_generate_submit_keys($data = []) {
debugging('Class mod_feedback_use_templ_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
return parent::mock_generate_submit_keys($data);
}
/**
* Overrides parent static method for deprecation purposes.
*
* @deprecated since 4.0
* @param array $simulatedsubmitteddata
* @param array $simulatedsubmittedfiles
* @param string $method
* @param null $formidentifier
*/
public static function mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(),
$method = 'post', $formidentifier = null) {
debugging('Class mod_feedback_use_templ_form is deprecated. Replaced with dynamic forms.', DEBUG_DEVELOPER);
parent::mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles, $method, $formidentifier);
}
}

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2021052500; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2021052507; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'mod_feedback'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;

@ -58,6 +58,17 @@ if (!has_capability('mod/feedback:edititems', $context) &&
exit;
}
$viewcompletion = $feedbackcompletion->is_open() && $feedbackcompletion->can_complete() && $feedbackcompletion->can_submit();
$actionbar = new \mod_feedback\output\standard_action_bar(
$cm->id,
$viewcompletion,
$feedbackcompletion->get_resume_page(),
$courseid
);
/** @var \mod_feedback\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_feedback');
// Trigger module viewed event.
$feedbackcompletion->trigger_module_viewed();
@ -76,20 +87,16 @@ if ($courseid) {
}
$preview = html_writer::link($previewlnk, $previewimg);
echo $OUTPUT->heading(format_string($feedback->name) . $preview);
// Render the activity information.
$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id);
$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id);
echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates);
// Print the tabs.
require('tabs.php');
// Show description.
echo $OUTPUT->box_start('generalbox feedback_description');
$options = (object)array('noclean' => true);
echo format_module_intro('feedback', $feedback, $cm->id);
echo $renderer->main_action_bar($actionbar);
echo $OUTPUT->box_end();
//show some infos to the feedback
@ -111,21 +118,23 @@ if (has_capability('mod/feedback:edititems', $context)) {
}
}
if (!has_capability('mod/feedback:viewreports', $context) &&
if (!$PAGE->has_secondary_navigation()) {
if (!has_capability('mod/feedback:viewreports', $context) &&
$feedbackcompletion->can_view_analysis()) {
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $id));
echo '<div class="mdl-align"><a href="'.$analysisurl->out().'">';
echo get_string('completed_feedbacks', 'feedback').'</a>';
echo '</div>';
}
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $id));
echo '<div class="mdl-align"><a href="' . $analysisurl->out() . '">';
echo get_string('completed_feedbacks', 'feedback') . '</a>';
echo '</div>';
}
if (has_capability('mod/feedback:mapcourse', $context) && $feedback->course == SITEID) {
echo $OUTPUT->box_start('generalbox feedback_mapped_courses');
echo $OUTPUT->heading(get_string("mappedcourses", "feedback"), 3);
echo '<p>' . get_string('mapcourse_help', 'feedback') . '</p>';
$mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id' => $id));
echo '<p class="mdl-align">' . html_writer::link($mapurl, get_string('mapcourses', 'feedback')) . '</p>';
echo $OUTPUT->box_end();
if (has_capability('mod/feedback:mapcourse', $context) && $feedback->course == SITEID) {
echo $OUTPUT->box_start('generalbox feedback_mapped_courses');
echo $OUTPUT->heading(get_string("mappedcourses", "feedback"), 3);
echo '<p>' . get_string('mapcourse_help', 'feedback') . '</p>';
$mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id' => $id));
echo '<p class="mdl-align">' . html_writer::link($mapurl, get_string('mapcourses', 'feedback')) . '</p>';
echo $OUTPUT->box_end();
}
}
if ($feedbackcompletion->can_complete()) {
@ -134,18 +143,7 @@ if ($feedbackcompletion->can_complete()) {
// Feedback is not yet open or is already closed.
echo $OUTPUT->notification(get_string('feedback_is_not_open', 'feedback'));
echo $OUTPUT->continue_button(course_get_url($courseid ?: $course->id));
} else if ($feedbackcompletion->can_submit()) {
// Display a link to complete feedback or resume.
$completeurl = new moodle_url('/mod/feedback/complete.php',
['id' => $id, 'courseid' => $courseid]);
if ($startpage = $feedbackcompletion->get_resume_page()) {
$completeurl->param('gopage', $startpage);
$label = get_string('continue_the_form', 'feedback');
} else {
$label = get_string('complete_the_form', 'feedback');
}
echo html_writer::div(html_writer::link($completeurl, $label, array('class' => 'btn btn-secondary')), 'complete-feedback');
} else {
} else if (!$feedbackcompletion->can_submit()) {
// Feedback was already submitted.
echo $OUTPUT->notification(get_string('this_feedback_is_already_submitted', 'feedback'));
$OUTPUT->continue_button(course_get_url($courseid ?: $course->id));