|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 require_once("../config.php"); 00028 require_once("lib.php"); 00029 00030 $id = required_param('id', PARAM_INT); // course id 00031 $scaleid = optional_param('scaleid', 0, PARAM_INT); // scale id (show only this one) 00032 00033 $url = new moodle_url('/course/scales.php', array('id'=>$id)); 00034 if ($scaleid !== 0) { 00035 $url->param('scaleid', $scaleid); 00036 } 00037 $PAGE->set_url($url); 00038 00039 $context = null; 00040 if ($course = $DB->get_record('course', array('id'=>$id))) { 00041 require_login($course); 00042 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00043 } else { 00044 //$id will be 0 for site level scales 00045 require_login(); 00046 $context = get_context_instance(CONTEXT_SYSTEM); 00047 } 00048 00049 $PAGE->set_context($context); 00050 require_capability('moodle/course:viewscales', $context); 00051 00052 $strscales = get_string("scales"); 00053 $strcustomscales = get_string("scalescustom"); 00054 $strstandardscales = get_string("scalesstandard"); 00055 00056 $PAGE->set_title($strscales); 00057 if (!empty($course)) { 00058 $PAGE->set_heading($course->fullname); 00059 } else { 00060 $PAGE->set_heading($SITE->fullname); 00061 } 00062 echo $OUTPUT->header(); 00063 00064 if ($scaleid) { 00065 if ($scale = $DB->get_record("scale", array('id'=>$scaleid))) { 00066 if ($scale->courseid == 0 || $scale->courseid == $course->id) { 00067 00068 $scalemenu = make_menu_from_list($scale->scale); 00069 00070 echo $OUTPUT->box_start(); 00071 echo $OUTPUT->heading($scale->name); 00072 echo "<center>"; 00073 echo html_writer::select($scalemenu, 'unused'); 00074 echo "</center>"; 00075 echo text_to_html($scale->description); 00076 echo $OUTPUT->box_end(); 00077 echo $OUTPUT->close_window_button(); 00078 echo $OUTPUT->footer(); 00079 exit; 00080 } 00081 } 00082 } 00083 00084 $systemcontext = get_context_instance(CONTEXT_SYSTEM); 00085 00086 if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) { 00087 echo $OUTPUT->heading($strcustomscales); 00088 00089 if (has_capability('moodle/course:managescales', $context)) { 00090 echo "<p align=\"center\">("; 00091 print_string('scalestip2'); 00092 echo ")</p>"; 00093 } 00094 00095 foreach ($scales as $scale) { 00096 00097 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id); 00098 00099 $scalemenu = make_menu_from_list($scale->scale); 00100 00101 echo $OUTPUT->box_start(); 00102 echo $OUTPUT->heading($scale->name); 00103 echo "<center>"; 00104 echo html_writer::select($scalemenu, 'unused'); 00105 echo "</center>"; 00106 echo text_to_html($scale->description); 00107 echo $OUTPUT->box_end(); 00108 echo "<hr />"; 00109 } 00110 00111 } else { 00112 if (has_capability('moodle/course:managescales', $context)) { 00113 echo "<p align=\"center\">("; 00114 print_string("scalestip2"); 00115 echo ")</p>"; 00116 } 00117 } 00118 00119 if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) { 00120 echo $OUTPUT->heading($strstandardscales); 00121 foreach ($scales as $scale) { 00122 00123 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id); 00124 00125 $scalemenu = make_menu_from_list($scale->scale); 00126 00127 echo $OUTPUT->box_start(); 00128 echo $OUTPUT->heading($scale->name); 00129 echo "<center>"; 00130 echo html_writer::select($scalemenu, 'unused'); 00131 echo "</center>"; 00132 echo text_to_html($scale->description); 00133 echo $OUTPUT->box_end(); 00134 echo "<hr />"; 00135 } 00136 } 00137 00138 echo $OUTPUT->close_window_button(); 00139 echo $OUTPUT->footer(); 00140