/* strings used in administrative pages to send requests to the server (WAMP version) */
/* Note: svyUserServerHeaders.js contains other headers used in administrative pages */


/* dsurveyVersionAdmin:
   The dsurvey version (admin)
*/
dsurveyVersionAdmin='WAMP 04March2011 ';

/* todos done: 1 2  3 5 (4 7 76 124)  6 61 33 121 122 131  132 322    77 500 403

Not done:
  backupSessionURL='/dsurvey/dsurvey?todo=421';
  postParticipantFile="todo=213&";

*/

/* getSessionDescriptorURL (todo=3): the basic URL to use to request the contents of a session-dsecriptor file (an XML file) (todo=3).
   Note that the session name will be added at the end of this.
*/
getSessionDescriptorURL='/dsurvey/client/phps/returnSessDesc.php?name=';

/* getCurrentSessionsURL: the URL that   will return a list of sessions.   (todo=5)  */
getCurrentSessionsURL='/dsurvey/client/phps/getSessList.php';


/* getInstrumentsURL: the URL that   will return a list of instruments. (todo=1)    */
getInstrumentsURL='/dsurvey/admins/phps/getInstList.php';


/* getInstrumentURL : the basic URL to use to request the contents of an instrument descriptor file (todo=2) .
   Note that a xml file name (of the instrument file) will be added at the end of this.
   Thus: for instrument anInst, url will be /dsurvey/client/phps/returnInstDesc.php?file=anInst.xml;
*/
getInstrumentURL='/dsurvey/admins/phps/returnInstDesc.php?file=';


/* getSessionExistsURL : the basic URL to use to request if a session file exists.  (todo=31)
   Note that a xml file name will be added at the end of this.
   then the requested URL will be: /dsurvey/client/phps/checkSessExists.php?name=mysession;
   The server should return a 0 if no such session file exists, a 1 if it does exist
*/
getSessionExistsURL='/dsurvey/admins/phps/checkSessExists.php?name=';

/*  postFileURL

      The basic url to use to "post" an XML file to the server to be saved as a session-descriptor file.
      Used with both postSessionFilesHeader and postFileHeader
      This is used as the URL in POST request, hence should NOT contain ?arguments.

   postSessionFilesHeader (todo=4): Used to instruct save session descriptor file, and to copy a list of
                           "instrument default" files to "session specific files".
                          These files will NOT be modified -- they will just be copied.
      The body of the POST will look like:
         postSessionFilesHeader&name=sessionName&instName=iName&file=filename&doScenarios=1&content=escaped_verbatim_xmlFile
      where
                postSessionFilesHeader= is the contents of the postSessionFilesHeader variable
                sessionName = the session name you enter
                iName = the instrument name
                doScenarios=1 : copy SC_*.XML files (from instrument to session directory)
                FileList =  a comma delimited list of filenames, that has been "escaped" (%2c used instead of comma)
                ovewrite=1 : optional -- force overwrite of session descriptor file
                escaped_verbatim_xmlFile = the contents of the session specific "instrument" xmlFile, 'escaped' for safe transmission
       Note that the instrument name is used to find the instrument's directory

  postInstrumentFileHeader (todo=76): used to instrument specific XML parameters  (that may have been modified).

     The body of the POST will look like:
         postInstrumentFileHeader&name=instrumentName&file=iFileName&content=escaped_verbatim_xmlFile
      where "postInstrumentFileHeader" is the contents of the postInstrumentFileHeader variable
                instrumentName = the instrument's name
                iFileName = the  xml file ( observation, general parameters, or other) file to create (or overwrite)
                escaped_verbatim_xmlFile = the contents of the xmlFile, 'escaped' for safe transmission


  postFileHeader (todo=7): used to session specific XML parameters  (that may have been modified).
                  These will overwrite session specific files of the same name

     The body of the POST will look like:
         postFileHeader&name=sessionName&file=iFileName&content=escaped_verbatim_xmlFile
      where "postFileHeader" is the contents of the postFileHeader variable
                sessionName = the session name
                iFileName = the  xml file ( observation, general parameters, or other) file to create (or overwrite)
                escaped_verbatim_xmlFile = the contents of the xmlFile, 'escaped' for safe transmission

 postClientFileBody (todo=124): used to "post" a client-accessible file (to PINFO/sessionname)
     The following will be added to the postClientFileBody
          &session=sessname&type=atype&contents=escapedXMLfile
     where atype is one of SESSION, ROUND, or OTHER


 uploadFileName and uploadFileValue: used to upload a file to browser
      This is used as input fields in an enctype of "multipart/form-data"


 echoFileName and Value: used to echo a file back to browser, with a content-disposition: attachment; filename=...
   This is used as the header of the body of  a post to the server.
   The following "input" element is added to the form used to force this post request
        name="echoFileName" value=echoFileValue
   Note that
         a name="filename" input element will also be added -- default filename to use to save to disk (see viewSubmittedAsXML for details)
         a name="contents" input element will also be added  -- unescaped contents of file to save (see viewSubmittedAsXML for details)
*/

