Fileref:mod/choice/sl choice linker.php
This Linker Script allows the Sloodle Choice object in Second Life to query and interact with instances of the Moodle choice module. It has 3 modes of operation:
- Available choices query : returns a list of choice module instances available in the specified course
- Choice details query : returns the details for a specific choice instance
- Option selection : informs Moodle that a user has made a selection
By default, the script behaves in mode 1, unless the parameters for other modes are specified.
Contents |
Additional Information
Debug mode will output additional data, indicating what is happening at all points in the script.
Dependencies
Sloodle files:
Request Parameters
The following parameters are always required:
- sloodlepwd = the prim password used to authenticate the choice object for this site
- sloodlecourseid = ID of the course which the request relates to
The following additional parameter is required for modes 2 and 3:
- sloodlemoduleid = course module instance ID of the desired choice
The following additional parameters are also required for mode 3:
- sloodleoptionid = ID of the choice option being selected
- sloodleuuid = the SL UUID of the agent chatting (optional if 'sloodleavname' is specified)
- sloodleavname = the name of the agent chatting (optional if 'sloodleuuid' is specified)
The following parameter is always optional:
- sloodledebug = activates debug mode
Note: if parameter 'sloodleoptionid' is specified, then script will attempt to adopt mode 3. If not, but 'sloodlemoduleid' is specified, then it adopts mode 2. Otherwise, it will default to mode 1.
Response
- Note: the response format is likely to change slightly, to bring it into line with other linker scripts.
Mode 1
If a list of at least one choice in the specified course has been successfully retrieved, the status code returned is 10021. The first line indicates the number of choices available, while each subsequent line describes a choice instance, as follows:
10021|CHOICE_LIST_QUERY
num_instances|{integer: number of choice instances in the course}
choice_instance|{integer: id number of instance}|{string: name of instance}
The "id number of instance" value is the number that should be passed in via parameter 'sloodlemoduleid' for modes 2 and 3. The following example shows a possible response from a course with 3 choices:
10021|CHOICE_LIST_QUERY num_instances|3 choice_instance|18|Operating system survey choice_instance|23|Favourite programming language choice_instance|24|Number of computers owned
If no choices are available, then the status code will be -10022. If a general error occurs while querying for choices, the status code will be -10021. In either case, an error message will be contained in the data line. (Other standard error codes may also be returned).
- Note: it is likely that the status code will become 1 for success, the first data line will be omitted completely, and the "choice_instance|" will be removed from the beginning of every subsequent line. This makes the communications more data-efficient, and is in line with the other tools.
Mode 2
If successful in querying for the details of a choice, the status code will be 10001, and there will be several data lines, as follows:
10001|CHOICE_QUERY
choice_name|{string:name of choice}
choice_text|{string:text of choice (i.e. question)}
num_options|{integer:number of options}
option|{integer:option id}|{string:option text}|{integer:number selected so far}
num_unanswered|{integer:number of students not yet answered}
accepting_answers|{true/false:is the choice currently open?}
The "option id" integer is the value that should be passed in via parameter 'sloodleoptionid' for mode 3.
(Note: the ordering of the lines can be arbitrary!) There will be as many "option|..." lines as there are options in the choice. The number selected so far of each option (and the number not yet answered) will be -1 if the information is not to be displayed.
Here is an example of a choice which has been closed, and for which the results are visible, but the number of people who didn't choose is not visible:
10001|CHOICE_QUERY choice_name|Cheese Survey choice_text|Which of these cheeses do you like best? num_options|4 option|1|Stilton|2 option|2|Wensleydale|7 option|3|Parmesan|4 option|4|None of them|6 num_unanswered|-1 accepting_answers|false
If the linker script fails to query for details of the choice, then the status code will be -10001. (Other standard error codes may also be returned).
- Note: in order to bring the choice linker into line with other scripts, the status code for success in mode 2 is likely to become 1. Otherwise, the format for the response is likely to remain the same.
Mode 3
If successful in selecting an option, the script will respond with status code 10011, and there will be no data line. (Eventually, the status code will likely become 1 for success).
If the choice has been closed and selections are therefore no longer being accepted, the status code returned will be -10014, and an error message will be contained in the data line. (Other standard error codes may also be returned).
Algorithm
- Fetch the custom parameter ('sloodleoptionid')
- Create SloodleLSLHandler object
- Process request data
- Authenticate request
- Fetch course record (terminate on failure)
- Was module ID omitted? If so than enter mode 1:
- Fetch list of available choices in course (terminate on failure)
- Were there no available choices in the course? If so then:
- Output error message
- Terminate script
- Output number of available choices
- Iterate through choices and output each one
- Render response
- Terminate script
- Retrieve course module instance (terminate on failure)
- Retreive choice record from database (terminate on failure)
- Was the option ID omitted? If yes then enter mode 2:
- Determine if choice is open
- Determine if results should be shown publicly in-world
- Determine if the number of unanswered users should be displayed? If yes then:
- Calculate how many have not answered
- Prepare other choice data
- Output choice data
- Iterate through each option and output it
- Render response
- Terminate script
- (Falling through to mode 3)
- Attempt to login the user (terminate on failure)
- Ensure user is enrolled in the course (terminate on failure)
- Attempt to select the appropriate choice option
- Output success/failure
- Render response
- Terminate script
See Also
| This page is part of the SLOODLE documentation | |||
|---|---|---|---|
| Docs: Users | Administrators | Developers | |||
| Wiki Frontpage Sloodle.org | |||