Example #1
0
        /// <summary>
        /// Manages the interaction of a user with a group
        /// </summary>
        /// <param name="user">The user who has interacted with the group</param>
        /// <param name="group">The group</param>
        /// <param name="type">The interaction id</param>
        /// <param name="dbContext">The database context</param>
        public static void manageInteraction(User user, Group group, interactionType type, ApplicationDBContext dbContext)
        {
            List <GroupInteraction> interactions = dbContext.GroupInteractions.Where(gi => gi.groupid == group.id && gi.userid == user.id).ToList();
            bool leftTheGroup          = type == interactionType.LEAVED ? true : false;
            bool wasKickedFromTheGroup = type == interactionType.KICKED ? true : false;

            try
            {
                if (interactions.Count() != 1)
                {
                    GroupInteraction gi = new GroupInteraction
                    {
                        Group  = group,
                        User   = user,
                        kicked = wasKickedFromTheGroup,
                        leaved = leftTheGroup
                    };
                    dbContext.Add(gi);
                }
                else
                {
                    GroupInteraction gi = interactions.First();
                    gi.dateLeave = DateTime.Now;
                    gi.kicked    = wasKickedFromTheGroup;
                    gi.leaved    = leftTheGroup;
                }
                dbContext.SaveChanges();
            }
            catch (Exception) { }
        }
        private void interactionsPerfValidate(interactionType rsp)
        {
            Assert.AreEqual(interactionTypeType.performance, rsp.type);
            correctResponsesTypeCorrectResponsePerformance[] responses = new correctResponsesTypeCorrectResponsePerformance[rsp.correctResponses.Items.Length];
            for (int ii = 0; ii < rsp.correctResponses.Items.Length; ii++)
            {
                responses[ii] = (correctResponsesTypeCorrectResponsePerformance)rsp.correctResponses.Items[ii];
            }
            learnerResponseTypeLearnerResponsePerformance[] lResponses = new learnerResponseTypeLearnerResponsePerformance[rsp.learnerResponse.Items.Length];
            for (int ii = 0; ii < rsp.learnerResponse.Items.Length; ii++)
            {
                lResponses[ii] = (learnerResponseTypeLearnerResponsePerformance)rsp.learnerResponse.Items[ii];
            }
            Assert.AreEqual(rsp.result, interactionTypeResult.incorrect);
            Assert.IsTrue(rsp.resultSpecified);

            Assert.AreEqual(2, responses.Length, "response count");
            Assert.AreEqual(2, responses[0].step.Length, "response 1 step count");
            Assert.AreEqual(2, responses[1].step.Length, "response 2 step count");
            Assert.AreEqual(2, rsp.learnerResponse.Items.Length, "learner response count");

            Assert.AreEqual("answer 1", lResponses[0].stepAnswer.Item.ToString(), "learner response 1 step 1 answer");
            Assert.AreEqual("step_1", lResponses[0].stepName, "learner response 1 step 1 name");
            Assert.AreEqual("23", lResponses[1].stepAnswer.Item.ToString(), "learner response 2 step 1 answer");
            Assert.AreEqual("step_2_min_42", lResponses[1].stepName, "learner response 2 step 1 name");

            perfValidateStep(responses[0].step[1], "step_2_min_42", 42M, null, "response 1 step 1");
            perfValidateStep(responses[0].step[0], "step_1", "answer 1", "response 1 step 1");
            perfValidateStep(responses[1].step[0], "step_1_max_100", null, 100M, "response 2 step 1");
            perfValidateStep(responses[1].step[1], "step_2_minmax_no_limit", null, null, "response 2 step 2");
        }
        public void interactionsLongFillIn()
        {
            LETSIRTE_Service client = getClient();

            string intFillInID = "Long_FillIn";

            cocdType        cocd  = client.Get();
            interactionType inter = cocd.GetInteraction(intFillInID, true);

            inter.type             = interactionTypeType.long_fill_in;
            inter.correctResponses = new correctResponsesType();
            inter.correctResponses.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.correctResponseLongFillIn, ItemsChoiceType.correctResponseLongFillIn };
            correctResponsesTypeCorrectResponseLongFillIn rsp  = new correctResponsesTypeCorrectResponseLongFillIn();
            correctResponsesTypeCorrectResponseLongFillIn rsp2 = new correctResponsesTypeCorrectResponseLongFillIn();

            inter.correctResponses.Items = new object[] { rsp, rsp2 };

            rsp.Value  = "answer 1";
            rsp2.Value = "answer 2";

            inter.description       = new interactionTypeDescription();
            inter.description.Value = "long fillin interaction";
            inter.learnerResponse   = new learnerResponseType();
            inter.learnerResponse.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.learnerResponseLongFillIn };
            learnerResponseTypeLearnerResponseLongFillIn lrsp = new learnerResponseTypeLearnerResponseLongFillIn();

            inter.learnerResponse.Items = new object[] { lrsp };

            lrsp.Value = "answer 2";

            inter.result          = interactionTypeResult.correct;
            inter.resultSpecified = true;


            Assert.IsNotNull(inter, "inter");
            Assert.IsNotNull(inter.correctResponses, "inter.correctResponses");
            Assert.IsNotNull(inter.correctResponses.Items, "inter.correctResponses.Items");
            Assert.AreEqual(2, inter.correctResponses.Items.Length, "correct response count");
            Assert.AreEqual(1, inter.learnerResponse.Items.Length, "learner response count");
            Assert.AreEqual("answer 1", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[0]).Value, "correct response 1");
            Assert.AreEqual("answer 2", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[1]).Value, "correct response 2");
            Assert.AreEqual("answer 2", ((learnerResponseTypeLearnerResponseLongFillIn)inter.learnerResponse.Items[0]).Value, "learner response");


            cocd.exit          = exit.suspend;
            cocd.exitSpecified = true;
            client.Set(cocd);
            cocd = client.Get();

            inter = cocd.GetInteraction(intFillInID, false);
            Assert.IsNotNull(inter, "inter");
            Assert.IsNotNull(inter.correctResponses, "inter.correctResponses");
            Assert.IsNotNull(inter.correctResponses.Items, "inter.correctResponses.Items");
            Assert.AreEqual(2, inter.correctResponses.Items.Length, "correct response count");
            Assert.AreEqual(1, inter.learnerResponse.Items.Length, "learner response count");
            Assert.AreEqual("answer 1", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[0]).Value, "correct response 1");
            Assert.AreEqual("answer 2", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[1]).Value, "correct response 2");
            Assert.AreEqual("answer 2", ((learnerResponseTypeLearnerResponseLongFillIn)inter.learnerResponse.Items[0]).Value, "learner response");
        }
        public void interactionsPerformanceTest()
        {
            LETSIRTE_Service client = getClient();

            string int2ID = "Performance_interaction_upd";

            cocdType        cocd = client.Get();
            interactionType perf = cocd.GetInteraction(int2ID, true);

            perf.type             = interactionTypeType.performance;
            perf.correctResponses = new correctResponsesType();
            perf.correctResponses.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.correctResponsePerformance, ItemsChoiceType.correctResponsePerformance };
            correctResponsesTypeCorrectResponsePerformance rsp  = new correctResponsesTypeCorrectResponsePerformance();
            correctResponsesTypeCorrectResponsePerformance rsp2 = new correctResponsesTypeCorrectResponsePerformance();

            perf.correctResponses.Items = new object[] { rsp, rsp2 };

            rsp.step = new correctResponsesTypeCorrectResponsePerformanceStep[] {
                new correctResponsesTypeCorrectResponsePerformanceStep("step_1", "answer 1"),
                new correctResponsesTypeCorrectResponsePerformanceStep("step_2_min_42", 42M, null)
            };
            rsp2.step = new correctResponsesTypeCorrectResponsePerformanceStep[] {
                new correctResponsesTypeCorrectResponsePerformanceStep("step_1_max_100", null, 100M),
                new correctResponsesTypeCorrectResponsePerformanceStep("step_2_minmax_no_limit", null, null)
            };

            perf.description       = new interactionTypeDescription();
            perf.description.Value = "performance interaction";
            perf.learnerResponse   = new learnerResponseType();
            perf.learnerResponse.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.learnerResponsePerformance, ItemsChoiceType1.learnerResponsePerformance };
            learnerResponseTypeLearnerResponsePerformance lrsp  = new learnerResponseTypeLearnerResponsePerformance();
            learnerResponseTypeLearnerResponsePerformance lrsp2 = new learnerResponseTypeLearnerResponsePerformance();

            perf.learnerResponse.Items = new object[] { lrsp, lrsp2 };
            lrsp.stepName        = "step_1";
            lrsp.stepAnswer      = new learnerResponseTypeLearnerResponsePerformanceStepAnswer();
            lrsp.stepAnswer.Item = "answer 1";

            lrsp2.stepName        = "step_2_min_42";
            lrsp2.stepAnswer      = new learnerResponseTypeLearnerResponsePerformanceStepAnswer();
            lrsp2.stepAnswer.Item = 23M; // WRONG!

            perf.result          = interactionTypeResult.incorrect;
            perf.resultSpecified = true;

            interactionsPerfValidate(cocd.GetInteraction(int2ID, false));

            cocd.exit          = exit.suspend;
            cocd.exitSpecified = true;
            client.Set(cocd);
            cocd = client.Get();

            interactionsPerfValidate(cocd.GetInteraction(int2ID, false));
        }
