[ Index ]

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

title

Body

[close]

/course/ -> reset.php (source)

   1  <?php  // $Id: reset.php,v 1.7.2.1 2007/11/29 14:40:50 skodak Exp $
   2  /*
   3  resetcourse.php  - Mark Flach and moodle.com
   4  The purpose of this feature is to quickly remove all user related data from a course
   5  in order to make it available for a new semester.  This feature can handle the removal
   6  of general course data like students, teachers, logs, events and groups as well as module
   7  specific data.  Each module must be modified to take advantage of this new feature.
   8  The feature will also reset the start date of the course if necessary.
   9  */
  10  
  11  require ('../config.php');
  12  require_once ('reset_form.php');
  13  
  14  $id = required_param('id', PARAM_INT);
  15  
  16  if (!$course = get_record('course', 'id', $id)) {
  17      error("Course is misconfigured");
  18  }
  19  
  20  require_login($course);
  21  require_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id));
  22  
  23  $strreset       = get_string('reset');
  24  $strresetcourse = get_string('resetcourse');
  25  $strremove      = get_string('remove');
  26  
  27  $navlinks = array(array('name' => $strresetcourse, 'link' => null, 'type' => 'misc'));
  28  $navigation = build_navigation($navlinks);
  29  
  30  $mform = new course_reset_form();
  31  
  32  if ($mform->is_cancelled()) {
  33      redirect($CFG->wwwroot.'/course/view.php?id='.$id);
  34  
  35  } else if ($data = $mform->get_data(false)) { // no magic quotes
  36  
  37      if (isset($data->selectdefault)) {
  38          $_POST = array();
  39          $mform = new course_reset_form();
  40          $mform->load_defaults();
  41  
  42      } else if (isset($data->deselectall)) {
  43          $_POST = array();
  44          $mform = new course_reset_form();
  45  
  46      } else {
  47          print_header($course->fullname.': '.$strresetcourse, $course->fullname.': '.$strresetcourse, $navigation);
  48          print_heading($strresetcourse);
  49  
  50          $data->reset_start_date_old = $course->startdate;
  51          $status = reset_course_userdata($data);
  52  
  53          $data = array();;
  54          foreach ($status as $item) {
  55              $line = array();
  56              $line[] = $item['component'];
  57              $line[] = $item['item'];
  58              $line[] = ($item['error']===false) ? get_string('ok') : '<div class="notifyproblem">'.$item['error'].'</div>';
  59              $data[] = $line;
  60          }
  61  
  62          $table = new object();
  63          $table->head  = array(get_string('resetcomponent'), get_string('resettask'), get_string('resetstatus'));
  64          $table->size  = array('20%', '40%', '40%');
  65          $table->align = array('left', 'left', 'left');
  66          $table->width = '80%';
  67          $table->data  = $data;
  68          print_table($table);
  69  
  70          print_continue('view.php?id='.$course->id);  // Back to course page
  71          print_footer($course);
  72          exit;
  73      }
  74  }
  75  
  76  print_header($course->fullname.': '.$strresetcourse, $course->fullname.': '.$strresetcourse, $navigation);
  77  print_heading($strresetcourse);
  78  
  79  print_simple_box(get_string('resetinfo'), 'center', '60%');
  80  
  81  $mform->display();
  82  print_footer($course);
  83  
  84  ?>


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