Example #1
0
        /// <summary>
        /// Creates a new instance of a Statement.
        /// </summary>
        /// <param name="id">Unique identifier for the statement.</param>
        /// <param name="actor">Whom the Statement is about, as an Agent or Group Object.</param>
        /// <param name="verb">Action taken by the Actor.</param>
        /// <param name="statementObject">Activity, Agent, or another Statement that is the Object of the Statement.</param>
        /// <param name="result">Result Object, further details representing a measured outcome.</param>
        /// <param name="context">Context that gives the Statement more meaning. Examples: a team the Actor is working with, altitude at which a scenario was attempted in a flight simulator.</param>
        /// <param name="timestamp">Timestamp of when the events described within this Statement occurred. Set by the LRS if not provided.</param>
        /// <param name="attachments">Headers for Attachments to the Statement</param>
        /// <param name="authority">Agent or Group who is asserting this Statement is true. Verified by the LRS based on authentication. Set by LRS if not provided or if a strong trust relationship between the Learning Record Provider and LRS has not been established.</param>
        public Statement(
            Guid id,
            Actor actor,
            Verb verb,
            StatementObject statementObject,
            Result result      = null,
            Context context    = null,
            DateTime?timestamp = null,
            IEnumerable <Attachment> attachments = null,
            Actor authority = null)
        {
            Actor           = actor ?? throw new ArgumentNullException(nameof(actor));
            Verb            = verb ?? throw new ArgumentNullException(nameof(verb));
            StatementObject = statementObject ?? throw new ArgumentNullException(nameof(statementObject));

            Id      = id;
            Context = context;
            Result  = result;

            Timestamp = timestamp;
            Authority = authority;

            if (attachments != null && attachments.Any())
            {
                Attachments = attachments;
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of a StatementBuilder class.
        /// </summary>
        /// <param name="actor">Whom the Statement is about, as an Agent or Group Object.</param>
        /// <param name="verb">Action taken by the Actor.</param>
        /// <param name="statementObject">Activity, Agent, or another Statement that is the Object of the Statement.</param>
        public StatementBuilder(Actor actor, Verb verb, StatementObject statementObject)
        {
            _actor           = actor;
            _verb            = verb;
            _statementObject = statementObject;

            _attachments = new List <Attachment>();
        }
Example #3
0
        /// <summary>
        /// Voids a statement by sending a statement containing the void verb.
        /// </summary>
        /// <param name="statementId">The id of the statement to void</param>
        /// <param name="agent">The agent that voids the statement</param>
        public async Task VoidStatementAsync(Guid statementId, Agent agent)
        {
            var voidingStatement =
                Statement.Create(
                    agent,
                    Verb.Create("http://adlnet.gov/expapi/verbs/voided")
                    .AddDisplay("en-US", "voided"),
                    StatementObject.CreateStatementReference(statementId)).Build();

            await SendStatementAsync(voidingStatement);
        }
Example #4
0
 /// <summary>
 /// Creates a new instance of a Statement. The statement's ID is automatically
 /// generated using a GUID.
 /// </summary>
 /// <param name="actor">Whom the Statement is about, as an Agent or Group Object.</param>
 /// <param name="verb">Action taken by the Actor.</param>
 /// <param name="statementObject">Activity, Agent, or another Statement that is the Object of the Statement.</param>
 /// <param name="result">Result Object, further details representing a measured outcome.</param>
 /// <param name="context">Context that gives the Statement more meaning. Examples: a team the Actor is working with, altitude at which a scenario was attempted in a flight simulator.</param>
 /// <param name="timestamp">Timestamp of when the events described within this Statement occurred. Set by the LRS if not provided.</param>
 /// <param name="attachments">Headers for Attachments to the Statement</param>
 /// <param name="authority">Agent or Group who is asserting this Statement is true. Verified by the LRS based on authentication. Set by LRS if not provided or if a strong trust relationship between the Learning Record Provider and LRS has not been established.</param>
 public Statement(
     Actor actor,
     Verb verb,
     StatementObject statementObject,
     Result result      = null,
     Context context    = null,
     DateTime?timestamp = null,
     IEnumerable <Attachment> attachments = null,
     Actor authority = null) : this(Guid.NewGuid(), actor, verb, statementObject, result, context, timestamp, attachments, authority)
 {
 }
Example #5
0
 public void ParseStatements()
 {
     for (int i = 0; i < statementJSON.Count; i++)
     {
         string t = statementJSON [i] ["QText"].Value;
         bool b = statementJSON [i] ["IsTrue"].AsBool;
         int c = statementJSON [i] ["Paragraph_ID"].AsInt;
         int p = statementJSON [i] ["Position"].AsInt;
         StatementObject s = new StatementObject (t, b, c, p);
         TextPool.instance.StatementObjList.AddStatement (s);
     }
 }
Example #6
0
        private static Statement SimpleStatement()
        {
            var statement =
                Statement.Create(
                    Actor.CreateAgent("Project Tin Can API").WithMailBox("*****@*****.**"),
                    Verb.Create("http://example.com/xapi/verbs#sent-a-statement")
                    .AddDisplay("en-US", "sent"),
                    StatementObject.CreateActivity("http://example.com/xapi/activity/simplestatement")
                    .AddName("en-US", "simple statement")
                    .AddDescription("en-US", "A simple Experience API statement. Note that the LRS does not need to have any prior information about the Actor(learner), the verb, or the Activity / object.")).Build();

            return(statement);
        }
Example #7
0
        private static void SubStatement()
        {
            var statement =
                Statement.Create(
                    Actor.CreateAgent().WithMailBox("*****@*****.**"),
                    Verb.Create("http://example.com/planned").AddDisplay("en-US", "planned"),
                    StatementObject.CreateSubStatement(
                        Actor.CreateAgent().WithMailBox("*****@*****.**"),
                        Verb.Create("http://example.com/visited").AddDisplay("en-US", "will visit"),
                        StatementObject.CreateActivity("http://example.com/website").AddName("en-US", "Some Awesome Website"))).Build();
            var json = statement.ToJson(true);

            Console.WriteLine(json);
        }
Example #8
0
        private static Statement CompleteStatement()
        {
            var statement =
                Statement.Create(
                    Actor.CreateGroup("Team PB")
                    .Add(Actor.CreateAgent("Andrew Downes").WithAccount("13936749", "http://www.example.com"))
                    .Add(Actor.CreateAgent("Toby Nichols").WithOpenId("http://toby.openid.example.org/"))
                    .Add(Actor.CreateAgent("Ena Hills").WithHashedMailBox("ebd31e95054c018b10727ccffd2ef2ec3a016ee9"))
                    .WithMailBox("*****@*****.**"),
                    Verb.Create("http://adlnet.gov/expapi/verbs/attended")
                    .AddDisplay("en-GB", "attended")
                    .AddDisplay("en-US", "attended"),
                    StatementObject
                    .CreateActivity("http://www.example.com/meetings/occurances/34534")
                    .WithActivityType("http://adlnet.gov/expapi/activities/meeting")
                    .AddName("en-GB", "example meeting")
                    .AddName("en-US", "example meeting")
                    .AddDescription("en-GB", "An example meeting that happened on a specific occasion with certain people present.")
                    .AddDescription("en-US", "An example meeting that happened on a specific occasion with certain people present.")
                    .AddExtension("http://example.com/profiles/meetings/activitydefinitionextensions/room", @"{""name"": ""Kilby"", ""id"" : ""http://example.com/rooms/342""}")
                    .WithMoreInfo("http://virtualmeeting.example.com/345256"))
                .WithResult(Result.Create()
                            .WithSuccess(true)
                            .WithCompletion(true)
                            .WithResponse("We agreed on some example actions.")
                            .WithDuration(TimeSpan.FromHours(1))
                            .AddExtension("http://example.com/profiles/meetings/resultextensions/minuteslocation", @"X:\meetings\minutes\examplemeeting.one"))
                .WithTimeStamp(new DateTime(2015, 12, 18, 12, 17, 00))
                .WithContext(Context.Create()
                             .WithRegistration(new Guid("ec531277-b57b-4c15-8d91-d292c5b2b8f7"))
                             .AddParent(StatementObject.CreateActivity("http://www.example.com/meetings/series/267").Build())
                             .AddCategory(StatementObject.CreateActivity("http://www.example.com/meetings/categories/teammeeting")
                                          .AddName("en", "team meeting")
                                          .AddDescription("en", "A category of meeting used for regular team meetings.")
                                          .WithActivityType("http://example.com/expapi/activities/meetingcategory"))
                             .AddOther(StatementObject.CreateActivity("http://www.example.com/meetings/occurances/34257"))
                             .AddOther(StatementObject.CreateActivity("http://www.example.com/meetings/occurances/3425567"))
                             .WithInstructor(Actor.CreateAgent("Andrew Downes").WithAccount("13936749", "http://www.example.com"))
                             .WithTeam(Actor.CreateGroup("Team PB").WithMailBox("*****@*****.**"))
                             .WithPlatform("Example virtual meeting software")
                             .WithLanguage("tlh")
                             .WithStatementReference(new Guid("6690e6c9-3ef0-4ed3-8b37-7f3964730bee")))
                .WithAuthority(Actor.CreateAgent().WithAccount("anonymous", "http://cloud.scorm.com"))
                .Build();

            return(statement);
        }
Example #9
0
        private static void CompletionStatement()
        {
            var statement =
                Statement.Create(
                    Actor.CreateAgent("Example Learner").WithMailBox("*****@*****.**"),
                    Verb.Create("http://adlnet.gov/expapi/verbs/attempted").AddDisplay("en-US", "attempted"),
                    StatementObject.CreateActivity("http://example.adlnet.gov/xapi/example/simpleCBT")
                    .AddName("en-US", "simple CBT course")
                    .AddDescription("en-US", "A fictious example CBT course"))
                .WithResult(Result.Create()
                            .WithScore(new Score(0.95))
                            .WithSuccess(true)
                            .WithCompletion(true)
                            .WithDuration(TimeSpan.FromSeconds(1234)))
                .Build();
            var json = statement.ToJson(true);

            Console.WriteLine(json);
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of a StatementBuilder class.
 /// </summary>
 /// <param name="id">The Statement unique identifier.</param>
 /// <param name="actor">Whom the Statement is about, as an Agent or Group Object.</param>
 /// <param name="verb">Action taken by the Actor.</param>
 /// <param name="statementObject">Activity, Agent, or another Statement that is the Object of the Statement.</param>
 public StatementBuilder(Guid id, Actor actor, Verb verb, StatementObject statementObject) :
     this(actor, verb, statementObject)
 {
     _id = id;
 }
Example #11
0
 public void AddStatement(StatementObject sIndex)
 {
     sIndex.CorrespondingParagraph -= 1;
     List<StatementObject> s = sList [sIndex.CorrespondingParagraph];
     s.Add(sIndex);
 }
Example #12
0
 /// <summary>
 /// Starts the creation of a Statement object with the mandatory objects passed. The Statement ID is defined
 /// as a parameter passed to the method.
 /// <para>Actor, Verb and StatementObject are mandatory, the other optional properties are
 /// passed through the returned Statement builder.</para>
 /// </summary>
 /// <param name="id"></param>
 /// <param name="actor">Whom the Statement is about, as an Agent or Group Object.</param>
 /// <param name="verbBuilder">An instance of a verb builder class.</param>
 /// <param name="statementObject">Activity, Agent, or another Statement that is the Object of the Statement.</param>
 /// <returns>A builder class that allows to continue to set optional properties to the Statement.</returns>
 public static IStatementBuilder Create(Guid id, Actor actor, IVerbBuilder verbBuilder, StatementObject statementObject)
 {
     return(Create(id, actor, verbBuilder.Build(), statementObject));
 }
Example #13
0
 /// <summary>
 /// Starts the creation of a Statement object with the mandatory objects passed as well as a specific Guid
 /// for the statement.
 /// <para>Actor, Verb and StatementObject are mandatory, the other optional properties are
 /// passed through the returned Statement builder.</para>
 /// </summary>
 /// <param name="id">The unique identifier for the Statement.</param>
 /// <param name="actor">Whom the Statement is about, as an Agent or Group Object.</param>
 /// <param name="verb">Action taken by the Actor.</param>
 /// <param name="statementObject">Activity, Agent, or another Statement that is the Object of the Statement.</param>
 /// <returns>A builder class that allows to continue to set optional properties to the Statement.</returns>
 public static IStatementBuilder Create(Guid id, Actor actor, Verb verb, StatementObject statementObject)
 {
     return(new StatementBuilder(id, actor, verb, statementObject));
 }