postFileURL='/dsurvey/admins/phps/postFile.php';

// these are used with postFileURL
postSessionFilesHeader='todo=4';
postFileHeader='todo=7';
postInstrumentFileHeader='todo=76';
postClientFileBody='todo=124'

uploadFileName='todo';
uploadFileValue='77';

echoFileName='todo';
echoFileValue='500';


/* getSessionDataURL:   the basic URL to use to request the contents of one of a session's data file  (such as a general parameters file)
   a "name=sessionName&file=Params_FILE" are added (todo=6)  */
getSessionDataURL='/dsurvey/admins/phps/returnSessParams.php';

/* getInstrumentDataURL:   the basic URL to use to request the contents of one of an instrument's data file  (such as a general parameters file)
   a "name=instrumentName&file=Params_FILE" are added  (todo=61)*/
getInstrumentDataURL='/dsurvey/admins/phps/returnInstParams.php';


/* getSuspendedDescriptorURL : the basic URL to use to request the contents of a suspended session-dsecriptor file (an XML file).
   Note that the session name will be added at the end of this. (todo=33)
*/
getSuspendedDescriptorURL='/dsurvey/admins/phps/returnSuspendDesc.php?name=';


/* getSuspendedSessionsURL (todo=55): the URL that   will return a list of suspended sessions.    */
getSuspendedSessionsURL='/dsurvey/admins/phps/getSuspendSessList.php';



/* setServerVarURL (todo=121): the base URL used to create a "session specific" variable. This variable will
   be queried for by clients. Ideally, it should be retained in form easily for quick delivery
   (as a plain text string.
   The following will be added to the setServerVarURL :
       session=sessname&varname=aVarname&delim=adelim&value=Avalue
   where
        sessName: the survey session
        varname: variable to be saved (or space delimited list of variables)
        aValue : value of the variable  (or delim delimiged list of values)
        delim: a delimiter (used only if multiple varnames)
   The server should return an "ok" if the variable was properly saved.
   Otherwise, an error message that begins with a "-"
*/
setServerVarURL='/dsurvey/admins/phps/saveServerVar.php?';

/* getServerVarURL (todo=122): the base URL used to request a "session specific" variable.
  Note: admins\php\readServerVar.php and client\php\readServerVarC.php are slightly different (admin supports more
       options)

   The following will be added to the getServerVarURL :
       session=sessname&varname=aVarnames&delim=adelim&default=defValue
   where
        sessName: the survey session
        varname: variable to be retrieved. Or, a space delimited (escaped) list of variables.
                 If varname='*', return a delim delimited list of all the server variables defined for this session, using a
                        varname=value delim varname=value ...
                 syntax
       delim: optional. Only used if several variables. Adelim will be used by server to seperate values
       default: optional. If no varname exits, return defValue
  Optional: id and message variables
        ...&delim=adelim&id=participantId&message=escaped_message&time=aTime
   This participant specific (based on participantID) message will be saved, for use in status display.
    In addition, the current time  (highly recommended: use getTime()) will be stored.
*/
getServerVarURL='/dsurvey/admins/phps/readServerVar.php?';


/* setServerStatusVarURL (todo=131): the base URL used to create a "session specific" status variable.
  This variable will be queried for by clients, such as when a participant is joining
  Ideally, it should be retained in form easily for quick delivery  (as a plain text string)
   The following will be added to the setServerVarURL :
       session=sessname&varname=aVarname&value=Avalue
   where
        sessName: the survey session
        varname: variable to be saved
        aValue :  value of the variable
   The server should return an "ok" if the variable was properly saved.
   Otherwise, an error message that begins with a "-"
   Note: this is a somewhat simpler version of setServerVarUrl
*/
setServerStatusVarURL='/dsurvey/admins/phps/saveServerStatusVar.php?';

