|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00025 require_once("../../config.php"); 00026 require_once("lib.php"); 00027 require_once('use_templ_form.php'); 00028 00029 $id = required_param('id', PARAM_INT); 00030 $templateid = optional_param('templateid', false, PARAM_INT); 00031 $deleteolditems = optional_param('deleteolditems', 0, PARAM_INT); 00032 00033 if (!$templateid) { 00034 redirect('edit.php?id='.$id); 00035 } 00036 00037 $url = new moodle_url('/mod/feedback/use_templ.php', array('id'=>$id, 'templateid'=>$templateid)); 00038 if ($deleteolditems !== 0) { 00039 $url->param('deleteolditems', $deleteolditems); 00040 } 00041 $PAGE->set_url($url); 00042 00043 if (! $cm = get_coursemodule_from_id('feedback', $id)) { 00044 print_error('invalidcoursemodule'); 00045 } 00046 00047 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 00048 print_error('coursemisconf'); 00049 } 00050 00051 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { 00052 print_error('invalidcoursemodule'); 00053 } 00054 00055 if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { 00056 print_error('badcontext'); 00057 } 00058 00059 require_login($course->id, true, $cm); 00060 00061 require_capability('mod/feedback:edititems', $context); 00062 00063 $mform = new mod_feedback_use_templ_form(); 00064 $newformdata = array('id'=>$id, 00065 'templateid'=>$templateid, 00066 'confirmadd'=>'1', 00067 'deleteolditems'=>'1', 00068 'do_show'=>'edit'); 00069 $mform->set_data($newformdata); 00070 $formdata = $mform->get_data(); 00071 00072 if ($mform->is_cancelled()) { 00073 redirect('edit.php?id='.$id.'&do_show=templates'); 00074 } 00075 00076 if (isset($formdata->confirmadd) AND $formdata->confirmadd == 1) { 00077 feedback_items_from_template($feedback, $templateid, $deleteolditems); 00078 redirect('edit.php?id=' . $id); 00079 } 00080 00082 $strfeedbacks = get_string("modulenameplural", "feedback"); 00083 $strfeedback = get_string("modulename", "feedback"); 00084 00085 $PAGE->navbar->add($strfeedbacks, new moodle_url('/mod/feedback/index.php', array('id'=>$course->id))); 00086 $PAGE->navbar->add(format_string($feedback->name)); 00087 $PAGE->set_heading(format_string($course->fullname)); 00088 $PAGE->set_title(format_string($feedback->name)); 00089 echo $OUTPUT->header(); 00090 00095 echo $OUTPUT->heading(format_text($feedback->name)); 00096 00097 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal'); 00098 echo $OUTPUT->heading(get_string('confirmusetemplate', 'feedback')); 00099 00100 $mform->display(); 00101 00102 echo $OUTPUT->box_end(); 00103 00104 $templateitems = $DB->get_records('feedback_item', array('template'=>$templateid), 'position'); 00105 if (is_array($templateitems)) { 00106 $templateitems = array_values($templateitems); 00107 } 00108 00109 if (is_array($templateitems)) { 00110 $itemnr = 0; 00111 $align = right_to_left() ? 'right' : 'left'; 00112 echo $OUTPUT->box_start('feedback_items'); 00113 foreach ($templateitems as $templateitem) { 00114 echo $OUTPUT->box_start('feedback_item_box_'.$align); 00115 if ($templateitem->hasvalue == 1 AND $feedback->autonumbering) { 00116 $itemnr++; 00117 echo $OUTPUT->box_start('feedback_item_number_'.$align); 00118 echo $itemnr; 00119 echo $OUTPUT->box_end(); 00120 } 00121 echo $OUTPUT->box_start('box generalbox boxalign_'.$align); 00122 if ($templateitem->typ != 'pagebreak') { 00123 // echo '<div class="feedback_item_'.$align.'">'; 00124 feedback_print_item_preview($templateitem); 00125 } else { 00126 echo $OUTPUT->box_start('feedback_pagebreak'); 00127 echo get_string('pagebreak', 'feedback').'<hr class="feedback_pagebreak" />'; 00128 echo $OUTPUT->box_end(); 00129 } 00130 echo $OUTPUT->box_end(); 00131 echo $OUTPUT->box_end(); 00132 } 00133 echo $OUTPUT->box_end(); 00134 } else { 00135 echo $OUTPUT->box(get_string('no_items_available_at_this_template', 'feedback'), 00136 'generalbox boxaligncenter boxwidthwide'); 00137 } 00138 00139 echo $OUTPUT->footer(); 00140