Source for file sl_teacher_courses_linker.php

Documentation is available at sl_teacher_courses_linker.php

  1. <?php    
  2.     /**
  3.     * Sloodle teacher courses linker.
  4.     *
  5.     * Allows an LSL script to retrieve a list of courses for which the specified user is a teacher.
  6.     *
  7.     * @package sloodlelogin
  8.     * @copyright Copyright (c) 2007 Sloodle (various contributors)
  9.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  10.     *
  11.     * @contributor Edmund Edgar
  12.     * @contributor Peter R. Bloomfield
  13.     *
  14.     */
  15.     
  16.     // This script is expected to be requested from with Second Life.
  17.     // The following parameters (GET or POST) are required:
  18.     //
  19.     //   sloodlepwd = the prim password
  20.     //   sloodleuuid = UUID of the user's avatar (note: optional if sloodleavname is provided)
  21.     //   sloodleavname = name of the user's avatar (note: optional if sloodleuuid is provided)
  22.     //
  23.     // The following parameter is optional:
  24.     //
  25.     //   sloodlecategoryid = ID of the category to which results should be limited (leave blank or set to 'all' to retrieve all categories)
  26.     //
  27.     
  28.     // The response code will 1 (OK) for success.
  29.     // Each data line will contain course information: "<id>|<shortname>|<fullname>"
  30.     
  31.     
  32.     require_once('../config.php');
  33.     require_once(SLOODLE_DIRROOT.'/sl_debug.php');
  34.     require_once(SLOODLE_DIRROOT.'/lib/sl_lsllib.php');
  35.     
  36.     
  37.     // Construct an LSL handler and process the basic request data
  38.     sloodle_debug_output('Constructing LSL handler...<br/>');
  39.     $lsl new SloodleLSLHandler();
  40.     sloodle_debug_output('Processing basic request data...<br/>');
  41.     $lsl->request->process_request_data();
  42.     
  43.     // Authenticate the request
  44.     sloodle_debug_output('Authenticating request...<br/>');
  45.     $lsl->request->authenticate_request();
  46.     
  47.     // Login the user identified in the request
  48.     sloodle_debug_output('Logging-in user...<br/>');
  49.     $lsl->login_by_request();
  50.     
  51.     // Retreive the category parameter
  52.     sloodle_debug_output('Fetching additional parameters...<br/>');
  53.     $sloodlecategoryid optional_param('sloodlecategoryid'NULLPARAM_INT);
  54.     if ($sloodlecategoryid == NULL$sloodlecategoryid 'all';
  55.     
  56.     // Fetch a list of all courses (just their ID's, short names, and long names)
  57.     sloodle_debug_output("Fetching list of all courses (category: $sloodlecategoryid)...<br/>");
  58.     // N.B.: ought to make this query more efficient by reducing number of retrieved fields
  59.     $courses get_courses($sloodlecategoryid);
  60.     // Go through each course
  61.     sloodle_debug_output('Iterating through courses...<br/>');
  62.     foreach ($courses as $c{
  63.         // Is the user a teacher of this course, or just an admin?
  64.         if (isteacher($c->id|| isadmin()) {
  65.             // Yes - add this to the response data
  66.             $lsl->response->add_data_line(array($c->id$c->shortname$c->fullname));
  67.         }
  68.     }
  69.     
  70.     // Output the response
  71.     sloodle_debug_output('Outputting response...<br/>');
  72.     $lsl->response->set_status_code(1);
  73.     $lsl->response->set_status_descriptor('OK');
  74.     sloodle_debug_output('<pre>');
  75.     $lsl->response->render_to_output();
  76.     sloodle_debug_output('</pre>');
  77.     
  78.     exit();
  79.  
  80. ?>

Documentation generated on Tue, 04 Mar 2008 15:08:55 +0000 by phpDocumentor 1.4.0