Source for file object_config.php

Documentation is available at object_config.php

  1. <?php
  2.     /**
  3.     * PrimDrop 1.0 configuration form.
  4.     *
  5.     * This is a fragment of HTML which gives the form elements for configuration of a PrimDrop 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 sloodleprimdrop
  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 Sloodle Object assignments on the course
  38.         // Get the ID of the assignment type
  39.         $rec get_record('modules''name''assignment');
  40.         if (!$rec{
  41.             sloodle_debug("Failed to get assignment module type.");
  42.             exit();
  43.         }
  44.         $assignmentmoduleid $rec->id;
  45.         
  46.         // Get all visible assignments in the current course
  47.         $recs get_records_select('course_modules'"course = $courseid AND module = $assignmentmoduleid AND visible = 1");
  48.         if (!$recs{
  49.             error(get_string('noassignments','sloodle'));
  50.             exit();
  51.         }
  52.         $assignments array();
  53.         foreach ($recs as $cm{
  54.             // Fetch the assignment instance
  55.             $inst get_record('assignment''id'$cm->instance);
  56.             if (!$instcontinue;
  57.             // Ignore anything except Sloodle Object assignments
  58.             if ($inst->assignmenttype != 'sloodleobject'continue;
  59.             // Store the assignment details
  60.             $assignments[$cm->id$inst->name;
  61.         }
  62.         
  63.         // Make sure that we got some Sloodle Object assignments
  64.         if (count($assignments== 0{
  65.             error(get_string('nosloodleassignments','sloodle'));
  66.             exit();
  67.         }
  68.         
  69.         // Sort the list by name
  70.         natcasesort($assignments);
  71.         
  72.     //--------------------------------------------------------
  73.     // FORM
  74.     
  75.         // Get the current object configuration
  76.         $settings SloodleController::get_object_configuration($sloodleauthid);
  77.         
  78.         // Setup our default values
  79.         $sloodlemoduleid = (int)sloodle_get_value($settings'sloodlemoduleid'0);
  80.     
  81.     ///// GENERAL CONFIGURATION /////
  82.         print_box_start('generalbox boxaligncenter');
  83.         echo '<h3>'.get_string('generalconfiguration','sloodle').'</h3>';
  84.         
  85.         // Ask the user to select an assignment
  86.         echo get_string('selectassignment','sloodle').': ';
  87.         choose_from_menu($assignments'sloodlemoduleid'$sloodlemoduleid'');
  88.         echo "<br>\n";
  89.         
  90.         print_box_end();
  91.         
  92.         
  93.     ///// ACCESS LEVELS /////
  94.         sloodle_print_access_level_options($settings);
  95.         
  96.     }
  97.     
  98. ?>

Documentation generated on Fri, 17 Jul 2009 11:02:14 +0100 by phpDocumentor 1.4.0