[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/grade/report/grader/ -> preferences.php (source)

   1  <?php // $Id: preferences.php,v 1.25.2.2 2007/12/19 17:38:46 skodak Exp $
   2  
   3  ///////////////////////////////////////////////////////////////////////////
   4  //                                                                       //
   5  // NOTICE OF COPYRIGHT                                                   //
   6  //                                                                       //
   7  // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
   8  //          http://moodle.com                                            //
   9  //                                                                       //
  10  // Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
  11  //                                                                       //
  12  // This program is free software; you can redistribute it and/or modify  //
  13  // it under the terms of the GNU General Public License as published by  //
  14  // the Free Software Foundation; either version 2 of the License, or     //
  15  // (at your option) any later version.                                   //
  16  //                                                                       //
  17  // This program is distributed in the hope that it will be useful,       //
  18  // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
  19  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
  20  // GNU General Public License for more details:                          //
  21  //                                                                       //
  22  //          http://www.gnu.org/copyleft/gpl.html                         //
  23  //                                                                       //
  24  ///////////////////////////////////////////////////////////////////////////
  25  set_time_limit(0);
  26  require_once '../../../config.php';
  27  require_once $CFG->libdir . '/gradelib.php';
  28  require_once  '../../lib.php';
  29  
  30  $courseid      = required_param('id', PARAM_INT);
  31  
  32  /// Make sure they can even access this course
  33  
  34  if (!$course = get_record('course', 'id', $courseid)) {
  35      print_error('nocourseid');
  36  }
  37  
  38  require_login($course->id);
  39  
  40  $context = get_context_instance(CONTEXT_COURSE, $course->id);
  41  $systemcontext = get_context_instance(CONTEXT_SYSTEM);
  42  require_capability('gradereport/grader:view', $context);
  43  
  44  require ('preferences_form.php');
  45  $mform = new grader_report_preferences_form('preferences.php', compact('course'));
  46  
  47  if ($mform->is_cancelled()){
  48      redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid);
  49  }
  50  
  51  // If data submitted, then process and store.
  52  if ($data = $mform->get_data()) {
  53      foreach ($data as $preference => $value) {
  54          if (substr($preference, 0, 6) !== 'grade_') {
  55              continue;
  56          }
  57  
  58          if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
  59              unset_user_preference($preference);
  60          } else {
  61              set_user_preference($preference, $value);
  62          }
  63      }
  64  
  65      redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid); // message here breaks accessability and is sloooowww
  66      exit;
  67  }
  68  
  69  $strgrades = get_string('grades');
  70  $strgraderreport = get_string('modulename', 'gradereport_grader');
  71  $strgradepreferences = get_string('gradepreferences', 'grades');
  72  
  73  $navigation = grade_build_nav(__FILE__, $strgradepreferences, $courseid);
  74  
  75  print_header_simple($strgrades.': '.$strgraderreport . ': ' . $strgradepreferences,': '.$strgradepreferences, $navigation,
  76                      '', '', true, '', navmenu($course));
  77  
  78  /// Print the plugin selector at the top
  79  print_grade_plugin_selector($course->id, 'report', 'grader');
  80  
  81  // Add tabs
  82  $currenttab = 'preferences';
  83  include ('tabs.php');
  84  
  85  // If USER has admin capability, print a link to the site config page for this report
  86  if (has_capability('moodle/site:config', $systemcontext)) {
  87      echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportgrader">';
  88      echo get_string('changereportdefaults', 'grades');
  89      echo "</a></div>\n";
  90  }
  91  
  92  print_simple_box_start("center");
  93  
  94  $mform->display();
  95  print_simple_box_end();
  96  
  97  print_footer($course);
  98  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7