Example #5
0
    public void Interact(interactionType type, bool state)
    {
        Vector3 center = transform.position;

        Collider[] hitColliders = Physics.OverlapSphere(center, interactionRadius);

        foreach (Collider col in hitColliders)
        {
            //Debug.Log(col.tag + " | " + tags[type]);
            if(col.tag == tags[type])
            {
                col.GetComponent<Interactable>().ChangeState(type, state);
            }
        }
    }
Example #6
0
    ///<summary>
    ///Add an interaction to the course data.
    ///</summary>
    ///<returns>
    ///A new interaction object.
    ///</returns>
    ///<remarks>
    ///The new interaction object created is added into the array, it is not necessary to add it
    ///again manually. The identifier is generated automatically, as is the timestamp.
    ///The new interaction is the LongFillIn type. You will have to get deeper into the SCORM for
    ///other types. Note that if you wish to set the LearnerResponse values, you need to cast
    ///interaction.learner_response to learnerResponseTypeLearnerResponseLongFillIn
    ///</remarks>
    public static interactionType AddInteraction()
    {
        interactionType i = new interactionType();

        i.id = "urn:ADL:interaction-id-" + GetLearnerRecord().interactions.Count.ToString();
        learnerResponseTypeLearnerResponseLongFillIn lrs = new learnerResponseTypeLearnerResponseLongFillIn();

        lrs.Value          = "this is the data that should be in the answer";
        lrs.lang           = "en-US";
        i.learner_response = lrs;
        i.objectives       = new System.Collections.Generic.List <objectiveIDType>();
        i.result           = interactionTypeResult.incorrect;

        i.timestamp         = new Scorm2004.DateTime(System.DateTime.Now);
        i.type              = interactionTypeType.long_fill_in;
        i.weighting         = new System.Decimal(100);
        i.description.lang  = "en-US";
        i.description.Value = "this is the description for the interaction";

        GetLearnerRecord().interactions.Add(i);
        return(i);
    }
