IEnumerator lmsSetContentComplete( string contentID, int enrollment_id, LMSSimpleCallback callback ) { //string bodyString = "{\"action\":\"Curriculum_CompleteContent\",\"params\":{\"content_id\":\"" + contentID + "\"," + "\"enrollment_id\":" + enrollment_id + "},\"authKey\":" + pingAuthKey + "}"; // make JSON JSONObject j = new JSONObject(JSONObject.Type.OBJECT); //number j.AddField("action", "Curriculum_CompleteContent"); // make param area JSONObject arr = new JSONObject(JSONObject.Type.ARRAY); j.AddField("params", arr); // add params arr.AddField ("content_id",contentID); arr.AddField ("enrollment_id", enrollment_id ); // add authkey string keyNoQuotes = pingAuthKey.Replace ("\"",""); j.AddField ("authKey",keyNoQuotes); // get bodystring string bodyString = j.print(); LMSDebug ("lmsSetContentComplete(" + contentID + "," + enrollment_id + ") : bodystring=" + bodyString); // Create a download object string url = "http://" + URL + "statefull/post"; WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString),pingHeaders); yield return download; LMSDebug ("lmsSetContentComplete(" + pingAuthKey + ") text=<" + download.text + "> error=<" + download.error + ">"); string DBResult; string DBErrorString; if (download.error != null) { // save the error DBResult = ""; DBErrorString = download.error; if ( callback != null ) callback(false,contentID,"",download); } else { // decode JSONObject decoder = new JSONObject(download.text); if ( CheckReturn(decoder) == true ) { var N = JSONNode.Parse(download.text); string result = N["params"]["mark_start_flag"].ToString(); string msg = "lmsSetContentComplete() : mark_start_flag=" + result; LMSDebug (msg); DBResult = "ok"; if ( callback != null ) callback(true,contentID,msg,download); } else { if ( callback != null ) callback(false,contentID,download.text,download); } } }
// // LMS Launch Content // args: contentID, List<LMSCourseInfo>, callback // NOTE: sets last contentID complete // // public void LMSLaunchContent( string contentID, List<LMSCourseInfo> list, LMSSimpleCallback callback=null ) { if ( LMSIsValidLogin() == false ) { string error = "LMSLaunchContent(" + contentID + ") authkey not set or not valid!"; UnityEngine.Debug.LogError(error); if ( callback != null ) callback(false,contentID,error,null); } else { if ( list != null ) { #if SET_LAUNCH_ON_ALL_RECORDS foreach( LMSCourseInfo item in list ) { LMSLaunchContent(contentID,item.EnrollmentID,callback); } #else if ( list.Count > 0 ) LMSLaunchContent(contentID,list[list.Count-1].EnrollmentID,callback); #endif } } }
public void LMSSetContentComplete( string contentID, int enrollment_id, LMSSimpleCallback callback=null ) { if ( LMSIsValidLogin() == false ) { string error = "LMSSetContentComplete(" + contentID + ") authkey not set or not valid!"; UnityEngine.Debug.LogError(error); if ( callback != null ) callback(false,contentID,error,null); } else StartCoroutine(lmsSetContentComplete(contentID,enrollment_id,callback)); }
public void LMSSetContentComplete( string contentID, List<LMSCourseInfo> list, LMSSimpleCallback callback=null ) { if ( LMSIsValidLogin() == false ) { string error = "LMSGetCoursesUsingContent(" + contentID + ") authkey not set or not valid!"; UnityEngine.Debug.LogError(error); if ( callback != null ) callback(false,contentID,error,null); } else { #if SET_COMPLETE_ON_ALL_RECORDS // this sends a content complete to all content registered foreach( LMSCourseInfo item in list ) { LMSSetContentComplete(contentID,item.EnrollmentID,callback); } #else // this only sends content complete to last record, because // that is the most up to date record if ( list != null && list.Count > 0 ) LMSSetContentComplete(contentID,list[list.Count-1].EnrollmentID,callback); #endif } }
// // LMSSetComplete(contentID) // // this method first needs to make sure course list is valid and then call LMSSetContentComplete() // public void LMSSetComplete( string contentID, LMSSimpleCallback callback=null ) { // set callback contentCompleteCallback = callback; // auto enroll this user LMSDebug ("LMSIntegration.LMSStartContent() : first see if user is enrolled, calling LMSGetCoursesUsingContent()"); LMSIntegration.GetInstance().LMSGetUserEnrollment(contentID,SetCompleteCallback); }
IEnumerator lmsSaveData( string path, string data, LMSSimpleCallback callback ) { // make JSON JSONObject j = new JSONObject(JSONObject.Type.OBJECT); //number j.AddField("action", "AppData_SaveDump"); // make param area JSONObject arr = new JSONObject(JSONObject.Type.ARRAY); j.AddField("params", arr); // add params arr.AddField ("key",path); arr.AddField ("data",data); // add authkey string keyNoQuotes = pingAuthKey.Replace ("\"",""); j.AddField ("authKey",keyNoQuotes); // get the string string bodyString = j.print(); LMSDebug ("LMSIntegration.lmsSaveData(" + path + "," + data + ") : bodystring=<" + bodyString + ">"); // Create a download object string url = "http://" + URL + "statefull/post"; WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString),pingHeaders); yield return download; string DBResult; string DBErrorString; if (download.error != null) { // save the error DBResult = ""; DBErrorString = download.error; // decode return JSONObject decoder = new JSONObject(download.text); JSONObject msg = decoder.GetField ("msg"); UnityEngine.Debug.LogError("LMSIntegration.lmsSaveData() : error, msg=" + msg.print()); // bad return if ( callback != null ) callback(false,path,"",download); } else { // decode JSONObject decoder = new JSONObject(download.text); if ( CheckReturn(decoder) == true ) { // ok return if ( callback != null ) callback(true,path,"transfer ok",download); } else { // probably an error, show it JSONObject p = decoder.GetField ("params"); JSONObject msg = p.GetField("msg"); if ( msg != null ) { UnityEngine.Debug.LogError("LMSIntegration.lmsSaveData() : msg=" + msg.print ()); // bad return if ( callback != null ) callback(false,path,msg.print(),download); } } DBResult = "ok"; } }
// // LMS Save Data // args: path, callback // NOTE: saves the data stored in the path defined as a normal path </path/filename> // public void LMSSaveData( string path, string data, LMSSimpleCallback callback ) { StartCoroutine(lmsSaveData(path,data,callback)); }