Beispiel #1
0
        private Context BuildTextContext()
        {
            Guid registration = new Guid("42c0855b-8f64-47f3-b0e2-3f337930045a");
            ContextActivities contextActivities = new ContextActivities();
            string            revision          = "";
            string            platform          = "";
            string            language          = "";
            StatementRef      statement         = new StatementRef();

            TinCan.Extensions extensions = new TinCan.Extensions();

            Context context = new Context();

            context.registration      = registration;
            context.contextActivities = contextActivities;
            context.revision          = revision;
            context.platform          = platform;
            context.language          = language;
            context.statement         = statement;
            context.extensions        = extensions;

            return(context);
        }
Beispiel #2
0
        // ------------------------------------------------------------------------
        //	"object": {
        //		"objectType": "Activity",
        //		"id": "https://dig-itgames.com/apps/exotrex2/minigame/titan/branchingquiz/4",
        //		"definition": {
        //			"type": "https://gblxapi.org/object/minigame",
        //			"name": {
        //				"en-US": "MiniGame Titan BranchingQuiz 4"
        //			},
        //			"description": {
        //				"en-US": "I'm very interested in your take of Titan's volcanoes. How do they compare to the ones we have on Earth?"
        //			},
        //			"interactionType": "choice",
        //			"correctResponsesPattern": [
        //				"0"
        //			],
        //			"choices": [
        //				{
        //					"id": "0",
        //					"description": {
        //						"en-US": "Titan's volcanoes are called cryovolcanoes because they ooze frozen or slushy mixtures of water and methane from under the moon's crust."
        //					}
        //				},
        //				{
        //					"id": "1",
        //					"description": {
        //						"en-US": "Titan's volcanoes are just like Earth's and the hot lava helps warm the surface."
        //					}
        //				},
        //				{
        //					"id": "2",
        //					"description": {
        //						"en-US": "Titan's volcanoes are called cryovolcanoes because they only emit steam and sparks of light from deep inside of Titan."
        //					}
        //				}
        //			]
        //		}
        //	},
        // REF: https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#Appendix2C
        // ------------------------------------------------------------------------
        public Activity CreateObjectStatement(string objectId, string activityName, string objectName, string objectDescription, string interactionType, List <String> objectResponses = null, List <InteractionComponent> objectResponseOptions = null, List <InteractionComponent> objectResponseTargets = null, TinCan.Extensions extensions = null)
        {
            // create definition and add to activity.
            ActivityDefinition definition = new ActivityDefinition();

            try { definition.type = (Uri)this.standardsJson["activity"][activityName.ToLower()]["id"]; }
            catch (NullReferenceException) { this.ThrowVocabError("Activity", activityName); }
            definition.name = new LanguageMap();
            definition.name.Add("en-US", objectName);
            definition.description = new LanguageMap();
            definition.description.Add("en-US", objectDescription);
            definition.interactionType = interactionType;

            if (objectResponses != null)
            {
                definition.correctResponsesPattern = objectResponses;
            }

            if (extensions != null)
            {
                definition.extensions = extensions;
            }

            // definition field type is based on interactionType
            if (objectResponseOptions != null && objectResponseOptions.Count > 0)
            {
                switch (interactionType)
                {
                case "choice":
                    definition.choices = objectResponseOptions;
                    break;

                case "likert":
                    definition.scale = objectResponseOptions;
                    break;

                case "matching":
                    definition.source = objectResponseOptions;
                    definition.target = objectResponseTargets;
                    break;

                case "performance":
                    definition.steps = objectResponseOptions;
                    break;

                case "sequencing":
                    definition.choices = objectResponseOptions;
                    break;

                default:
                    Debug.LogWarning("CreateObjectStatement(): Interaction Type:" + interactionType + " does not use response options (discarded)");
                    break;
                }
            }

            // create the activity
            Activity activity = new Activity();

            activity.id         = new Uri(objectId);
            activity.definition = definition;

            return(activity);
        }
