Пример #1
0
        internal List<UserQuestion> AssignQuestionsIds(string userid )
        {
            UserQuestionContext uqc = new UserQuestionContext();
            var quassign = uqc.GetAllForPartition(userid);
            if (quassign.Count == 0 )
            {
                var rez = GetAll();
                foreach (var item in rez)
                {
                    UserQuestion uq = new UserQuestion();
                    uq.UserId = userid;
                    uq.QuestionId = item.QuestionId;
                    uq.CategoryId = item.CategoryId;
                    uq.IsActive = true;
                    uqc.AddObject(uq);
                }

            }

            quassign = uqc.GetAllForPartition(userid);
            return quassign.ToList<UserQuestion>();
        }
Пример #2
0
        private CategoryScore[] CalculateScore(string id)
        {
            UserQuestionContext uqc = new UserQuestionContext();
            var ques = uqc.GetAllForPartition(id);

               var results = from q in ques
                          group  q by q.CategoryId into grps
                          select new CategoryScore {CategoryId = grps.Key , Score = grps.Sum(g=>g.Answer)};

               return results.ToArray();
        }
Пример #3
0
 internal void RemoveQuestions(string userid)
 {
     UserQuestionContext uqc = new UserQuestionContext();
     var quassign = uqc.GetAllForPartition(userid);
     if (quassign != null)
     {
         foreach (var item in quassign)
         {
             uqc.DeleteObject(item,false);
         }
     }
 }