Ejemplo n.º 1
0
    IEnumerator IEndTrade()
    {
        bool havePlace = InventoryManager.GetInventoryManager.GetInventory().GetNbRemainingPlace() >= hisTrade.GetNbOccupiedPlace();

        InteractionManager.GetInteractionManager.HavePlaceForTrade(havePlace);
        while (targetHavePlace == Anwser.none)
        {
            yield return(null);
        }

        if (targetHavePlace == Anwser.yes && havePlace)
        {
            AddTradeInventoryToPlayerInventory(hisTrade, nbColumnInventoryTrade, nbLineInventoryTrade);
            myTrade.Clear();
            hisTrade.Clear();
        }
        else if (!havePlace)
        {
            ChatManager.GetChatManager.SendInfoMsg("Vous n'avez pas la place dans votre inventaire", Message.MessageType.info);
        }
        else if (targetHavePlace == Anwser.no)
        {
            ChatManager.GetChatManager.SendInfoMsg(InteractionManager.GetInteractionManager.TargetName + " n'a pas la place dans son inventaire", Message.MessageType.info);
        }
        Close();
        targetHavePlace = Anwser.none;
        InventoryManager.GetInventoryManager.UpdateInventory();
    }
Ejemplo n.º 2
0
        public ExamAttempt recalculate(ExamAttempt obj)
        {
            //TODO
            float sumAttempt = 0;

            obj.Anwsers = _context.Anwsers.Where(x => x.ExamAttemptID == obj.ID).ToArray();
            for (int i = 0; i < obj.Anwsers.Count; i++)
            {
                Anwser         item = obj.Anwsers.ElementAt(i);
                Question       q    = _context.Questions.Find(item.QuestionID);
                float          max  = (float)q.Max;
                List <Mistake> list = _context.Mistakes.Where(x => x.AnwserID == item.ID).ToList();
                if (list.Count() != 0)
                {
                    item.Total = max + list.Sum(x => x.AdjustedWeight) + (float)item.Adjustment;
                }
                sumAttempt += item.Total;
                _context.Anwsers.Update(item);
            }

            obj.Total = sumAttempt;
            _context.ExamAttempts.Update(obj);
            _context.SaveChanges();
            return(obj);
        }
Ejemplo n.º 3
0
        public async Task PostTwo(Two anwser, string veld)
        {
            var value = new Anwser
            {
                data = anwser.answer,
                name = veld
            };
            var data = new Body
            {
                challengeId = ChallengeTwo.id
            };

            data.values = new List <Anwser>();
            data.values.Add(value);

            var client  = new RestClient("http://htf2018.azurewebsites.net");
            var request = new RestRequest("challenges/{id}", Method.POST);

            request.AddUrlSegment("id", ChallengeTwo.id);
            request.AddJsonBody(data);
            request.AddHeader("htf-identification", "ODc2ZjM2NjYtZGUyNy00ZDczLThkN2QtOTY4ZTA2NzY3MGMy");

            IRestResponse response = client.Execute(request);
            var           content  = response.Content;
        }
Ejemplo n.º 4
0
 public void Open()
 {
     if (!isOpen)
     {
         targetHavePlace = Anwser.none;
         isOpen          = true;
         onOpen();
     }
 }
Ejemplo n.º 5
0
 public ActionResult AddUpdate(Anwser model)
 {
     model.Status      = 1;
     model.CreatedDate = DateTime.Now;
     if (new SqlAnwserDao().Insert(model))
     {
         TempData["success"] = "Cập nhật thành công";
     }
     else
     {
         TempData["error"] = "Cập nhật thất bại";
     }
     return(Redirect("/Admin/Anwser"));
 }
Ejemplo n.º 6
0
        public Anwser Create(Anwser newObject)
        {
            if (newObject.ExamAttemptID != null && _context.Anwsers.Find(newObject.ExamAttemptID) == null)
            {
                throw new AppException("Exam attempt " + newObject.ExamAttemptID + " does not exist");
            }

            newObject.Completion     = "Blank";
            newObject.CensorshipDate = DateTime.Now;
            _context.Anwsers.Add(newObject);
            _context.SaveChanges();

            return(_context.Anwsers.Last(x => x.ExamAttemptID == x.ExamAttemptID));
        }
Ejemplo n.º 7
0
        public void Delete(int id)
        {
            Anwser t = _context.Anwsers.Find(id);

            if (t != null)
            {
                List <Mistake> children = _context.Mistakes.ToList().FindAll(x => x.AnwserID == id);
                foreach (Mistake item in children)
                {
                    this.Delete(item.ID);
                }
                _context.Anwsers.Remove(t);
                _context.SaveChanges();
            }
        }
