Source for file object_config.php

Documentation is available at object_config.php

  1. <?php
  2.     /**
  3.     * Quiz 1.0 configuration form.
  4.     *
  5.     * This is a fragment of HTML which gives the form elements for configuration of a quiz object, v1.0.
  6.     * ONLY the basic form elements should be included.
  7.     * The "form" tags and submit button are already specified outside.
  8.     * The $auth_obj and $sloodleauthid variables will identify the object being configured.
  9.     *
  10.     * @package sloodlequiz
  11.     * @copyright Copyright (c) 2008 Sloodle (various contributors)
  12.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  13.     *
  14.     * @contributor Peter R. Bloomfield
  15.     *
  16.     */
  17.     
  18.     // IMPORTANT: make sure this is called from within a Sloodle script
  19.     if (!defined('SLOODLE_VERSION')) {
  20.         error('Not called from within a Sloodle script.');
  21.         exit();
  22.     }
  23.     
  24.     // Execute everything within a function to ensure we don't mess up the data in the other file
  25.     sloodle_display_config_form($sloodleauthid$auth_obj);
  26.     
  27.     
  28.     
  29.     function sloodle_display_config_form($sloodleauthid$auth_obj)
  30.     {
  31.     //--------------------------------------------------------
  32.     // SETUP
  33.         
  34.         // Determine which course is being accessed
  35.         $courseid $auth_obj->course->get_course_id();
  36.         
  37.         // We need to fetch a list of visible quizzes on the course
  38.         // Get the ID of the chat type
  39.         $rec get_record('modules''name''quiz');
  40.         if (!$rec{
  41.             sloodle_debug("Failed to get quiz module type.");
  42.             exit();
  43.         }
  44.         $quizmoduleid $rec->id;
  45.         
  46.         // Get all visible quizzes in the current course
  47.         $recs get_records_select('course_modules'"course = $courseid AND module = $quizmoduleid AND visible = 1");
  48.         if (!$recs{
  49.             error(get_string('noquizzes','sloodle'));
  50.             exit();
  51.         }
  52.         $quizzes array();
  53.         foreach ($recs as $cm{
  54.             // Fetch the quiz instance
  55.             $inst get_record('quiz''id'$cm->instance);
  56.             if (!$instcontinue;
  57.             // Store the quiz details
  58.             $quizzes[$cm->id$inst->name;
  59.         }
  60.         // Sort the list by name
  61.         natcasesort($quizzes);
  62.         
  63.     //--------------------------------------------------------
  64.     // FORM
  65.     
  66.         // Get the current object configuration
  67.         $settings SloodleController::get_object_configuration($sloodleauthid);
  68.         
  69.         // Setup our default values
  70.         $sloodlemoduleid = (int)sloodle_get_value($settings'sloodlemoduleid'0);
  71.         $sloodlerepeat = (int)sloodle_get_value($settings'sloodlerepeat'0);
  72.         $sloodlerandomize = (int)sloodle_get_value($settings'sloodlerandomize'1);
  73.         $sloodledialog = (int)sloodle_get_value($settings'sloodledialog'1);
  74.         $sloodleplaysound = (int)sloodle_get_value($settings'sloodleplaysound'0);
  75.     
  76.     ///// GENERAL CONFIGURATION /////
  77.         print_box_start('generalbox boxaligncenter');
  78.         echo '<h3>'.get_string('generalconfiguration','sloodle').'</h3>';
  79.         
  80.         // Ask the user to select a quiz
  81.         echo get_string('selectquiz','sloodle').': ';
  82.         choose_from_menu($quizzes'sloodlemoduleid'$sloodlemoduleid'');
  83.         echo "<br><br>\n";
  84.         
  85.         // Repeat the quiz
  86.         echo get_string('repeatquiz','sloodle').' ';
  87.         choose_from_menu_yesno('sloodlerepeat'$sloodlerepeat);
  88.         echo "<br><br>\n";
  89.         
  90.         // Randomize the question order
  91.         echo get_string('randomquestionorder','sloodle').' ';
  92.         choose_from_menu_yesno('sloodlerandomize'$sloodlerandomize);
  93.         echo "<br><br>\n";
  94.     
  95.         // Use dialogs
  96.         echo get_string('usedialogs','sloodle').' ';
  97.         choose_from_menu_yesno('sloodledialog'$sloodledialog);
  98.         echo "<br><br>\n";
  99.         
  100.         // Play sounds
  101.         echo get_string('playsounds','sloodle').' ';
  102.         choose_from_menu_yesno('sloodleplaysound'$sloodleplaysound);
  103.         echo "<br>\n";
  104.         
  105.         print_box_end();
  106.         
  107.         
  108.     ///// ACCESS LEVELS /////
  109.         sloodle_print_access_level_options($settingstruefalsetrue);
  110.         
  111.     }
  112.     
  113. ?>

Documentation generated on Mon, 07 Jul 2008 12:33:06 +0100 by phpDocumentor 1.4.0