[ Index ]

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

title

Body

[close]

/grade/import/xml/ -> index.php (source)

   1  <?php  //$Id: index.php,v 1.21 2007/10/07 10:22:22 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://moodle.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  
  26  require_once '../../../config.php';
  27  require_once  'lib.php';
  28  require_once  'grade_import_form.php';
  29  
  30  $id = required_param('id', PARAM_INT); // course id
  31  
  32  if (!$course = get_record('course', 'id', $id)) {
  33      print_error('nocourseid');
  34  }
  35  
  36  require_login($course);
  37  $context = get_context_instance(CONTEXT_COURSE, $id);
  38  require_capability('moodle/grade:import', $context);
  39  require_capability('gradeimport/xml:view', $context);
  40  
  41  // print header
  42  $strgrades = get_string('grades', 'grades');
  43  $actionstr = get_string('modulename', 'gradeimport_xml');
  44  $navigation = grade_build_nav(__FILE__, $actionstr, array('courseid' => $course->id));
  45  
  46  if (!empty($CFG->gradepublishing)) {
  47      $CFG->gradepublishing = has_capability('gradeimport/xml:publish', $context);
  48  }
  49  
  50  $mform = new grade_import_form();
  51  
  52  if ($data = $mform->get_data()) {
  53      // Large files are likely to take their time and memory. Let PHP know
  54      // that we'll take longer, and that the process should be recycled soon
  55      // to free up memory.
  56      @set_time_limit(0);
  57      @raise_memory_limit("256M");
  58      if (function_exists('apache_child_terminate')) {
  59          @apache_child_terminate();
  60      }
  61  
  62      if ($text = $mform->get_file_content('userfile')) {
  63          print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
  64          print_grade_plugin_selector($id, 'import', 'xml');
  65  
  66          $error = '';
  67          $importcode = import_xml_grades($text, $course, $error);
  68          if ($importcode) {
  69              grade_import_commit($id, $importcode, $data->feedback, true);
  70              print_footer();
  71              die;
  72          } else {
  73              notify($error);
  74              print_continue($CFG->wwwroot.'/grade/index.php?id='.$course->id);
  75              print_footer();
  76              die;
  77          }
  78  
  79      } else if (empty($data->key)) {
  80          redirect('import.php?id='.$id.'&amp;feedback='.(int)($data->feedback).'&url='.urlencode($data->url));
  81  
  82      } else {
  83          if ($data->key == 1) {
  84              $data->key = create_user_key('grade/import', $USER->id, $course->id, $data->iprestriction, $data->validuntil);
  85          }
  86  
  87          print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
  88          print_grade_plugin_selector($id, 'import', 'xml');
  89  
  90          echo '<div class="gradeexportlink">';
  91          $link = $CFG->wwwroot.'/grade/import/xml/fetch.php?id='.$id.'&amp;feedback='.(int)($data->feedback).'&amp;url='.urlencode($data->url).'&amp;key='.$data->key;
  92          echo get_string('import', 'grades').': <a href="'.$link.'">'.$link.'</a>';
  93          echo '</div>';
  94          print_footer();
  95          die;
  96      }
  97  }
  98  
  99  print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
 100  print_grade_plugin_selector($id, 'import', 'xml');
 101  
 102  $mform->display();
 103  
 104  print_footer();
 105  
 106  ?>


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