Dokeos PHP Cross Reference Learning Management Systems

Source: /main/exercice/addlimits.php - 252 lines - 7595 bytes - Summary - Text - Print

Description: Adding limits

   1  <?php
   2  /*

   3      DOKEOS - elearning and course management software

   4  

   5      For a full list of contributors, see documentation/credits.html

   6  

   7      This program is free software; you can redistribute it and/or

   8      modify it under the terms of the GNU General Public License

   9      as published by the Free Software Foundation; either version 2

  10      of the License, or (at your option) any later version.

  11      See "documentation/licence.html" more details.

  12  

  13      Contact:

  14          Dokeos

  15          Rue des Palais 44 Paleizenstraat

  16          B-1030 Brussels - Belgium

  17          Tel. +32 (2) 211 34 56

  18  */
  19  
  20  
  21  /**

  22  *    Adding limits

  23  *    @package dokeos.exercise

  24  *     @author

  25  *     @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $

  26  */
  27  /*

  28  -----------------------------------------------------------

  29      including the global file

  30  -----------------------------------------------------------

  31  */
  32  include ('../inc/global.inc.php');
  33  
  34  /*

  35  -----------------------------------------------------------

  36      Including necessary files

  37  -----------------------------------------------------------

  38  */
  39  include ('exercise.class.php');
  40  include ('question.class.php');
  41  include ('answer.class.php');
  42  include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  43  
  44  /*

  45  -----------------------------------------------------------

  46      Answer types

  47  -----------------------------------------------------------

  48  */
  49  define('UNIQUE_ANSWER',    1);
  50  define('MULTIPLE_ANSWER',    2);
  51  define('FILL_IN_BLANKS',    3);
  52  define('MATCHING',        4);
  53  define('FREE_ANSWER', 5);
  54  
  55  /*

  56  -----------------------------------------------------------

  57      Language

  58  -----------------------------------------------------------

  59  */
  60  // name of the language file that needs to be included

  61  $language_file='exercice';
  62  
  63  /*

  64  -----------------------------------------------------------

  65      section (for the tabs)

  66  -----------------------------------------------------------

  67  */
  68  $this_section=SECTION_COURSES;
  69  
  70  api_protect_course_script();
  71  
  72  /*

  73  -----------------------------------------------------------

  74      Table definitions

  75      @todo: use the Database :: get_course_table functions

  76  -----------------------------------------------------------

  77  */
  78  $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  79  $TBL_EXERCICES         = Database::get_course_table(TABLE_QUIZ_TEST);
  80  $TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
  81  $TBL_REPONSES          = Database::get_course_table('quiz_answer');
  82  $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  83  $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  84  $TBL_TRACK_EXERCICES    = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  85  $TBL_TRACK_ATTEMPT        = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  86  
  87  $dsp_percent = false;
  88  $debug=0;
  89  if($debug>0)
  90  {
  91      echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
  92  }
  93  // general parameters passed via POST/GET

  94  if ( empty ( $origin ) )
  95  {
  96      $origin = $_REQUEST['origin'];
  97  }
  98  if ( empty ( $learnpath_id ) )
  99  {
 100      $learnpath_id       = $_REQUEST['learnpath_id'];
 101  }
 102  if ( empty ( $learnpath_item_id ) )
 103  {
 104      $learnpath_item_id  = $_REQUEST['learnpath_item_id'];
 105  }
 106  if ( empty ( $formSent ) )
 107  {
 108      $formSent= $_REQUEST['formSent'];
 109  }
 110  if ( empty ( $exerciseResult ) )
 111  {
 112      $exerciseResult = $_SESSION['exerciseResult'];
 113  }
 114  if ( empty ( $questionId ) )
 115  {
 116      $questionId = $_REQUEST['questionId'];
 117  }
 118  if ( empty ( $choice ) ) {
 119      $choice = $_REQUEST['choice'];
 120  }
 121  if ( empty ( $questionNum ) )
 122  {
 123      $questionNum    = $_REQUEST['questionNum'];
 124  }
 125  if ( empty ( $nbrQuestions ) )
 126  {
 127      $nbrQuestions   = $_REQUEST['nbrQuestions'];
 128  }
 129  if ( empty ( $questionList ) )
 130  {
 131      $questionList = $_SESSION['questionList'];
 132  }
 133  if ( empty ( $objExercise ) )
 134  {
 135      $objExercise = $_SESSION['objExercise'];
 136  }
 137  $exercise_id = intval($_GET['exercise_id']);
 138  $is_allowedToEdit=$is_courseAdmin;
 139  
 140  if (isset($_SESSION['gradebook'])){
 141      $gradebook=    $_SESSION['gradebook'];
 142  }
 143  
 144  if (!empty($gradebook) && $gradebook=='view') {    
 145      $interbreadcrumb[]= array (
 146              'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
 147              'name' => get_lang('Gradebook')
 148          );
 149  }
 150  $nameTools=get_lang('Exercice');
 151  $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
 152  Display::display_tool_header($nameTools,"Exercise");
 153  
 154  /*

 155  -----------------------------------------------------------

 156      Action handling

 157  -----------------------------------------------------------

 158  */
 159  include ('../inc/global.inc.php');
 160  if (isset($_POST['ok']))
 161  {
 162      $message = get_lang('TestLimitsAdded');
 163      Display::display_normal_message($message);
 164  }
 165  ?>
 166    <script type="text/javascript">
 167    function selectlimited()
 168    {
 169        document.getElementById('limited').checked="checked";
 170    }
 171     function selectattempts()
 172    {
 173        document.getElementById('attemptlimited').checked="checked";
 174    }
 175    </script>
 176    <h3><?php  echo get_lang('AddLimits'); ?></h3>
 177  <br>
 178  <form action="addlimits.php" name="frmlimit" method="post">
 179  <h4>
 180  Time :
 181  </h4>
 182  <input type="hidden" name="exe_id" value="<?php echo $exercise_id; ?>" />
 183  <input type="radio" name="limit" checked="checked" value="0" id="unlimit"><?php echo get_lang('Unlimited'); ?>
 184  <br>
 185  <input type="radio" name="limit" value="1" id="limited"><?php echo get_lang('LimitedTime'); ?>
 186  <select name="minutes" onfocus="selectlimited();" >
 187    <option selected="selected">1</option>
 188    <option>2</option>
 189    <option>3</option>
 190    <option>4</option>
 191    <option>5</option>
 192    <option>6</option>
 193    <option>7</option>
 194    <option>8</option>
 195    <option>9</option>
 196    <option>10</option>
 197    <option>15</option>
 198    <option>20</option>
 199    <option>25</option>
 200    <option>30</option>
 201    <option>40</option>
 202    <option>50</option>
 203    <option>60</option>
 204  </select><?php echo get_lang('Minutes'); ?>.
 205  <h4>
 206  <?php echo get_lang('Attempts'); ?>:
 207  </h4>
 208  <input type="radio" name="attempt" checked="checked" value="0" id="attemptunlimited"><?php echo get_lang('Unlimited'); ?>
 209  <br>
 210  <input type="radio" name="attempt" value="1" id="attemptlimited"><?php echo get_lang('LimitedAttempts'); ?>
 211  <select name="attempts" onfocus="selectattempts();">
 212    <option selected="selected">1</option>
 213    <option>2</option>
 214    <option>3</option>
 215    <option>4</option>
 216    <option>5</option>
 217    <option>6</option>
 218    <option>7</option>
 219    <option>8</option>
 220    <option>9</option>
 221    <option>10</option>
 222    </select><?php echo get_lang('Times'); ?>.
 223  
 224  <br> <br>
 225  <input type="submit" name="ok" value="<?php echo get_lang('Ok'); ?>">
 226  </form>
 227  <?php
 228  /**

 229   * @todo shouldn't this be moved to the part above (around line 111: action handling)

 230   */
 231  if (isset($_POST['ok'])) {
 232      $exercise_id = Database::escape_string($_POST['exe_id']);    
 233      if ($_POST['limit']==1) {
 234          $minutes = Database::escape_string($_POST['minutes']);
 235          $query = "UPDATE ".$TBL_EXERCICES." SET ques_time_limit= $minutes where id= $exercise_id";
 236          api_sql_query($query,__FILE__,__LINE__);
 237      } else {
 238          $query = "UPDATE ".$TBL_EXERCICES." SET ques_time_limit= 0 WHERE id= $exercise_id";
 239          api_sql_query($query,__FILE__,__LINE__);
 240      }
 241  
 242      if ($_POST['attempt']==1) {
 243          $attempts = Database::escape_string($_POST['attempts']);
 244          $query = "UPDATE ".$TBL_EXERCICES." SET num_attempts = $attempts WHERE id= $exercise_id";
 245          api_sql_query($query,__FILE__,__LINE__);
 246      } else {
 247          $query = "UPDATE ".$TBL_EXERCICES." SET num_attempts = 0 WHERE id= $exercise_id";
 248          api_sql_query($query,__FILE__,__LINE__);
 249      }
 250  }
 251  ?>
 252  

title

Description

title

Description

title

Description

title

title

Body