mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
MDL-53638 mod_feedback: JS confirmation on delete entry and template
This commit is contained in:
parent
3fdba72902
commit
094c57dd4f
@ -183,9 +183,10 @@ class mod_feedback_responses_table extends table_sql {
|
|||||||
*/
|
*/
|
||||||
public function col_deleteentry($row) {
|
public function col_deleteentry($row) {
|
||||||
global $OUTPUT;
|
global $OUTPUT;
|
||||||
$icon = $OUTPUT->render(new \pix_icon('t/delete', get_string('delete_entry', 'feedback')));
|
$deleteentryurl = new moodle_url($this->baseurl, ['delete' => $row->id, 'sesskey' => sesskey()]);
|
||||||
$deleteentryurl = new moodle_url($this->baseurl, ['delete' => $row->id]);
|
$deleteaction = new confirm_action(get_string('confirmdeleteentry', 'feedback'));
|
||||||
return html_writer::link($deleteentryurl, $icon);
|
return $OUTPUT->action_icon($deleteentryurl,
|
||||||
|
new pix_icon('t/delete', get_string('delete_entry', 'feedback')), $deleteaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,9 +77,10 @@ class mod_feedback_templates_table extends flexible_table {
|
|||||||
foreach ($templates as $template) {
|
foreach ($templates as $template) {
|
||||||
$data = array();
|
$data = array();
|
||||||
$data[] = format_string($template->name);
|
$data[] = format_string($template->name);
|
||||||
$url = new moodle_url($this->baseurl, array('deletetempl' => $template->id));
|
$url = new moodle_url($this->baseurl, array('deletetempl' => $template->id, 'sesskey' => sesskey()));
|
||||||
|
|
||||||
$data[] = $OUTPUT->single_button($url, $strdeletefeedback, 'post');
|
$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->add_data($data);
|
||||||
}
|
}
|
||||||
$this->finish_output();
|
$this->finish_output();
|
||||||
|
@ -43,7 +43,8 @@ $feedback = $PAGE->activityrecord;
|
|||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
// Process template deletion.
|
// Process template deletion.
|
||||||
if ($deletetempl && optional_param('confirm', 0, PARAM_BOOL) && confirm_sesskey()) {
|
if ($deletetempl) {
|
||||||
|
require_sesskey();
|
||||||
$template = $DB->get_record('feedback_template', array('id' => $deletetempl), '*', MUST_EXIST);
|
$template = $DB->get_record('feedback_template', array('id' => $deletetempl), '*', MUST_EXIST);
|
||||||
|
|
||||||
if ($template->ispublic) {
|
if ($template->ispublic) {
|
||||||
@ -69,36 +70,29 @@ echo $OUTPUT->heading(format_string($feedback->name));
|
|||||||
/// print the tabs
|
/// print the tabs
|
||||||
require('tabs.php');
|
require('tabs.php');
|
||||||
|
|
||||||
/// Print the main part of the page
|
// Print the main part of the page.
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
echo $OUTPUT->heading($strdeletefeedback, 3);
|
echo $OUTPUT->heading($strdeletefeedback, 3);
|
||||||
if ($deletetempl) {
|
|
||||||
$continueurl = new moodle_url($baseurl, array('deletetempl' => $deletetempl, 'confirm' => 1, 'sesskey' => sesskey()));
|
|
||||||
echo $OUTPUT->confirm(get_string('confirmdeletetemplate', 'feedback'), $continueurl, $baseurl);
|
|
||||||
} else {
|
|
||||||
// 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);
|
|
||||||
$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'));
|
// First we get the course templates.
|
||||||
echo $OUTPUT->single_button($url, get_string('back'), 'post');
|
$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);
|
||||||
|
$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');
|
||||||
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
||||||
|
@ -54,12 +54,10 @@ require_capability('mod/feedback:viewreports', $context);
|
|||||||
if ($deleteid) {
|
if ($deleteid) {
|
||||||
// This is a request to delete a reponse.
|
// This is a request to delete a reponse.
|
||||||
require_capability('mod/feedback:deletesubmissions', $context);
|
require_capability('mod/feedback:deletesubmissions', $context);
|
||||||
|
require_sesskey();
|
||||||
$feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $deleteid);
|
$feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $deleteid);
|
||||||
if (optional_param('confirm', 0, PARAM_BOOL) && confirm_sesskey()) {
|
feedback_delete_completed($feedbackstructure->get_completed(), $feedback, $cm);
|
||||||
// Process delete template result.
|
redirect($baseurl);
|
||||||
feedback_delete_completed($feedbackstructure->get_completed(), $feedback, $cm);
|
|
||||||
redirect($baseurl);
|
|
||||||
}
|
|
||||||
} else if ($showcompleted || $userid) {
|
} else if ($showcompleted || $userid) {
|
||||||
// Viewing individual response.
|
// Viewing individual response.
|
||||||
$feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $showcompleted, $userid);
|
$feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $showcompleted, $userid);
|
||||||
@ -98,11 +96,7 @@ require('tabs.php');
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if ($deleteid) {
|
if ($userid || $showcompleted) {
|
||||||
// Print confirmation form to delete a response.
|
|
||||||
$continueurl = new moodle_url($baseurl, array('delete' => $deleteid, 'confirm' => 1, 'sesskey' => sesskey()));
|
|
||||||
echo $OUTPUT->confirm(get_string('confirmdeleteentry', 'feedback'), $continueurl, $baseurl);
|
|
||||||
} else if ($userid || $showcompleted) {
|
|
||||||
// Print the response of the given user.
|
// Print the response of the given user.
|
||||||
$completedrecord = $feedbackstructure->get_completed();
|
$completedrecord = $feedbackstructure->get_completed();
|
||||||
|
|
||||||
|
@ -233,8 +233,6 @@ Feature: Anonymous feedback
|
|||||||
And I follow "Back"
|
And I follow "Back"
|
||||||
# Delete anonymous response
|
# Delete anonymous response
|
||||||
And I click on "Delete entry" "link" in the "Response number: 1" "table_row"
|
And I click on "Delete entry" "link" in the "Response number: 1" "table_row"
|
||||||
And I should see "Are you sure you want to delete this entry?"
|
|
||||||
And I press "Continue"
|
|
||||||
And I should see "Anonymous entries (1)"
|
And I should see "Anonymous entries (1)"
|
||||||
And I should not see "Response number: 1"
|
And I should not see "Response number: 1"
|
||||||
And I should see "Response number: 2"
|
And I should see "Response number: 2"
|
||||||
|
@ -162,8 +162,6 @@ Feature: Non anonymous feedback
|
|||||||
And I follow "Back"
|
And I follow "Back"
|
||||||
# Delete non anonymous response
|
# Delete non anonymous response
|
||||||
And I click on "Delete entry" "link" in the "Username 1" "table_row"
|
And I click on "Delete entry" "link" in the "Username 1" "table_row"
|
||||||
And I should see "Are you sure you want to delete this entry?"
|
|
||||||
And I press "Continue"
|
|
||||||
And I should see "Non anonymous entries (1)"
|
And I should see "Non anonymous entries (1)"
|
||||||
And I should not see "Username 1"
|
And I should not see "Username 1"
|
||||||
And I should see "Username 2"
|
And I should see "Username 2"
|
||||||
|
@ -153,9 +153,7 @@ Feature: Saving, using and deleting feedback templates
|
|||||||
Then I should not see "My public template"
|
Then I should not see "My public template"
|
||||||
And ".publictemplates" "css_element" should not exist
|
And ".publictemplates" "css_element" should not exist
|
||||||
And "My course template" "text" should exist in the ".coursetemplates" "css_element"
|
And "My course template" "text" should exist in the ".coursetemplates" "css_element"
|
||||||
And I click on "Delete" "button" in the "My course template" "table_row"
|
And I click on "Delete" "link" in the "My course template" "table_row"
|
||||||
And I should see "Are you sure you want to delete this template?"
|
|
||||||
And I press "Continue"
|
|
||||||
And I should see "Template deleted"
|
And I should see "Template deleted"
|
||||||
And "My course template" "text" should not exist in the ".coursetemplates" "css_element"
|
And "My course template" "text" should not exist in the ".coursetemplates" "css_element"
|
||||||
And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
|
And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
|
||||||
@ -164,6 +162,7 @@ Feature: Saving, using and deleting feedback templates
|
|||||||
And the "Use a template" select box should contain "My public template"
|
And the "Use a template" select box should contain "My public template"
|
||||||
And I log out
|
And I log out
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: Manager can delete both course and public templates
|
Scenario: Manager can delete both course and public templates
|
||||||
# Save feedback as both public and course template
|
# Save feedback as both public and course template
|
||||||
When I log in as "manager"
|
When I log in as "manager"
|
||||||
@ -180,17 +179,17 @@ Feature: Saving, using and deleting feedback templates
|
|||||||
And I follow "Delete template..."
|
And I follow "Delete template..."
|
||||||
Then "My public template" "text" should exist in the ".publictemplates" "css_element"
|
Then "My public template" "text" should exist in the ".publictemplates" "css_element"
|
||||||
And "My course template" "text" should exist in the ".coursetemplates" "css_element"
|
And "My course template" "text" should exist in the ".coursetemplates" "css_element"
|
||||||
And I click on "Delete" "button" in the "My course template" "table_row"
|
And I click on "Delete" "link" in the "My course template" "table_row"
|
||||||
And I should see "Are you sure you want to delete this template?"
|
And I should see "Are you sure you want to delete this template?"
|
||||||
And I press "Continue"
|
And I press "Yes"
|
||||||
And I should see "Template deleted"
|
And I should see "Template deleted"
|
||||||
And "My course template" "text" should not exist in the ".coursetemplates" "css_element"
|
And "My course template" "text" should not exist in the ".coursetemplates" "css_element"
|
||||||
And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
|
And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
|
||||||
# Delete public template
|
# Delete public template
|
||||||
And "My public template" "text" should exist in the ".publictemplates" "css_element"
|
And "My public template" "text" should exist in the ".publictemplates" "css_element"
|
||||||
And I click on "Delete" "button" in the "My public template" "table_row"
|
And I click on "Delete" "link" in the "My public template" "table_row"
|
||||||
And I should see "Are you sure you want to delete this template?"
|
And I should see "Are you sure you want to delete this template?"
|
||||||
And I press "Continue"
|
And I press "Yes"
|
||||||
And I should see "Template deleted"
|
And I should see "Template deleted"
|
||||||
And "My public template" "text" should not exist in the ".publictemplates" "css_element"
|
And "My public template" "text" should not exist in the ".publictemplates" "css_element"
|
||||||
And "No templates available yet" "text" should exist in the ".publictemplates" "css_element"
|
And "No templates available yet" "text" should exist in the ".publictemplates" "css_element"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user