ITS Mobile API  2
ITS API
 All Data Structures Files Functions Variables Pages
ITS_ajax_mobile.php File Reference

ITS mobile AJAX code for interfacing between the client and server side. More...

Detailed Description

ITS mobile AJAX code for interfacing between the client and server side.

Author
Ricky Liou (rliou.nosp@m.92@g.nosp@m.mail..nosp@m.com)
Date
February 20, 2014
Parameters
[in]'id'new user id
[in]'action'ITS screen action ('q', 'r', 's', 'm', 'submit', 'skip')
[in]'data'general purpose data dependent on the action
[out]$JSON_arrayJSON formatted array containing the output data
Parameter Detailed Descriptions
  • 'data'
    The input data is dependent on the 'action' parameter. If 'action' is:

    'q':

    If set, changes current chapter number.

    'r':

    If set, review index is incremented if positive, decremented if negative, or reset if 0. If index is out-of-bounds, it will not change.

    's':

    N/A

    'm':

    N/A

    'submit':

    Question id, question type, and user answer delimited by '~'

    Question id: question id number

    Question type: 'c', 'm', 'mc'

    User answer: array of user answers dependent on question type:

    'c': Number

    'mc': Single uppercase letter

    'm': Comma separated uppercase letters in order with respect to the left hand side

    'skip':

    Question id of question skipped

  • '$JSON_array'
    JSON array fields:

    'ridx_end':

    Returned if the review index is manipulated. 1 = reached max index value. -1 = reached min index value.

    'Q-feedback':

    Returned after a question is submitted. Content depends on question type:

    'c':

    array[0] = answer, array[1] = tolerance limits

    'mc':

    Array of percentages of all current term student answers for each answer in order

    'm':

    Array of scores for each left hand side value in order

    'content':

    ITS screen content dependent on action:

    's':

    "Module": Module number

    "Scores": Points earned in respective module

    "Percentage": Earned points / available points

    "Attem": Number of attempted questions

    "Avail": Number of available questions

    'q':

    "Q-type": mc,c,m

    "Q-title": Title string

    "Q-question": Question string

    "Q-answers": Number of total answers

    "Q-answers-values": Array of answer values

    "Q-image": Image id number

    'r':

    "Q-type": m,mc,c

    "Q-title": Title string

    "Q-question": Question string

    "Q-answers": Number of total answers

    "Q-answers-values": Array of answer values

    "Q-image": Image id number

    "user_answer": User's submitted answer

    "user_score": User's score

    'm':

    Current active chapter

Note
For "Q-answers-values", the data depends on the question type:
c: N/A
mc: array{'answer1' => ..., 'answer2' => ..., ...}
m [For text right hand side fields]: array{array{'L_fields1' => ..., 'L_fields2' => ..., ...}, array{'R_field1' => ...,'R_field2' => ..., ...}}
m [For image right hand side fields]: array{array{'L_fields1' => ..., 'L_fields2' => ..., ...}, array{'Rimage1' => ..., 'Rimage2' => ..., ...}, 1}

Note
For matching Q-statistics NULL is essentially a zero, means student picked a answer choice that has no corresponding answer.

The client makes AJAX requests to this script. This script calls the ITS_screen_mobile class with the appropriate arguments and returns the data to the client in the JSON format.

A user session must first be created by supplying the user id. In all other AJAX calls the 'id' field should then be obmitted.

First AJAX call example:

$.get('ajax/ITS_ajax_mobile.php', {id: 1, mode: 'q'}, function(data){...})

Subsquent AJAX call example:

$.get('ajax/ITS_ajax_mobile.php', {mode: 'r', data: 1}, function(data){...})

Error codes:

Todo:

Formatting of documentation is good enough for now.

Session ending / logging off??

Warning
The review index does not change if called too quickly successive times.