GetLessonAnswers.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <!-- headlinks removed -->
  6. <link rel="shortcut icon" href="../../../../misc/favicon.ico"/>
  7. <title>GetLessonAnswers - SLIS Second Life Wiki</title>
  8. <style type="text/css">/*<![CDATA[*/ @import "../../../../skins/offline/main.css"; /*]]>*/</style>
  9. <link rel="stylesheet" type="text/css" media="print" href="../../../../skins/common/commonPrint.css" />
  10. <!--[if lt IE 5.5000]><style type="text/css">@import "../../../../skins/monobook/IE50Fixes.css";</style><![endif]-->
  11. <!--[if IE 5.5000]><style type="text/css">@import "../../../../skins/monobook/IE55Fixes.css";</style><![endif]-->
  12. <!--[if IE 6]><style type="text/css">@import "../../../../skins/monobook/IE60Fixes.css";</style><![endif]-->
  13. <!--[if IE]><script type="text/javascript" src="../../../../skins/common/IEFixes.js"></script>
  14. <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
  15. <script type="text/javascript" src="../../../../skins/common/wikibits.js"></script>
  16. <script type="text/javascript" src="../../../../skins/offline/md5.js"></script>
  17. <script type="text/javascript" src="../../../../skins/offline/utf8.js"></script>
  18. <script type="text/javascript" src="../../../../skins/offline/lookup.js"></script>
  19. </head>
  20. <body
  21. class="ns-0 ns-subject page-GetLessonAnswers">
  22. <div id="globalWrapper">
  23. <div id="column-content">
  24. <div id="content">
  25. <a name="top" id="contentTop"></a>
  26. <h1 class="firstHeading">GetLessonAnswers</h1>
  27. <div id="bodyContent">
  28. <h3 id="siteSub">From SLIS Second Life Wiki</h3>
  29. <div id="contentSub"></div>
  30. <!-- start content -->
  31. <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><table border="0" cellpadding="0" cellspacing="0" style="text-align: top; width: 95%;">
  32. <tr>
  33. <td> <a href="../../../../articles/s/l/o/SLOODLE_LSL_API.html" title="SLOODLE LSL API">Back to Sloodle API</a>
  34. </td></tr></table>
  35. <p><br />
  36. </p>
  37. <table border="2" cellpadding="0" cellspacing="0" style="text-align: top; width: 95%; color:#5a3696; border-color:black;">
  38. <tr>
  39. <td>
  40. <table border="0" style="width: 100%; background:#f4f8fb; color:#5a3696; font-weight:bold; font-size:180%;">
  41. <tr>
  42. <td>Function: getLessonAnswers
  43. </td></tr></table>
  44. </td></tr>
  45. <tr>
  46. <td>
  47. <table border="0">
  48. <tr>
  49. <td style="width: 100%; font-weight:bold;"> Description: Returns a list of lesson answers for the lessonid and pageid specified
  50. </td>
  51. <td> }
  52. </td></tr>
  53. <tr>
  54. <td>
  55. <table border="0">
  56. <tr>
  57. <td style="width: 10%; font-weight:bold;"> <font color="red">llMessageLinked</font>(<font color="green">LINK_SET</font>, PLUGIN_CHANNEL, "<font color="green">plugin:lessons,function:getLessonAnswers\nSLOODLEID:null\nindex:0|lessonsPerPage:9|lessonid:3|pageid:6</font>", <font color="red">NULL_KEY</font>);
  58. </td></tr></table>
  59. </td></tr>
  60. <tr>
  61. <td>
  62. <table border="0">
  63. <tr>
  64. <td style="width: 10%; font-weight:bold;" colspan="2"> Parameters:
  65. </td></tr>
  66. <tr>
  67. <td style="width: 10%; color:green;"> <b>SLOODLE_ID:null</b>
  68. </td>
  69. <td style="width: 90%;"> this is left as null because we aren't accessing a specific activity
  70. </td></tr>
  71. <tr>
  72. <td style="width: 10%; color:green;"> <b>INDEX</b>:
  73. </td>
  74. <td style="width: 90%;"> The index of the lesson page you'd like to start from
  75. </td></tr>
  76. <tr>
  77. <td style="width: 10%; color:green;"> <b>ITEMS_PER_PAGE</b>:
  78. </td>
  79. <td style="width: 90%;"> The number of items you'd like to appear in the output
  80. </td></tr>
  81. <tr>
  82. <td style="width: 10%; color:green;"> <b>LESSON ID</b>:
  83. </td>
  84. <td style="width: 90%;"> The id of lesson you want pages from
  85. </td></tr>
  86. <tr>
  87. <td style="width: 10%; color:green;"> <b>PAGE ID</b>:
  88. </td>
  89. <td style="width: 90%;"> The id of pageyou want answers from
  90. </td></tr></table>
  91. <p><br />
  92. </p>
  93. </td></tr>
  94. <tr>
  95. <td>
  96. <table border="0">
  97. <tr>
  98. <td style="width: 10%; font-weight:bold;"> Output:
  99. </td>
  100. <td style="width: 90%;"> <a href="../../../../articles/g/e/t/File:GetlessonAnswers.jpg.html" class="image"><img alt="GetlessonAnswers.jpg" src="../../../../images/a/2F/a/a/a6/GetlessonAnswers.jpg" width="777" height="167" /></a>
  101. </td></tr></table>
  102. <p><br />
  103. </p>
  104. </td></tr>
  105. <tr>
  106. <td>
  107. <table border="0">
  108. <tr>
  109. <td style="width: 10%; font-weight:bold;"> Example Script:
  110. </td>
  111. <td style="width: 90%;">
  112. <pre> /*********************************************
  113. * Copyright (c) 2009 Paul Preibisch
  114. * Released under the GNU GPL 3.0
  115. * This script can be used in your scripts, but you must include this copyright header as per the GPL Licence
  116. * For more information about GPL 3.0 - see: <a rel="nofollow" class="external free" href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>
  117. *
  118. *
  119. * This script is part of the SLOODLE Project see <a rel="nofollow" class="external free" href="http://sloodle.org">http://sloodle.org</a>
  120. *
  121. * Copyright:
  122. * Paul G. Preibisch (Fire Centaur in SL)
  123. * fire@b3dMultiTech.com
  124. *
  125. * API DEMO OBJECT
  126. * getLessonPages.lsl
  127. *
  128. * PURPOSE
  129. * This script is part of the SLOODLE HQ.
  130. *
  131. /**********************************************************************************************/
  132. key owner;
  133. // *************************************************** HOVER TEXT VARIABLES
  134. integer DISPLAY_DATA =-774477; //every time the display is updated, data goes on this channel
  135. integer PLUGIN_RESPONSE_CHANNEL =998822; //sloodle_api.lsl responses
  136. integer PLUGIN_CHANNEL =998821;//sloodle_api requests
  137. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;//translation channel
  138. integer SLOODLE_CHANNEL_TRANSLATION_RESPONSE = -1928374652;//translation channel
  139. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;//configuration channel
  140. /***********************************************
  141. * getFieldData-- returns data from a table based on the column name
  142. ***********************************************/
  143. string getFieldData(list tableRowData, string colName){
  144. return llList2String(tableRowData,llListFindList(tableRowData, [colName])+1);
  145. }
  146. /***********************************************
  147. * s() used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  148. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  149. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  150. * All this function does is strip off the text before the ":" char and return a string
  151. ***********************************************/
  152. string s (string ss){
  153. return llList2String(llParseString2List(ss, [":"], []),1);
  154. }
  155. /***********************************************
  156. * k() used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  157. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  158. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  159. * All this function does is strip off the text before the ":" char and return a key
  160. ***********************************************/
  161. key k (string kk){
  162. return llList2Key(llParseString2List(kk, [":"], []),1);
  163. }
  164. /***********************************************
  165. * counter() used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  166. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  167. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  168. * All this function does is strip off the text before the ":" char and return an integer
  169. ***********************************************/
  170. integer i (string ii){
  171. return llList2Integer(llParseString2List(ii, [":"], []),1);
  172. }
  173. /* &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
  174. *
  175. * default state
  176. * In this state we wait until the rest of the scripts in this object init
  177. *
  178. * &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp; */
  179. default{
  180. state_entry() {
  181. //set owner
  182. owner = llGetOwner();
  183. }
  184. link_message(integer sender_num, integer channel, string str, key id) {
  185. list dataLines=llParseString2List(str, ["\n"],[]);
  186. list cmdLine = llParseString2List(str, ["|"],[]);
  187. string cmd=s(llList2String(cmdLine,0));
  188. if (channel==PLUGIN_RESPONSE_CHANNEL){
  189. if (cmd=="API READY") state go;
  190. }//endif channel=PLUGIN_RESPONSE_CHANNEL
  191. }//end linked_message event
  192. /***********************************************
  193. * changed event
  194. * |--&gt;Every time the inventory changes, reset the script
  195. *
  196. ***********************************************/
  197. changed(integer change) {
  198. if (change ==CHANGED_INVENTORY){
  199. llResetScript();
  200. }//endif
  201. }//end changed state
  202. }//end default state
  203. /* &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
  204. *
  205. * go state
  206. * Now you can execute your logic because the api is ready
  207. *
  208. * &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp; */
  209. state go{
  210. touch_start(integer num_detected) {
  211. /*********************************************************************************
  212. * API CALL: getLessons: Return all lesson pages in the course
  213. **********************************************************************************/
  214. llMessageLinked(LINK_SET, PLUGIN_CHANNEL, "plugin:lessons,function:getLessonAnswers\nSLOODLEID:null\nindex:0|lessonsPerPage:9|lessonid:2|pageid:6", NULL_KEY);
  215. }
  216. link_message(integer sender_num, integer channel, string str, key id) {
  217. if (channel==PLUGIN_RESPONSE_CHANNEL){
  218. list dataLines = llParseStringKeepNulls(str,["\n"],[]);
  219. //get status code
  220. list statusLine =llParseString2List(llList2String(dataLines,0),["|"],[]);
  221. integer status =llList2Integer(statusLine,0);
  222. string descripter = llList2String(statusLine,1);
  223. string response = s(llList2String(dataLines,1));
  224. integer index = i(llList2String(dataLines,2));
  225. integer counter=0;
  226. if (response=="lessons|getLessonAnswers"){
  227. //check status of returned response
  228. if (status==1){
  229. //initialize the string we will print on xy_text channel
  230. //get all of the lesson activities returned
  231. list lessons = llList2List(dataLines, 5,llGetListLength(dataLines)-1);
  232. integer len = llGetListLength(lessons);
  233. list colNames =llParseString2List(llList2String(dataLines,4), ["|"], []);
  234. integer colLen = llGetListLength(colNames);
  235. list data;
  236. for (counter=0;counter&lt;len;counter++){
  237. list colData=llParseString2List(llList2String(lessons,counter), ["|"], []); //parse the message into a list
  238. integer j;
  239. //add all data from this line into a 2 dimensional list called tableRowData:
  240. //["nameOfColumn","value"]
  241. list tableRowData;
  242. for (j=0;j&lt;colLen;j++){
  243. tableRowData +=[llList2String(colNames,j),llList2String(colData,j)];
  244. llOwnerSay("// "+(string)(j+1)+") "+llList2String(colNames,j)+": "+llList2String(colData,j));
  245. }
  246. llOwnerSay("//********************************");
  247. }//for
  248. }//status==1
  249. }//endif response=="getLessonAnswers"
  250. }//end if channel==PLUGIN_RESPONSE_CHANNEL
  251. }//end link_message
  252. /***********************************************
  253. * changed event
  254. * |--&gt;Every time the inventory changes, reset the script
  255. *
  256. ***********************************************/
  257. changed(integer change) {
  258. if (change ==CHANGED_INVENTORY){
  259. llResetScript();
  260. }//endif
  261. }//end changed state
  262. }//end state
  263. </pre>
  264. <p><br />
  265. </p><p><br />
  266. </p><p><br />
  267. </p>
  268. </td></tr></table>
  269. <p><br />
  270. </p>
  271. </td></tr></table>
  272. </td>
  273. </tr>
  274. </table>
  275. <!--
  276. NewPP limit report
  277. Preprocessor node count: 5/1000000
  278. Post‐expand include size: 0/2097152 bytes
  279. Template argument size: 0/2097152 bytes
  280. Expensive parser function count: 0/100
  281. -->
  282. </div><div class="printfooter">
  283. </div>
  284. <div id="catlinks"><div id='catlinks' class='catlinks'><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="http://localhost/sl/index.php/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="../../../../articles/i/n/w/Category:Inworld_API.html" title="Category:Inworld API">Inworld API</a></li></ul></div></div></div> <!-- end content -->
  285. <div class="visualClear"></div>
  286. </div>
  287. </div>
  288. </div>
  289. <div id="column-one">
  290. <div id="p-cactions" class="portlet">
  291. <h5>Views</h5>
  292. <ul>
  293. <li id="ca-nstab-main"
  294. class="selected" ><a href="../../../../articles/g/e/t/GetLessonAnswers.html">Page</a></li><li id="ca-talk"
  295. class="new" ><a href="http:http://localhost/sl/index.php?title=Talk:GetLessonAnswers&amp;action=edit&amp;redlink=1">Discussion</a></li><li id="ca-current"
  296. ><a href="http://localhost/sl/index.php/GetLessonAnswers">Latest revision</a></li> </ul>
  297. </div>
  298. <div class="portlet" id="p-logo">
  299. <a style="background-image: url(../../../../misc/wiki.png);"
  300. href="../../../../index.html"
  301. title="Main Page"></a>
  302. </div>
  303. <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
  304. <div class='portlet' id='p-navigation'>
  305. <h5>Navigation</h5>
  306. <div class='pBody'>
  307. <ul>
  308. <li id="n-mainpage-description"><a href="../../../../index.html">Main page</a></li>
  309. <li id="n-SLOODLE"><a href="../../../../articles/s/l/o/Sloodle.html">SLOODLE</a></li>
  310. <li id="n-currentevents"><a href="../../../../articles/c/u/r/SLIS_Second_Life_Wiki:Current_events.html">Current events</a></li>
  311. <li id="n-help"><a href="../../../../articles/c/o/n/Help:Contents.html">Help</a></li>
  312. </ul>
  313. </div>
  314. </div>
  315. <div class='portlet' id='p-SEARCH'>
  316. <h5>Search</h5>
  317. <div class='pBody'>
  318. <ul>
  319. </ul>
  320. </div>
  321. </div>
  322. <div class='portlet' id='p-TOOLBOX'>
  323. <h5>Toolbox</h5>
  324. <div class='pBody'>
  325. <ul>
  326. </ul>
  327. </div>
  328. </div>
  329. <div class='portlet' id='p-LANGUAGES'>
  330. <h5>LANGUAGES</h5>
  331. <div class='pBody'>
  332. <ul>
  333. </ul>
  334. </div>
  335. </div>
  336. <div id="p-search" class="portlet">
  337. <h5><label for="searchInput">Search</label></h5>
  338. <div id="searchBody" class="pBody">
  339. <form action="javascript:goToStatic(3)" id="searchform"><div>
  340. <input id="searchInput" name="search" type="text"
  341. accesskey="f" value="" />
  342. <input type='submit' name="go" class="searchButton" id="searchGoButton"
  343. value="Go" />
  344. </div></form>
  345. </div>
  346. </div>
  347. </div><!-- end of the left (by default at least) column -->
  348. <div class="visualClear"></div>
  349. <div id="footer">
  350. <div id="f-poweredbyico"><a href="//www.mediawiki.org/"><img src="../../../../skins/common/images/poweredby_mediawiki_88x31.png" height="31" width="88" alt="Powered by MediaWiki" /></a></div> <ul id="f-list">
  351. <li id="f-credits">This page was last modified 21:50, 18 October 2009 by <a href="http:http://localhost/sl/index.php?title=User:Fire&amp;action=edit&amp;redlink=1" class="new" title="User:Fire (page does not exist)">Paul Preibisch</a>. </li> <li id="f-about"><a href="../../../../articles/a/b/o/SLIS_Second_Life_Wiki:About.html" title="SLIS Second Life Wiki:About">About SLIS Second Life Wiki</a></li> <li id="f-disclaimer"><a href="../../../../articles/g/e/n/SLIS_Second_Life_Wiki:General_disclaimer.html" title="SLIS Second Life Wiki:General disclaimer">Disclaimers</a></li> </ul>
  352. </div>
  353. </div>
  354. </body>
  355. </html>