SLOODLE LSL API

From SLIS Second Life Wiki
Jump to: navigation, search

This page describes an API that is currently undergoing significant development. Information on this page may be inaccurate, and API calls may be renamed, added or deleted during development of the API. We hope developers will experiment with the API, and suggest improvements

Sloodle API

Imagine being able to access the power the MOODLE Learning Management System live on a webserver directly through your LSL code. Well, now you can! This is the beginning of an API to enable LSL developers to access data from the MOODLE LMS without having to have any prior knowledge to MOODLE coding. To get started, download and install the SLOODLE 1.1 branch here: [1]

Once installed, you need the in your Object to get going.

  1. sloodle_setup_notecard
  2. sloodle_transation_en
  3. _sloodle_api.lsl

You'll also need to generate a sloodle_config notecard. You can do this by creating a "Controller activity" in your MOODLE course. Once created, click on the controller activity, choose "Sloodle API HQ" Then choode "Generate notecard" Copy all the text, and paste it into a notecard in SL called "sloodle_config"

Once these scripts are in your object, you can use the commands below to access MOODLE data.

The _sloodle_api.lsl script listens on channel 998822, and responds on channel 998821. You can copy the declarations below and paste them in your code if you like.

integerPLUGIN_RESPONSE_CHANNEL =998822; //sloodle_api.lsl responses

integerPLUGIN_CHANNEL =998821;//sloodle_api requests

These channels can be changed if you edit the _sloodle_api.lsl script directly

In the list below, you will see the current list of linked messages that are part of the sloodle api

user.php awards.php general.php lessons.php groups.php
getClassList makeTransaction getSloodleObjects getLessons getUsersGrps
getAwardGrpMbrs getAwardGrps getLessonPages getGrps
addGrpMbr addAwardGrp getLessonAnswers
removeGrpMbr removeAwardGrp
getTeamScore getTeamScores
getAwards
registerScoreboard
deregisterScoreboard

To add more commands to the above list. The developer simply needs to create another .php file, and save it as: http://yoursite.com/moodle/mod/sloodle/mod/hq-1.0/plugins/yourplugin.php

/*********************************************
*  Copyright (c) 2009 yourname
*  Released under the GNU GPL 3.0
*  This script can be used in your scripts, but you must include this copyright header as per the GPL Licence 
*  For more information about GPL 3.0 - see: http://www.gnu.org/copyleft/gpl.html
*  This script is part of the SLOODLE Project see http://sloodle.org
*
* example_plugin.lsl
*  Copyright:
*  yourname
*  youremail
* 
* 
*/
integer PLUGIN_RESPONSE_CHANNEL                                =998822; //sloodle_api.lsl responses
integer PLUGIN_CHANNEL                                                    =998821;//sloodle_api requests

default {
   state_entry() {
       llOwnerSay("Example Plugin.  All commands sent to the _sloodle.api script go on channel 998822.\nAll responses come in on 998821");
   }//end state_entry

   touch_start(integer num_detected) {
   	llMessageLinked(LINK_SET, PLUGIN_CHANNEL, "PLUGIN:user,FUNCTION:getClassList\nAWARDID:"+(string)104+"\nSENDERUUID:"+(string)llGetOwner()+"|INDEX:0|SORTMODE:balance", NULL_KEY);
   }//end touch

   link_message(integer sender_num, integer channel, string str, key id) {
   	if (channel==PLUGIN_RESPONSE_CHANNEL){
   		llOwnerSay(str);
   	}
   }//end link_message

}//end state
Personal tools