Beispiel #3
0
        // ------------------------------------------------------------------------
        //	"result": {
        //		"success": true,
        //		"duration": "PT1.46S",
        //		"response": "0",
        //		"completion": true
        //	},
        // ------------------------------------------------------------------------
        public Result CreateResultStatement(bool completed, bool success, float duration, string response = null, Nullable <int> score = null, TinCan.Extensions extensions = null)
        {
            Result resultStatement = new Result();

            resultStatement.completion = completed;
            resultStatement.success    = success;
            resultStatement.duration   = TimeSpan.FromSeconds(duration);

            if (extensions != null)
            {
                resultStatement.extensions = extensions;
            }

            if (response != null)
            {
                resultStatement.response = response;
            }

            if (score != null)
            {
                Score statementScore = new Score();
                statementScore.raw = score;                 // scaled, raw, min, max

                resultStatement.score = statementScore;
            }

            return(resultStatement);
        }
Beispiel #4
0
        // ------------------------------------------------------------------------
        // This function places a list of context extensions into a Tincan.Extensions object under the correct key.
        //
        // "https://w3id.org/xapi/gblxapi/extensions/focus": [
        //   {
        //     "name": {
        //       "en-US": "Addition/Subtraction"
        //     },
        //     "id": "https://gblxapi.org/focus/addition-subtraction",
        //     "description": {
        //       "en-US": "Actor has been presented or interacted in math experiences involving the focus area of: Addition/Subtraction"
        //     }
        //   }
        // ],
        //
        // extensionType: focus
        // trackedStandards: previously created list of focus extensions
        // target: previously created TinCan.Extensions object
        // ------------------------------------------------------------------------
        public void PackExtension(string extensionType, List <JToken> trackedStandards, TinCan.Extensions target)
        {
            extensionType = extensionType.ToLower();

            try {
                Uri extURI = new Uri((string)this.standardsJson["extension"][extensionType]["id"]);
                target.Add(extURI, JToken.FromObject(trackedStandards));
            }
            catch (NullReferenceException) { this.ThrowVocabError("extension type", extensionType); }
        }
Beispiel #5
0
        // ------------------------------------------------------------------------
        // "context": {
        //      "extensions": {
        //          "https://gblxapi.org/c3": [
        //          {
        //              "description": {
        //              "en-US": "Social Studies C3 Standard d2.his.13.6-8"
        //              },
        //              "name": {
        //              "en-US": "d2.his.13.6-8"
        //              },
        //              "id": "https://gblxapi.org/c3/d2-his-13-6-8"
        //          }],
        //          "https://w3id.org/xapi/gblxapi/extensions/domain": [
        //          {
        //              "name": {
        //              "en-US": "History"
        //              },
        //              "id": "https://gblxapi.org/domain/history",
        //              "description": {
        //              "en-US": "Actor has been presented or interacted in Social Studies domain experiences in: History"
        //              }
        //          }]
        //      },
        //      "contextActivities": {
        //          "category": [
        //          {
        //              "id": "https://gblxapi.org/socialstudies",
        //              "objectType": "Activity"
        //          }]
        //          "grouping": [
        //          {
        //              "id": "https://dig-itgames.com/",
        //              "objectType": "Activity"
        //          },
        //          {
        //              "definition": {
        //              "name": {
        //                  "en-US": "Three Digits - Easy"
        //              },
        //              "type": "https://w3id.org/xapi/gblxapi/activities/difficulty"
        //              },
        //              "id": "https://dig-itgames.com/three-digits/easy",
        //              "objectType": "Activity"
        //          }
        //          ],
        //          "parent": [
        //          {
        //              "definition": {
        //              "name": {
        //                  "en-US": "Three Digits"
        //              },
        //              "type": "https://w3id.org/xapi/seriousgames/activity-types/serious-game"
        //              },
        //              "id": "https://dig-itgames.com/three-digits",
        //              "objectType": "Activity"
        //          }]}
        //      }
        //
        // parent: Activity directly related to current Statement Object
        // grouping: Any other related activities
        // category: Educational Subject Area of current Statement Object
        // extensions: Related educational standards
        // ------------------------------------------------------------------------
        public Context CreateContextActivityStatement(List <Activity> parentList, List <Activity> groupingList = null, List <Activity> categoryList = null, TinCan.Extensions contextExtensions = null)
        {
            Context context = new Context();

            context.contextActivities = new ContextActivities();
            if (parentList != null)
            {
                context.contextActivities.parent = parentList;
            }
            if (groupingList != null)
            {
                context.contextActivities.grouping = groupingList;
            }
            if (categoryList != null)
            {
                context.contextActivities.category = categoryList;
            }
            if (contextExtensions != null)
            {
                context.extensions = contextExtensions;
            }

            return(context);
        }
