Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/grade/report/grader/index.php
Go to the documentation of this file.
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 
00018 require_once '../../../config.php';
00019 require_once $CFG->libdir.'/gradelib.php';
00020 require_once $CFG->dirroot.'/grade/lib.php';
00021 require_once $CFG->dirroot.'/grade/report/grader/lib.php';
00022 
00023 $courseid      = required_param('id', PARAM_INT);        // course id
00024 $page          = optional_param('page', 0, PARAM_INT);   // active page
00025 $perpageurl    = optional_param('perpage', 0, PARAM_INT);
00026 $edit          = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
00027 
00028 $sortitemid    = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
00029 $action        = optional_param('action', 0, PARAM_ALPHAEXT);
00030 $move          = optional_param('move', 0, PARAM_INT);
00031 $type          = optional_param('type', 0, PARAM_ALPHA);
00032 $target        = optional_param('target', 0, PARAM_ALPHANUM);
00033 $toggle        = optional_param('toggle', NULL, PARAM_INT);
00034 $toggle_type   = optional_param('toggle_type', 0, PARAM_ALPHANUM);
00035 
00036 $PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
00037 
00039 if (!$course = $DB->get_record('course', array('id' => $courseid))) {
00040     print_error('nocourseid');
00041 }
00042 require_login($course);
00043 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00044 
00045 require_capability('gradereport/grader:view', $context);
00046 require_capability('moodle/grade:viewall', $context);
00047 
00049 $gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'grader', 'courseid'=>$courseid, 'page'=>$page));
00050 
00052 if (!isset($USER->grade_last_report)) {
00053     $USER->grade_last_report = array();
00054 }
00055 $USER->grade_last_report[$course->id] = 'grader';
00056 
00058 
00059 if (!isset($USER->gradeediting)) {
00060     $USER->gradeediting = array();
00061 }
00062 
00063 if (has_capability('moodle/grade:edit', $context)) {
00064     if (!isset($USER->gradeediting[$course->id])) {
00065         $USER->gradeediting[$course->id] = 0;
00066     }
00067 
00068     if (($edit == 1) and confirm_sesskey()) {
00069         $USER->gradeediting[$course->id] = 1;
00070     } else if (($edit == 0) and confirm_sesskey()) {
00071         $USER->gradeediting[$course->id] = 0;
00072     }
00073 
00074     // page params for the turn editting on
00075     $options = $gpr->get_options();
00076     $options['sesskey'] = sesskey();
00077 
00078     if ($USER->gradeediting[$course->id]) {
00079         $options['edit'] = 0;
00080         $string = get_string('turneditingoff');
00081     } else {
00082         $options['edit'] = 1;
00083         $string = get_string('turneditingon');
00084     }
00085 
00086     $buttons = new single_button(new moodle_url('index.php', $options), $string, 'get');
00087 } else {
00088     $USER->gradeediting[$course->id] = 0;
00089     $buttons = '';
00090 }
00091 
00092 $gradeserror = array();
00093 
00094 // Handle toggle change request
00095 if (!is_null($toggle) && !empty($toggle_type)) {
00096     set_user_preferences(array('grade_report_show'.$toggle_type => $toggle));
00097 }
00098 
00099 //first make sure we have proper final grades - this must be done before constructing of the grade tree
00100 grade_regrade_final_grades($courseid);
00101 
00102 // Perform actions
00103 if (!empty($target) && !empty($action) && confirm_sesskey()) {
00104     grade_report_grader::process_action($target, $action);
00105 }
00106 
00107 $reportname = get_string('pluginname', 'gradereport_grader');
00108 
00110 print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
00111 
00112 //Initialise the grader report object that produces the table
00113 //the class grade_report_grader_ajax was removed as part of MDL-21562
00114 $report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);
00115 
00116 // make sure separate group does not prevent view
00117 if ($report->currentgroup == -2) {
00118     echo $OUTPUT->heading(get_string("notingroup"));
00119     echo $OUTPUT->footer();
00120     exit;
00121 }
00122 
00124 if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) {
00125     $warnings = $report->process_data($data);
00126 } else {
00127     $warnings = array();
00128 }
00129 
00130 
00131 // Override perpage if set in URL
00132 if ($perpageurl) {
00133     $report->user_prefs['studentsperpage'] = $perpageurl;
00134 }
00135 
00136 // final grades MUST be loaded after the processing
00137 $report->load_users();
00138 $numusers = $report->get_numusers();
00139 $report->load_final_grades();
00140 
00141 echo $report->group_selector;
00142 echo '<div class="clearer"></div>';
00143 // echo $report->get_toggles_html();
00144 
00145 //show warnings if any
00146 foreach($warnings as $warning) {
00147     echo $OUTPUT->notification($warning);
00148 }
00149 
00150 $studentsperpage = $report->get_pref('studentsperpage');
00151 // Don't use paging if studentsperpage is empty or 0 at course AND site levels
00152 if (!empty($studentsperpage)) {
00153     echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
00154 }
00155 
00156 $reporthtml = $report->get_grade_table();
00157 
00158 // print submit button
00159 if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading'))) {
00160     echo '<form action="index.php" method="post">';
00161     echo '<div>';
00162     echo '<input type="hidden" value="'.s($courseid).'" name="id" />';
00163     echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
00164     echo '<input type="hidden" value="grader" name="report"/>';
00165     echo $reporthtml;
00166     echo '<div class="submit"><input type="submit" value="'.s(get_string('update')).'" /></div>';
00167     echo '</div></form>';
00168 } else {
00169     echo $reporthtml;
00170 }
00171 
00172 // prints paging bar at bottom for large pages
00173 if (!empty($studentsperpage) && $studentsperpage >= 20) {
00174     echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
00175 }
00176 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations