Exemple #1
0
 private void SetTipQuestions(QuestionPool pool, List <int> usedIds)
 {
     for (int i = 0; i < DifficultyLevels; i++)
     {
         pool.SetTipQuestion(GetRandomQuestion(i, usedIds), i);
     }
 }
Exemple #2
0
        public async Task <ActionResult> Create(QuestionViewModel model)
        {
            try
            {
                string examFormat = model.qExamFormat == "Test" ? "Test" : "Classic";

                if (model.Question == "")
                {
                    ViewData["result"] = new Result {
                        error = true, message = "Soru alaný boþ býrakýlamaz !"
                    };
                    return(View("Create" + examFormat, model));
                }
                else if (examFormat == "Test" && model.DescriptionJ == null)
                {
                    ViewData["result"] = new Result {
                        error = true, message = "Test alaný boþ býrakýlamaz !"
                    };
                    return(View("Create" + examFormat, model));
                }


                var question = new QuestionPool
                {
                    Question    = model.Question,
                    Description = model.qExamFormat == "Klasik" ? model.Description
                            : Newtonsoft.Json.JsonConvert.SerializeObject(model.DescriptionJ),
                    ExamFormat = model.qExamFormat,
                    ExamType   = model.qExamType,
                    LessonId   = GetLesson(model.qLessonGuid).Id,
                    SubjectId  = model.qSubjectId,
                    Answer     = model.Answer
                };

                _context.QuestionPools.Add(question);
                var result = await _context.QuestionPools.SaveChangesAsync();

                if (result > 0)
                {
                    ViewData["result"] = new Result {
                        error = false, message = "Kayýt Baþrlý."
                    };
                    return(View("Create" + examFormat, new QuestionViewModel()));
                }
                else
                {
                    ViewData["result"] = new Result {
                        error = true, message = "Kayýt sýrasýnda bir hata oluþtu !"
                    };
                    return(View("Create" + examFormat, model));
                }
            }
            catch
            {
                ViewData["result"] = new Result {
                    error = true, message = "Kayýt sýrasýnda sitemde bir hata oluþru !"
                };
                return(View());
            }
        }
Exemple #3
0
 private void SetQuestions(QuestionPool pool, List <int> usedIds)
 {
     for (byte i = 0; i < PoolSize; i++)
     {
         int difficulty = i >= 10 ? 2 : i >= 5 ? 1 : 0;
         pool.SetQuestion(GetRandomQuestion(difficulty, usedIds), i);
     }
 }
Exemple #4
0
 public ActionResult Create(QuestionPool questionpool)
 {
     if (ModelState.IsValid)
     {
         db.QuestionPools.Add(questionpool);
         db.SaveChanges();
         return(RedirectToAction("Index", "Settings"));
     }
     return(RedirectToAction("Index", "Settings"));
     //ViewBag.Type = new SelectList(db.QATypes, "TypeId", "Description", questionpool.Type);
 }
Exemple #5
0
        public async Task <ActionResult> Edit(int id, QuestionViewModel model)
        {
            try
            {
                string examFormat = model.qExamFormat == "Test" ? "Test" : "Classic";

                if (model.Question == "")
                {
                    return(View("Edit" + examFormat, model));
                }
                else if (examFormat == "Test" && model.DescriptionJ == null)
                {
                    return(View("Edit" + examFormat, model));
                }


                QuestionPool q = _context.QuestionPools
                                 .GetAll().Where(x => x.Id == model.Id && x.Lesson.UserId == GetUser.Id)
                                 .SingleOrDefault();
                q.Question = model.Question;
                q.Answer   = model.Answer;

                if (q.ExamFormat == "Klasik")
                {
                    q.Description = model.Description;
                }
                else if (q.ExamFormat == "Test")
                {
                    q.Description = Newtonsoft.Json.JsonConvert.SerializeObject(model.DescriptionJ);
                }


                var result = await _context.QuestionPools.SaveChangesAsync();

                if (result > 0)
                {
                    return(Redirect("~/Question/Details/" + model.qLessonGuid));
                }
                else
                {
                    return(View("Edit" + examFormat, model));
                }
            }
            catch
            {
                return(Redirect("~/Question/Edit/" + id));
            }
        }
Exemple #6
0
    public QuestionPool GetQuestionPoolFromLocal(Player player = null)
    {
        List <int> usedIds = SetUsedIds(player);
        var        pool    = new QuestionPool()
        {
            questions    = new Question[PoolSize],
            answers      = new string[PoolSize],
            tipQuestions = new Question[DifficultyLevels],
            tipAnswers   = new string[DifficultyLevels]
        };

        SetQuestions(pool, usedIds);
        SetTipQuestions(pool, usedIds);

        // string ss = "";
        // foreach (var q in qs) ss += $"qid: {q.id} \nq: {q.question} \n---\n";
        // Debug.LogWarning(ss);
        return(pool);
    }
Exemple #7
0
 static void CreateEnglishMap(LineIds line, string basicPath) {
   ScanDir sd = new ScanDir(); sd.BasicPath = basicPath; sd.FileMask = @"(?i:\.xml)$";
   QuestionPool res = new QuestionPool() { Line = line };
   res.Pointers = sd.FileName(FileNameMode.RelPath).Select(fn => fn.ToLower()).Where(fn => !fn.StartsWith("map")).Select(fn => createPointer(basicPath, fn)).Where(p => p != null).ToArray();
   XmlUtils.ObjectToFile(basicPath + "\\map.xml", res);
 }
Exemple #8
0
 private void SetSessionQuestions() => pool = questionBank.GetQuestionPoolFromLocal(p);