Beispiel #6
0
        public ResultBuilder WithExtensions(TinCan.Extensions extensions)
        {
            _result.extensions = extensions;

            return(this);
        }
        public IOptional WithExtensions(TinCan.Extensions extensions)
        {
            _definition.extensions = extensions;

            return(this);
        }
Beispiel #8
0
        public ContextBuilder WithExtensions(TinCan.Extensions extensions)
        {
            _extensions = extensions;

            return(this);
        }
Beispiel #9
0
    // // ------------------------------------------------------------------------
    // // Sample Context Generators
    // // ------------------------------------------------------------------------

    /*
     * Since context generation can be many lines of code, it is often helpful to separate it out into helper functions.
     * These functions will be responsible for creating Context Activities, Context Extensions, and assigning them to a singular Context object.
     */

    public static Context CreateTestContext()
    {
        // CONTEXT ACTIVITIES

        // parent contains the activity just above this one in the hierarchy
        List <Activity> parentList = new List <Activity>();

        parentList.Add(GBLXAPI.Instance.CreateObjectActivityStatement(gameURI, "serious-game", gameName));

        // grouping contains all other related activities to this one
        List <Activity> groupingList = new List <Activity> ();

        groupingList.Add(GBLXAPI.Instance.CreateObjectActivityStatement(companyURI));

        // category is used in GBLxAPI to report on the subject area
        List <Activity> categoryList = new List <Activity> ();;

        categoryList.Add(GBLXAPI.Instance.CreateObjectActivityStatement("https://gblxapi.org/socialstudies"));
        categoryList.Add(GBLXAPI.Instance.CreateObjectActivityStatement("https://gblxapi.org/math"));

        // CONTEXT EXTENSIONS

        // grade
        List <JToken> gradeList = new List <JToken>();

        gradeList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Grade", "Grade 4 level"));

        // domain
        List <JToken> domainList = new List <JToken>();

        domainList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Domain", "History"));
        domainList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Domain", "Number and Operations in Base Ten"));

        // subdomain
        List <JToken> subdomainList = new List <JToken>();

        subdomainList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Subdomain", "Problem Solving"));

        // skill
        List <JToken> skillList = new List <JToken>();

        skillList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Skill", "Patterns and Relationships"));
        skillList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Skill", "Calculation and Computation"));

        // topic
        List <JToken> topicList = new List <JToken>();

        topicList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Topic", "Arithmetic"));

        // focus
        List <JToken> focusList = new List <JToken>();

        focusList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Focus", "Addition/Subtraction"));

        // action
        List <JToken> actionList = new List <JToken>();

        actionList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("Action", "Solve Problems"));

        // c3/ccss
        List <JToken> c3List = new List <JToken>();

        c3List.Add(GBLXAPI.Instance.CreateContextExtensionStatement("C3 Framework", "d2.His.13.6-8."));

        List <JToken> ccList = new List <JToken>();

        ccList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("CC-MATH", "CCSS.Math.Content.4.NBT.B.4"));
        ccList.Add(GBLXAPI.Instance.CreateContextExtensionStatement("CC-MATH", "CCSS.Math.Content.5.NBT.A.1"));

        // creating TinCan.Extensions object to pack the lists into
        TinCan.Extensions contextExtensions = new TinCan.Extensions();
        // adding lists to extensions JObject
        GBLXAPI.Instance.PackExtension("domain", domainList, contextExtensions);
        GBLXAPI.Instance.PackExtension("subdomain", subdomainList, contextExtensions);
        GBLXAPI.Instance.PackExtension("topic", topicList, contextExtensions);
        GBLXAPI.Instance.PackExtension("focus", focusList, contextExtensions);
        GBLXAPI.Instance.PackExtension("action", actionList, contextExtensions);
        GBLXAPI.Instance.PackExtension("skill", skillList, contextExtensions);
        GBLXAPI.Instance.PackExtension("grade", gradeList, contextExtensions);
        GBLXAPI.Instance.PackExtension("cc", ccList, contextExtensions);
        GBLXAPI.Instance.PackExtension("c3", c3List, contextExtensions);

        // Folding all of the above into our Context object to be used in the statement
        Context statementContext = GBLXAPI.Instance.CreateContextActivityStatement(parentList, groupingList, categoryList, contextExtensions);

        return(statementContext);
    }