[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 * print the form to map courses for global feedbacks 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("$CFG->libdir/tablelib.php"); 28 29 $id = required_param('id', PARAM_INT); // Course Module ID, or 30 $searchcourse = optional_param('searchcourse', '', PARAM_NOTAGS); 31 $coursefilter = optional_param('coursefilter', '', PARAM_INT); 32 $courseid = optional_param('courseid', false, PARAM_INT); 33 34 $url = new moodle_url('/mod/feedback/mapcourse.php', array('id'=>$id)); 35 if ($searchcourse !== '') { 36 $url->param('searchcourse', $searchcourse); 37 } 38 if ($coursefilter !== '') { 39 $url->param('coursefilter', $coursefilter); 40 } 41 if ($courseid !== false) { 42 $url->param('courseid', $courseid); 43 } 44 $PAGE->set_url($url); 45 46 if (($formdata = data_submitted()) AND !confirm_sesskey()) { 47 print_error('invalidsesskey'); 48 } 49 50 $current_tab = 'mapcourse'; 51 52 if (! $cm = get_coursemodule_from_id('feedback', $id)) { 53 print_error('invalidcoursemodule'); 54 } 55 56 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 57 print_error('coursemisconf'); 58 } 59 60 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { 61 print_error('invalidcoursemodule'); 62 } 63 64 $context = context_module::instance($cm->id); 65 66 require_login($course, true, $cm); 67 68 require_capability('mod/feedback:mapcourse', $context); 69 70 if ($coursefilter) { 71 $map = new stdClass; 72 $map->feedbackid = $feedback->id; 73 $map->courseid = $coursefilter; 74 // insert a map only if it does exists yet 75 $sql = "SELECT id, feedbackid 76 FROM {feedback_sitecourse_map} 77 WHERE feedbackid = ? AND courseid = ?"; 78 if (!$DB->get_records_sql($sql, array($map->feedbackid, $map->courseid))) { 79 $DB->insert_record('feedback_sitecourse_map', $map); 80 } 81 } 82 83 /// Print the page header 84 $strfeedbacks = get_string("modulenameplural", "feedback"); 85 $strfeedback = get_string("modulename", "feedback"); 86 87 $PAGE->set_heading($course->fullname); 88 $PAGE->set_title($feedback->name); 89 echo $OUTPUT->header(); 90 echo $OUTPUT->heading(format_string($feedback->name)); 91 92 require ('tabs.php'); 93 94 echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'), 'generalbox boxaligncenter boxwidthwide'); 95 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); 96 echo '<form method="post">'; 97 echo '<input type="hidden" name="id" value="'.$id.'" />'; 98 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; 99 100 $sql = "select c.id, c.shortname 101 from {course} c 102 where ".$DB->sql_like('c.shortname', '?', false)." 103 OR ".$DB->sql_like('c.fullname', '?', false); 104 $params = array("%{$searchcourse}%", "%{$searchcourse}%"); 105 106 if (($courses = $DB->get_records_sql_menu($sql, $params)) && !empty($searchcourse)) { 107 echo ' '. html_writer::label(get_string('courses'), 'menucoursefilter', false). ': '; 108 echo html_writer::select($courses, 'coursefilter', $coursefilter); 109 echo '<input type="submit" value="'.get_string('mapcourse', 'feedback').'"/>'; 110 echo $OUTPUT->help_icon('mapcourses', 'feedback'); 111 echo '<input type="button" '. 112 'value="'.get_string('searchagain').'" '. 113 'onclick="document.location=\'mapcourse.php?id='.$id.'\'"/>'; 114 115 echo '<input type="hidden" name="searchcourse" value="'.s($searchcourse).'"/>'; 116 echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'"/>'; 117 echo $OUTPUT->help_icon('searchcourses', 'feedback'); 118 } else { 119 echo '<input type="text" name="searchcourse" value="'.s($searchcourse).'"/> '; 120 echo '<input type="submit" value="'.get_string('searchcourses').'"/>'; 121 echo $OUTPUT->help_icon('searchcourses', 'feedback'); 122 } 123 124 echo '</form>'; 125 126 if ($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) { 127 $table = new flexible_table('coursemaps'); 128 $table->baseurl = $url; 129 $table->define_columns( array('course')); 130 $table->define_headers( array(get_string('mappedcourses', 'feedback'))); 131 132 $table->setup(); 133 134 $unmapurl = new moodle_url('/mod/feedback/unmapcourse.php'); 135 foreach ($coursemap as $cmap) { 136 $coursecontext = context_course::instance($cmap->courseid); 137 $cmapshortname = format_string($cmap->shortname, true, array('context' => $coursecontext)); 138 $cmapfullname = format_string($cmap->fullname, true, array('context' => $coursecontext)); 139 $unmapurl->params(array('id'=>$id, 'cmapid'=>$cmap->id)); 140 $anker = '<a href="'.$unmapurl->out().'">'; 141 $anker .= '<img src="'.$OUTPUT->pix_url('t/delete').'" alt="Delete" />'; 142 $anker .= '</a>'; 143 $table->add_data(array($anker.' ('.$cmapshortname.') '.$cmapfullname)); 144 } 145 146 $table->print_html(); 147 } else { 148 echo $OUTPUT->heading(get_string('mapcoursenone', 'feedback'), 3); 149 } 150 151 152 echo $OUTPUT->box_end(); 153 154 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |