public static void SendStatement(string activity) { string email = "mailto:"; email += username; Statement[] statements = new Statement[1]; Activity newAct = new Activity("http://35.9.22.105/xapi"); LanguageMap inter = new LanguageMap(); inter.Add("en-US", "Interacted"); System.Uri verbURI = new System.Uri("http://verbs/interaction/"); StatementVerb interact = new StatementVerb(verbURI, inter); newAct.Definition = new ActivityDefinition(); newAct.Definition.Name = new LanguageMap(); newAct.Definition.Description = new LanguageMap(); newAct.Definition.Description.Add("type", "Desktop Application Learning Activity"); newAct.Definition.Name.Add("en-US", activity); Random rand = new Random(); int random = rand.Next(); newAct.Id = "http://" + random.ToString() + "/desktopapp/" + activity; statements[0] = new Statement(new Actor(username, email), interact, newAct); try { tincan.StoreStatements(statements); } catch (Exception e) { _offlineQueuedStatements.Enqueue(statements[0]); } }
public static void JSObject() { Console.WriteLine("Start\n\n"); //TCAPI tincan = new TCAPI(new Uri("http://35.9.22.105:8000/xapi"), new BasicHTTPAuth("Dave", "12345")); Statement[] statements = new Statement[1]; Activity newAct = new Activity("http://www.google.com"); newAct.Definition = new ActivityDefinition(); newAct.Definition.Name = new LanguageMap(); newAct.Definition.Name.Add("en-US", "Testing"); statements[0] = new Statement(new Actor("Guess Who", "mailto:guesswho"), new StatementVerb(PredefinedVerbs.Created), newAct); TCAPI tincan = new TCAPI(new Uri("http://35.9.22.105:8000/xapi"), new BasicHTTPAuth("Joe", "123"), RusticiSoftware.TinCanAPILibrary.Helper.TCAPIVersion.TinCan1p0p0); tincan.StoreStatements(statements); Console.WriteLine("End\n"); }
/// <summary> /// Gets an Activity /// </summary> /// <param name="activityId">The activity ID</param> /// <returns></returns> public Activity GetActivity(string activityId) { Activity result = new Activity(); string getResult; TinCanJsonConverter converter = new TinCanJsonConverter(); NameValueCollection nvc = new NameValueCollection(); nvc["activityId"] = activityId; getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY, authentification, versionString); result = (Activity)converter.DeserializeJSON(getResult, typeof(Activity)); return result; }
public void StoreStatementTest() { TCAPI target = new TCAPI(new Uri("http://cloud.scorm.com/tc/public"), new BasicHTTPAuth("test", "password")); target.MaxBatchSize = 1; Statement[] statements = new Statement[1]; Activity activity = new Activity("http://www.example.com"); activity.Definition = new ActivityDefinition(); activity.Definition.Name = new LanguageMap(); activity.Definition.Name.Add("en-US", "TCAPI C# 0.95 Library."); statements[0] = new Statement(new Actor("Example", "mailto:[email protected]"), new StatementVerb(PredefinedVerbs.Experienced), activity); target.StoreStatements(statements); Assert.Inconclusive(INCONCLUSIVE); }