Ejemplo n.º 8
0
        public IActionResult Create([FromBody] AnwserDto anwserDto)
        {
            // map dto to entity and set id
            Anwser c = _mapper.Map <Anwser>(anwserDto);

            try
            {
                // save
                c = _anwserService.Create(c);
                return(Ok(_mapper.Map <AnwserDto>(c)));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 9
0
        public Anwser UpdateCompletion(Anwser obj, string completion)
        {
            Anwser t = _context.Anwsers.Find(obj.ID);

            if (t == null)
            {
                throw new AppException("Anwser " + obj.ID + " not found");
            }

            float max = (float)_context.Questions.Find(t.QuestionID).Max;

            t.Completion = completion;

            if (completion == "Attempted")
            {
                if (_context.Mistakes.Where(x => x.AnwserID == obj.ID).Count() != 0)
                {
                    t.Total = (float)(max - (float)(_context.Mistakes.Where(x => x.AnwserID == obj.ID).Sum(x => x.AdjustedWeight))) + (float)t.Adjustment;
                }
                else
                {
                    t.Total = max;
                }
            }
            else
            {
                _context.Mistakes.RemoveRange(_context.Mistakes.Where(x => x.AnwserID == obj.ID));
                _context.GeneralCritereaImpacts.RemoveRange(_context.GeneralCritereaImpacts.Where(x => x.AnwserID == obj.ID));
                t.Adjustment = 0;
                if (completion == "Blank")
                {
                    t.Total = 0;
                }
                else
                {
                    t.Total = max;
                }
                t.Adjustment = 0;
            }
            t.CensorshipDate = DateTime.Now;
            _context.Anwsers.Update(t);
            _context.SaveChanges();


            return(t);
        }
Ejemplo n.º 10
0
 IEnumerator ITrade()
 {
     if (identity == null)
     {
         identity = GetComponent <NetworkIdentity>();
     }
     if (!identity.hasAuthority)
     {
         playerController.CmdSetAuthority(identity);
     }
     while (!identity.hasAuthority)
     {
         yield return(null);
     }
     CmdSendRequestForTrade(targetIdentity, PlayerManager.GetPlayerManager.Player.PlayerName);
     anwser = Anwser.none;
     StartCoroutine(WaitAnswerForTrade());
 }
Ejemplo n.º 11
0
        public ExamAttempt recalculateSimple(int id)
        {
            ExamAttempt obj = _context.ExamAttempts.Find(id);

            if (obj == null)
            {
                throw new AppException("ExamAttempt not found");
            }

            float sumAttempt = 0, partial = 0;

            obj.Anwsers = _context.Anwsers.Where(x => x.ExamAttemptID == obj.ID).ToArray();
            for (int i = 0; i < obj.Anwsers.Count; i++)
            {
                Anwser item = obj.Anwsers.ElementAt(i);
                sumAttempt += item.Total;
            }

            obj.Total = sumAttempt;
            _context.ExamAttempts.Update(obj);
            _context.SaveChanges();
            return(obj);
        }
Ejemplo n.º 12
0
        public Anwser Update(Anwser updatedObject)
        {
            Anwser t = _context.Anwsers.Find(updatedObject.ID);

            if (t == null)
            {
                throw new AppException("Anwser " + updatedObject.ID + " not found");
            }

            _context.Mistakes.RemoveRange(_context.Mistakes.Where(x => x.AnwserID == updatedObject.ID));
            _context.GeneralCritereaImpacts.RemoveRange(_context.GeneralCritereaImpacts.Where(x => x.AnwserID == updatedObject.ID && x.MistakeID != null));
            _context.SaveChanges();

            /*copy properties here*/
            Question q   = _context.Questions.Find(t.QuestionID);
            float    max = (float)q.Max;

            //List<Mistake> list = _context.Mistakes.Where(x => x.AnwserID == t.ID).ToList();
            t.Adjustment = updatedObject.Adjustment;
            t.Total      = max;


            foreach (Mistake item in updatedObject.Mistakes)
            {
                Mistake temp = new Mistake()
                {
                    AnwserID = t.ID, ArgumentID = item.ArgumentID, AdjustedWeight = item.AdjustedWeight
                };
                _context.Mistakes.Add(temp);
                _context.SaveChanges();
                temp = _context.Mistakes.Last(x => x.AnwserID == t.ID);

                foreach (ArgumentCriterea ac in _context.ArgumentCritereas.Where(x => x.ArgumentID == item.ArgumentID))
                {
                    GeneralCritereaImpact tempgc = new GeneralCritereaImpact()
                    {
                        ExamAttemptID = t.ExamAttemptID, AnwserID = t.ID, MistakeID = temp.ID, ExamCritereaID = ac.ExamCritereaID, Weight = ac.Severity
                    };
                    _context.GeneralCritereaImpacts.Add(tempgc);
                }

                t.Total += item.AdjustedWeight;
                _context.SaveChanges();
            }

            if (t.Total + t.Adjustment > max)
            {
                t.Adjustment = max - t.Total;
                t.Total      = max;
            }
            else
            {
                t.Total += (float)t.Adjustment;
            }

            t.FinalTotal     = updatedObject.FinalTotal;
            t.CensorshipDate = DateTime.Now;
            t.Note           = updatedObject.Note;

            t.Completion = updatedObject.Completion;

            _context.Anwsers.Update(t);
            _context.SaveChanges();

            return(t);
        }
Ejemplo n.º 13
0
 void TargetGetAnswerForTrade(NetworkConnection networkConnection, Anwser anwser)
 {
     this.anwser = anwser;
 }
Ejemplo n.º 14
0
 void CmdSendAnswerForTrade(NetworkIdentity targetIdentity, Anwser anwser)
 {
     TargetGetAnswerForTrade(targetIdentity.connectionToClient, anwser);
 }