Example #7
0
        /// <summary>
        /// Join a user to a group
        /// </summary>
        /// <param name="order">The info to join to a group</param>
        /// See <see cref="Areas.GroupManage.Models.JoinGroup"/> to know the param structure
        /// <returns>IActionResult of the joining group action</returns>
        public IActionResult joinGroup([FromBody] JoinGroup order)
        {
            User user = TokenUserManager.getUserFromToken(HttpContext, _context);

            if (!user.open)
            {
                return(BadRequest(new { error = "YoureBanned" }));
            }
            if (AdminPolicy.isAdmin(user, _context))
            {
                return(BadRequest("notAllowed"));
            }
            Group group = new Group();

            if (!isUnderLimitations(user))
            {
                return(BadRequest(new { error = "MaxGroupJoinsReached" }));
            }
            if (!hasPermissions(user, ref group, order.groupName))
            {
                return(BadRequest());
            }

            if (group.password != null && !PasswordHasher.areEquals(order.password, group.password))
            {
                return(BadRequest(new { error = "IncorrectPasswordJoiningGroup" }));
            }
            if (!group.open)
            {
                return(BadRequest(new { error = "GroupBanned" }));
            }
            interactionType type = checkInteractions(user, group);

            if (type != interactionType.NONE)
            {
                if (type == interactionType.KICKED)
                {
                    return(BadRequest(new { error = "YouwereKickedGroup" }));
                }
                else
                {
                    return(BadRequest(new { error = "YouhasleavedGroup" }));
                }
            }

            try
            {
                UserGroup newUser = new UserGroup
                {
                    User     = user,
                    Group    = group,
                    role     = RoleManager.getGroupNormal(_context),
                    dateRole = DateTime.Today,
                    coins    = group.weeklyPay
                };

                _context.UserGroup.Add(newUser);
                _context.SaveChanges();
                Home.Util.GroupNew.launch(user, group, null, Home.Models.TypeGroupNew.JOIN_LEFT_GROUP, true, _context);
                Home.Util.GroupNew.launch(user, group, null, Home.Models.TypeGroupNew.JOIN_LEFT_USER, true, _context);

                return(Ok(new { success = "SuccesfullJoinGroup" }));
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }
        public void interactionsSequencing()
        {
            LETSIRTE_Service client = getClient();

            string intSeqId = "Sequencing";

            cocdType        cocd  = client.Get();
            interactionType inter = cocd.GetInteraction(intSeqId, true);

            inter.type             = interactionTypeType.sequencing;
            inter.correctResponses = new correctResponsesType();
            inter.correctResponses.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.correctResponseSequencing, ItemsChoiceType.correctResponseSequencing };
            correctResponsesTypeCorrectResponseSequencing rsp  = new correctResponsesTypeCorrectResponseSequencing();
            correctResponsesTypeCorrectResponseSequencing rsp2 = new correctResponsesTypeCorrectResponseSequencing();

            inter.correctResponses.Items = new object[] { rsp, rsp2 };

            rsp.step  = new string[] { "1", "2", "3", "4" };
            rsp2.step = new string[] { "A", "B", "C" };

            inter.description       = new interactionTypeDescription();
            inter.description.Value = "Sequencing interaction";
            inter.learnerResponse   = new learnerResponseType();
            inter.learnerResponse.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.learnerResponseSequencing, ItemsChoiceType1.learnerResponseSequencing };
            learnerResponseTypeLearnerResponseSequencing lrsp = new learnerResponseTypeLearnerResponseSequencing();

            inter.learnerResponse.Items = new object[] { lrsp };

            lrsp.step = new string[] { "A", "B", "C" };

            inter.result          = interactionTypeResult.correct;
            inter.resultSpecified = true;

            Assert.IsNotNull(inter, "inter");
            Assert.IsNotNull(inter.correctResponses, "inter.correctResponses");
            Assert.IsNotNull(inter.correctResponses.Items, "inter.correctResponses.Items");
            Assert.AreEqual(2, inter.correctResponses.Items.Length, "correct response count");
            Assert.AreEqual(1, inter.learnerResponse.Items.Length, "learner response count");
            Assert.AreEqual(4, ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[0]).step.Length, "correct response 1 step count");
            Assert.AreEqual(3, ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[1]).step.Length, "correct response 2 step count");
            Assert.AreEqual("1,2,3,4", string.Join(",", ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[0]).step), "correct response 1");
            Assert.AreEqual("A,B,C", string.Join(",", ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[1]).step), "correct response 2");
            Assert.AreEqual("A,B,C", string.Join(",", ((learnerResponseTypeLearnerResponseSequencing)inter.learnerResponse.Items[0]).step), "learner response");


            cocd.exit          = exit.suspend;
            cocd.exitSpecified = true;
            client.Set(cocd);
            cocd = client.Get();

            inter = cocd.GetInteraction(intSeqId, false);
            Assert.IsNotNull(inter, "inter");
            Assert.IsNotNull(inter.correctResponses, "inter.correctResponses");
            Assert.IsNotNull(inter.correctResponses.Items, "inter.correctResponses.Items");
            Assert.AreEqual(2, inter.correctResponses.Items.Length, "correct response count");
            Assert.AreEqual(1, inter.learnerResponse.Items.Length, "learner response count");
            Assert.AreEqual(4, ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[0]).step.Length, "correct response 1 step count");
            Assert.AreEqual(3, ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[1]).step.Length, "correct response 2 step count");
            Assert.AreEqual("1,2,3,4", string.Join(",", ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[0]).step), "correct response 1");
            Assert.AreEqual("A,B,C", string.Join(",", ((correctResponsesTypeCorrectResponseSequencing)inter.correctResponses.Items[1]).step), "correct response 2");
            Assert.AreEqual("A,B,C", string.Join(",", ((learnerResponseTypeLearnerResponseSequencing)inter.learnerResponse.Items[0]).step), "learner response");
        }
        private void interactionsTest(bool testArrayClear)
        {
            LETSIRTE_Service client = getClient();

            string int1ID = "test_interaction_1";

            cocdType        cocd = client.Get();
            interactionType int1 = cocd.GetInteraction(int1ID, true);

            int1.type             = interactionTypeType.fill_in;
            int1.correctResponses = new correctResponsesType();
            int1.correctResponses.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.correctResponseFillIn };
            correctResponsesTypeCorrectResponseFillIn rsp = new correctResponsesTypeCorrectResponseFillIn();

            int1.correctResponses.Items = new object[] { rsp };
            rsp.caseMatters             = false;
            rsp.orderMatters            = false;
            correctResponsesTypeCorrectResponseFillInMatchText match  = new correctResponsesTypeCorrectResponseFillInMatchText();
            correctResponsesTypeCorrectResponseFillInMatchText match2 = new correctResponsesTypeCorrectResponseFillInMatchText();

            rsp.matchText = new correctResponsesTypeCorrectResponseFillInMatchText[] { match, match2 };
            match.Value   = "answer 42";
            match2.Value  = "answer 2";

            int1.learnerResponse = new learnerResponseType();
            int1.learnerResponse.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.learnerResponseFillIn };
            learnerResponseTypeLearnerResponseFillIn lrsp = new learnerResponseTypeLearnerResponseFillIn();

            int1.learnerResponse.Items = new object[] { lrsp };
            lrsp.Value = "ANSWER 1";

            int1.result             = interactionTypeResult.correct;
            int1.resultSpecified    = true;
            int1.timeStamp          = DateTime.UtcNow;
            int1.timeStampSpecified = true;

            int1.objectiveIds = new string[] { "id1", "id2" };

            cocd.exitSpecified = true;
            cocd.exit          = exit.suspend;
            client.Set(cocd);
            cocd = client.Get();

            int1 = cocd.GetInteraction(int1ID, false);
            Assert.AreEqual(interactionTypeType.fill_in, int1.type);

            Assert.AreEqual(((correctResponsesTypeCorrectResponseFillIn)int1.correctResponses.Items[0]).matchText[0].Value, "answer 42");
            learnerResponseTypeLearnerResponseFillIn lr = (learnerResponseTypeLearnerResponseFillIn)int1.learnerResponse.Items[0];

            Thread.Sleep(1000);

            Assert.AreEqual(lr.Value.ToLower(), "answer 1");
            Assert.AreEqual(interactionTypeResult.correct, int1.result);
            Assert.IsTrue(int1.resultSpecified);
            Assert.Greater(DateTime.UtcNow, int1.timeStamp);
            Assert.IsTrue(int1.timeStampSpecified);
            Assert.AreEqual("id2", int1.objectiveIds[1]);

            if (testArrayClear)
            {
                cocd.exitSpecified         = true;
                cocd.exit                  = exit.suspend;
                int1.learnerResponse.Items = new object[] { };
                int1.objectiveIds          = new string[] { };
                client.Set(cocd);
                cocd = client.Get();

                int1 = cocd.GetInteraction(int1ID, false);

                // null or length==0 is acceptable
                if (int1.learnerResponse != null && int1.learnerResponse.Items != null)
                {
                    Assert.AreEqual(0, int1.learnerResponse.Items.Length, "Failed to clear array");
                }
                // null or length==0 is acceptable
                if (int1.objectiveIds != null)
                {
                    Assert.AreEqual(0, int1.objectiveIds.Length, "Failed to clear array");
                }
            }
        }