/* getServerStatusVarURL (todo=132): the base URL used to request a "session specific" status variable.
  Note: the client and admin side version of this are essentially identical.
   The following will be added to the getServerStatusVarURL :
       session=sessname&varname=aVarnames&default=defValue
   where
        sessName: the survey session
        varname: variable to be retrieved.
        default: optional. If no such varname, return defValue

*/
getServerStatusVarURL='/dsurvey/admins/phps/readServerStatusVar.php?';


/* getUserStatusURL (todo=322): get a string containing the status of the current participants.
    id, atime, message=amessage
 each on a seperate line
 session=sessionName will be appended
*/
getUserStatusURL='/dsurvey/admins/phps/readUserStatus.php?';


/*  getUserListURL (todo=202): the base url to request a list of users (in an xml file )
  The following will be added to getUserListURL
        session=sessName

 The returned file syntax should be something like  (the session and created nodes are purely descriptive, 1 <user>
 note for every participant, name nickname and contact are always subnodes.)

 <?xml version="1.0" encoding="UTF-8" ?>
 <users>
    <session value="sessname" />
    <created>date and time </created>
     <user id="53301924269913"><name>A2</name><contact></contact><nickname></nickname><refid></refid></user>
     <user id="3871111421218145"><name>A3</name><contact></contact><nickname></nickname><refid></refid></user>
     <user id="7424969263627784"><name>A4</name><contact></contact><nickname></nickname><refid></refid></user>
 </users>
Note. Actual stuff in the <user>... is supplied by clients when they join session. For example:
   name: 1-word name, provided when a user joins
   contact: contact info, provided when a user joins. This is optional-- if not provided, a '' is used
   nickname: a nickname, provided when a user joins. This is optional-- if not provided, a '' is used
*/
getUserListURL='/dsurvey/admins/phps/getuserList.php?';



/* getSubmittedDataURL (todo=403): return an XML file containing all submitted data.
   session=sessName will be appended to the end of this
*/
getSubmittedDataURL='/dsurvey/admins/phps/getSubmitted.php?';

/* DEPRECATED: updateSubmittedDataURL: tell server to append "current round" submitted data to "all round" submitted data, and to clear
  "current round" submitted
 session=sessName will be appended to the end of this
 */
//updateSubmittedDataURL='/dsurvey/dsurvey?todo=4031&';


//============== not done yet


/*  svyPost3URL :
      The basic url (points to a .php file) to use to "post" submitted data, as an XML data row, to the server
      This is used with svyPostDataHeader --
           svyPost3URL is the request line (the .php file), svyPost3Header is the start of the body of the post
*/
svyPost3URL='/dsurvey/admins/phps/saveAnyData.php' ;

/*  svyPost3Header :
      The header to use in the body of a a "post" of general, users, or  results data
      The following is appended:
                session=sessname&round=roundNum&round=around&type=atype&contents=EscapedXMLDataRows
      or, if atype=CUSTOM
                session=sessname&round=roundNum&round=around&type=atype&cname=filename&contents=EscapedXMLDataRows

 */
svyPost3Header='todo=431&' ;


/* getSavedDataURL (todo=461):
  Note: client-side version of this only gets  SIMPLEHISTORY
        retrieve a quasi-xml file containing saved data.
        The following is appended:
                sesion=sessname&type=atype
        where atype must be GENERAL, USERS, or RESULTS , HISTORY , or SIMPLEHISTORY, or CUSTOM
*/

getSaveDataURL='/dsurvey/admins/phps/getSavedAnyData.php?' ;


/* getSubmitMessages: return a crlf delimited string containing the list of submit-messages
   session=sessName will be appended to the end of this
*/
getSubmittedMessagesURL='/dsurvey/dsurvey?todo=405&';

/* killSessionURL: delete session specific files and directories.
        session=sessName&step=n&fake=k
    will be added,
        step=n  : with n=1,2,3, or 4 (descriptor, parameter and submitted data files, temporary data files, client-accessible files)
        fake=k:  k=1 means "don't actually delete, just report what would be deleted. k=0 means "do it!"
*/
killSessionURL='/dsurvey/dsurvey?todo=600&';


/* suspendSessionURL: suspend a session
   session=sessName will be added
*/

suspendSessionURL='/dsurvey/dsurvey?todo=601&';

