See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * prints the form to edit the feedback items such moving, deleting and so on 19 * 20 * @author Andreas Grabs 21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 22 * @package mod_feedback 23 */ 24 25 require_once('../../config.php'); 26 require_once ('lib.php'); 27 require_once ('edit_form.php'); 28 29 feedback_init_feedback_session(); 30 31 $id = required_param('id', PARAM_INT); 32 33 if (($formdata = data_submitted()) AND !confirm_sesskey()) { 34 print_error('invalidsesskey'); 35 } 36 37 $do_show = optional_param('do_show', 'edit', PARAM_ALPHA); 38 $switchitemrequired = optional_param('switchitemrequired', false, PARAM_INT); 39 $deleteitem = optional_param('deleteitem', false, PARAM_INT); 40 41 $current_tab = $do_show; 42 43 $url = new moodle_url('/mod/feedback/edit.php', array('id'=>$id, 'do_show'=>$do_show)); 44 45 list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); 46 47 $context = context_module::instance($cm->id); 48 require_login($course, false, $cm); 49 require_capability('mod/feedback:edititems', $context); 50 $feedback = $PAGE->activityrecord; 51 $feedbackstructure = new mod_feedback_structure($feedback, $cm); 52 53 if ($switchitemrequired) { 54 require_sesskey(); 55 $items = $feedbackstructure->get_items(); 56 if (isset($items[$switchitemrequired])) { 57 feedback_switch_item_required($items[$switchitemrequired]); 58 } 59 redirect($url); 60 } 61 62 if ($deleteitem) { 63 require_sesskey(); 64 $items = $feedbackstructure->get_items(); 65 if (isset($items[$deleteitem])) { 66 feedback_delete_item($deleteitem); 67 } 68 redirect($url); 69 } 70 71 // Process the create template form. 72 $cancreatetemplates = has_capability('mod/feedback:createprivatetemplate', $context) || 73 has_capability('mod/feedback:createpublictemplate', $context); 74 $create_template_form = new feedback_edit_create_template_form(null, array('id' => $id)); 75 if ($data = $create_template_form->get_data()) { 76 // Check the capabilities to create templates. 77 if (!$cancreatetemplates) { 78 print_error('cannotsavetempl', 'feedback', $url); 79 } 80 $ispublic = !empty($data->ispublic) ? 1 : 0; 81 if (!feedback_save_as_template($feedback, $data->templatename, $ispublic)) { 82 redirect($url, get_string('saving_failed', 'feedback'), null, \core\output\notification::NOTIFY_ERROR); 83 } else { 84 redirect($url, get_string('template_saved', 'feedback'), null, \core\output\notification::NOTIFY_SUCCESS); 85 } 86 } 87 88 //Get the feedbackitems 89 $lastposition = 0; 90 $feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position'); 91 if (is_array($feedbackitems)) { 92 $feedbackitems = array_values($feedbackitems); 93 if (count($feedbackitems) > 0) { 94 $lastitem = $feedbackitems[count($feedbackitems)-1]; 95 $lastposition = $lastitem->position; 96 } else { 97 $lastposition = 0; 98 } 99 } 100 $lastposition++; 101 102 103 //The use_template-form 104 $use_template_form = new feedback_edit_use_template_form('use_templ.php', array('course' => $course, 'id' => $id)); 105 106 //Print the page header. 107 $strfeedbacks = get_string('modulenameplural', 'feedback'); 108 $strfeedback = get_string('modulename', 'feedback'); 109 110 $PAGE->set_url('/mod/feedback/edit.php', array('id'=>$cm->id, 'do_show'=>$do_show)); 111 $PAGE->set_heading($course->fullname); 112 $PAGE->set_title($feedback->name); 113 114 //Adding the javascript module for the items dragdrop. 115 if (count($feedbackitems) > 1) { 116 if ($do_show == 'edit') { 117 $PAGE->requires->strings_for_js(array( 118 'pluginname', 119 'move_item', 120 'position', 121 ), 'feedback'); 122 $PAGE->requires->yui_module('moodle-mod_feedback-dragdrop', 'M.mod_feedback.init_dragdrop', 123 array(array('cmid' => $cm->id))); 124 } 125 } 126 127 echo $OUTPUT->header(); 128 echo $OUTPUT->heading(format_string($feedback->name)); 129 130 /// print the tabs 131 require ('tabs.php'); 132 133 // Print the main part of the page. 134 135 if ($do_show == 'templates') { 136 // Print the template-section. 137 $use_template_form->display(); 138 139 if ($cancreatetemplates) { 140 $deleteurl = new moodle_url('/mod/feedback/delete_template.php', array('id' => $id)); 141 $create_template_form->display(); 142 echo '<p><a href="'.$deleteurl->out().'">'. 143 get_string('delete_templates', 'feedback'). 144 '</a></p>'; 145 } else { 146 echo ' '; 147 } 148 149 if (has_capability('mod/feedback:edititems', $context)) { 150 $urlparams = array('action'=>'exportfile', 'id'=>$id); 151 $exporturl = new moodle_url('/mod/feedback/export.php', $urlparams); 152 $importurl = new moodle_url('/mod/feedback/import.php', array('id'=>$id)); 153 echo '<p> 154 <a href="'.$exporturl->out().'">'.get_string('export_questions', 'feedback').'</a>/ 155 <a href="'.$importurl->out().'">'.get_string('import_questions', 'feedback').'</a> 156 </p>'; 157 } 158 } 159 160 if ($do_show == 'edit') { 161 // Print the Item-Edit-section. 162 163 $select = new single_select(new moodle_url('/mod/feedback/edit_item.php', 164 array('cmid' => $id, 'position' => $lastposition, 'sesskey' => sesskey())), 165 'typ', feedback_load_feedback_items_options()); 166 $select->label = get_string('add_item', 'mod_feedback'); 167 echo $OUTPUT->render($select); 168 169 170 $form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_EDIT, 171 $feedbackstructure, 'feedback_edit_form'); 172 echo '<div id="feedback_dragarea">'; // The container for the dragging area. 173 $form->display(); 174 echo '</div>'; 175 } 176 177 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body