Example #10
0
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("item"))//outline
        {
            type = PlayerMovement.interactionType.item;

            if (item == null)
            {
                item = other.gameObject.GetComponent <itemPick>();
            }

            if (item.isPick == false)
            {
                item.outlinerItem.enabled = true;
                item.interactionIcon.SetActive(true);
            }
            else
            {
                item.outlinerItem.enabled = false;
                item.interactionIcon.SetActive(false);
            }
        }

        //pot
        if (other.CompareTag("pot"))//outline
        {
            type = PlayerMovement.interactionType.pot;

            if (potActuel == null)
            {
                potActuel = other.gameObject.GetComponent <pot>();
            }

            if (potActuel.fleurDePot.activeInHierarchy == false)
            {
                potActuel.outlinerItem.enabled = true;
                potActuel.interactionIcon.SetActive(true);
                potActuel.interactionIcon2.SetActive(true);
            }
        }

        //panneau
        if (other.CompareTag("panneau"))//outline
        {
            type = PlayerMovement.interactionType.panneau;

            if (panneau == null)
            {
                panneau = other.gameObject.GetComponent <cartePanneau>();
            }


            panneau.outlinerItem.enabled = true;
            panneau.interactionIcon.SetActive(true);
        }

        //dialogue
        if (other.CompareTag("dialogue"))
        {
            type = PlayerMovement.interactionType.dialogue;

            if (managerDialogue.dialogueActive == false)
            {
                dialogueActuel = null;

                if (dialogueActuel == null)
                {
                    dialogueActuel = other.GetComponent <Dialogue_Trigger>();
                }

                dialogueActuel.enabled = true;
                dialogueActuel.ActiveOutline();
            }
        }


        //banc

        if (other.CompareTag("banc"))
        {
            type = PlayerMovement.interactionType.banc;

            bancActuel = other.GetComponent <banc>();

            bancActuel.enabled = true;

            if (bancActuel.isBanc == false)
            {
                bancActuel.ActiveOutline();
            }
        }
    }