/* unSuspendSessionURL: unsuspend a session
   session=sessName will be added
*/
unSuspendSessionURL='/dsurvey/dsurvey?todo=602&';


/* saveSelectionFile: save the dsurvey.htm file -- list of sessions to chose from
  add contents=escaped_file
*/
saveSelectionFile='todo=802&';




/* postNoteHeader:
   The header to use to post a text note to this sessions notes file
   The following is appended:
                session=sessname&
   Note: postFileURL is used with this
*/
postNoteHeader="todo=711" ;


/* getScenarioList
   Request a list of scenario files
   The following is appended:
                session=sessname&
    or
                instrument=instname
*/
getScenarioListURL='/dsurvey/dsurvey?todo=901&';


/* getScenarioListsList
   Request a list of scenarioList files
   The following is appended:
                session=sessname&
    or
                instrument=instname
*/
getScenarioListsListURL='/dsurvey/dsurvey?todo=9011&';






/* postParticipantFile: post a quasi-XML file containing list of participants
   The following "input" element is added to the form used to force this post request
        session=sessName&contents=escaped_xml_file
   Note: in the post request, uses postFileUrl
*/
postParticipantFile="todo=213&";


/* backupSessionURL: the base url to backup a sessions data files.
        a) session descriptor file
        a) submitted data
        b) list of participants
        c) history of submissions
        d) all session specific xml files (including reference data, user and general parameters, and control panel)
   &session=sessName is added to the end
*/
backupSessionURL='/dsurvey/dsurvey?todo=421';


/* getSubmitMessages: return a crlf delimited string containing the list of submit-messages
   session=sessName will be appended to the end of this
*/
getSubmittedMessagesURL='/dsurvey/admins/phps/readUserStatus.php?';


/* ====== headers to static files ==== */

/* homePageURL : header to the "home page" for a instrument/session
    All occurences of !INST! will be replaced by the instrument name
*/
homePageURL='/dsurvey/instruments/!INST!/!INST!.html';

/* instrumentBaseURL: the base url for this instruments directory
    All occurences of !INST! will be replaced by the instrument name.
*/
instrumentBaseURL='/dsurvey/instruments/!INST!/' ;

/* specFileRL : header to the "specification file" for a instrument/session
    All occurences of !INST! will be replaced by the instrument name.
    Relative urls will be append to the instrumentBaseURL
*/
specFileURL='specs/spec.xml';



/*
    ------- MYSQL databases created for each session --- 

basic: Basic session info
   instrument, filelist, creation

servervars: Store varname as a serverVar:   (varname is key)
   varname, varvalue, modified

statusVars: Store varname as a statusVar  (varname is key)
   varname,varvalue, modified

clientstatus: Store client status (such as last requested variable)    (clientid is key)
   clientid , servertime, clienttime, state, message, varname, varvalue

submitted:   Store data "submitted" by clients (clientid, round, ct are keys)
   clientid, round, ct  , servertime,clienttime, notfinal ct, entry, comment
   
submitStatus: Store client submission status (time/comment of last submission (sStatus is key)
   sstatus,clienttime
  
simpleHistory:  store simple history information uploaded by clients (arow is key, auto incremented)
     arow, content, comment
     
clientIds: information about a client (clientid is key)
  clientid, clientName, refId, serverTime, content

assignCID: assigning unique client IDs  (used if server-side id assignation is enabled) (clientid is auto-incremented key)
   clientid, clientName, servertime

generalData: store general data (round is key) -- one entry per round
  round int(4) not null ,
     PRIMARY KEY (round)  ,
  servertime int,
  entry text

usersData: store users  data (round is key) -- one entry, with records for many clients, per round
  round int(4) not null ,
     PRIMARY KEY (round)  ,
  servertime int,
  entry text

resultsData: store results data (round is key) -- one entry, with records for many clients, per round
  round int(4) not null ,
     PRIMARY KEY (round)  ,
  servertime int,
  entry text

historyData: store history data (round is key) -- one entry, with records for many clients, per round
  round int(4) not null ,
     PRIMARY KEY (round)  ,
  servertime int,
  entry text

customData: store custom data (possibly several kinds) (name and round is key) -- one entry, with records for many clients, per round
  round int(4) not null ,
  aname varchar(60) not null,
     PRIMARY KEY (aname,round)  ,
  servertime int,
  entry text


//    generalData, resultsData, usersData, historyData



*/
