private void SetQuizIndex(Direction direction) { //if the next quistion direction then increment the counter if (direction == Direction.Next) { _currentQuizIndex++; } //but if the direction is previous then decrement the counter else if (direction == Direction.Previous) { _currentQuizIndex--; } //this will make sure that the currentQuizIndex wont be negative values if (_currentQuizIndex < 0) { _currentQuizIndex = 0; } //this will make sure that the index wont be more than the total number of question var questionCount = Questions.Count(); if (_currentQuizIndex >= questionCount) { _currentQuizIndex = questionCount - 1; } }
public bool IsValidListOfQuestions() { if (Questions.Count() != 0) { return(true); } return(false); }
public bool HasQuestions() { if (Questions != null && Questions.Count() > 0) { return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="Exam"/> class from the results of a Entity Framework query. /// </summary> /// <param name="exam">The results of the query.</param> public Exam(IEnumerable <Question> exam) { Questions = exam.ToList(); GradePoint = 100; for (int i = 0; i < Questions.Count(); i++) //set correctID to null to prevent radiobuttonfor from selecting a default answer { Questions[i].CorrectId = null; } }
public LinkedQuestion QuestionAt(string refVarName) { for (int i = 0; i < Questions.Count(); i++) { if (Questions[i].VarName.RefVarName.ToLower().Equals(refVarName.ToLower())) { return(Questions[i]); } } return(null); }
public int QuestionIndex(string refVarName) { for (int i = 0; i < Questions.Count(); i++) { if (Questions[i].VarName.RefVarName.Equals(refVarName)) { return(i); } } return(-1); }
public async Task <IActionResult> OnPostExportAsync(int currentPage, int pageSize, string categoryName, string sortOrder) { Questions = await InitiateView(currentPage, pageSize, categoryName, sortOrder); string sWebRootFolder = _hostingEnvironment.WebRootPath; string sFileName = @"Category Data.xlsx"; string URL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName); FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); var memory = new MemoryStream(); using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write)) { ExcelPackage package = new ExcelPackage(); package.Workbook.Worksheets.Add("Categories"); ExcelWorksheet questionsSheet = package.Workbook.Worksheets["Categories"]; using (var range = questionsSheet.Cells["A1:D1"]) { range.Style.Font.Bold = true; range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23, 121, 186)); range.Style.Font.Color.SetColor(Color.White); } questionsSheet.Cells[1, 1].Value = "Question Id"; questionsSheet.Cells[1, 2].Value = "Question Name"; questionsSheet.Cells[1, 3].Value = "Question Description"; questionsSheet.Cells[1, 4].Value = "Form Name"; questionsSheet.Cells[1, 1, 1, 4].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thick); for (int r = 0; r < Questions.Count(); r++) { Question questionC = _context.Questions.FirstOrDefault(c => c.Question_ID == Questions.ToList()[r].Question_ID); questionsSheet.Cells[r + 2, 1].Value = Questions.ToList()[r].Question_ID; questionsSheet.Cells[r + 2, 2].Value = Questions.ToList()[r].QuestionName; questionsSheet.Cells[r + 2, 3].Value = Questions.ToList()[r].Description; questionsSheet.Cells[r + 2, 4].Value = Forms.FirstOrDefault(f => f.Form_ID == Questions.ToList()[r].Form_ID).FormName; questionsSheet.Cells[1, 1, 1, 4].AutoFitColumns(); } package.SaveAs(fs); package.Dispose(); } using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; TempData["StatusMessage"] = "Forms successfully exported to file " + sFileName; return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName)); }
private async void _SubmitDelete_Exec(object parameter) { string respond = parameter as string; if (respond == "OK") { if (PatternVisibility == Visibility.Visible && TestVisibility == Visibility.Collapsed) { var result = (CRUDResult)await MainView.Client.AdminManager. DeleteAsync(SelectedPattern.Id); if (!result.IsSuccess) { MessageBox.Show(result.Message); return; } MainView.Patterns = new ObservableCollection <PatternView> (await MainView.Client.PatternManager.GetAllAsync()); Patterns = MainView.Patterns; SelectedPattern = null; } else { Questions.Remove(SelectedQuestion); if (Questions.Count() == 0) { TestContentVisibility = Visibility.Collapsed; } else { SelectedQuestion = Questions.FirstOrDefault(); } } } ((App)Application.Current).CloseDialog(); }
public override void AnswerQuestion(IQuestion question, IAnswer answer) { if (question.State == QuestionState.Unanswered) { var hitScore = HitScore; question.Answer = answer; CorrectAnswers = Questions.Count(o => o.State == QuestionState.Correct); IncorrectAnswers = Questions.Count(o => o.State == QuestionState.Incorrect); question.AnswerOrder = CorrectAnswers + IncorrectAnswers; if (question.State == QuestionState.Correct) { TotalScore += hitScore; } Completed = Questions.All(o => o.State != QuestionState.Unanswered); } }
public async Task OnGetAsync(int id) { RoomID = id; Questions = await _context.Question.Where(r => r.Room.ID == id).ToListAsync(); Votes = await _context.Vote.Where(r => r.Question.Room.ID == id).ToListAsync(); Scores = new int[Questions.Count()]; int count = 0; foreach (Question q in Questions) { foreach (Vote v in Votes) { if (v.Question.ID == q.ID) { Scores[count] += v.score; } } count++; } }
public async Task <IActionResult> OnGet(int?simID) { if (simID == null) { return(NotFound()); } Questions = await Context.Questions .Include(q => q.Simulation) .Include(q => q.QuestionType) .Include(q => q.StudentQuestions) .Where(q => q.SimulationID == simID) .ToListAsync(); if (Questions == null || Questions.Count() == 0) { return(NotFound()); } StudentAnswers = new string[Questions.Count()]; return(Page()); }
public TestInfo GetInfo(int?userId = null) { TestInfo info = new TestInfo() { RatingSystem = new KeyValuePair <int, string>(RatingSystem.Id, RatingSystem.Name), Category = new KeyValuePair <int, string>(Category.Id, Category.Name), AddDate = AddDate, Attempts = Attempts, Description = Description, Duration = Duration, Interval = Interval, Id = Id, IsPrivate = IsPrivate, IsQuestionsMix = IsQuestionsMix, Title = Title, User = User.GetEncryptedInfo(), UsedAttempts = 0, Mark = string.Empty, QuestionsCount = 0 }; info.QuestionsCount = Questions.Count(); if (userId.HasValue && TestResults != null) { TestResult testResult = TestResults.FirstOrDefault(tr => tr.UserId == userId.Value); if (testResult != null) { info.UsedAttempts = testResult.Attempts; info.Mark = RatingSystem.GetMark(testResult.Score, Questions.Sum(q => q.Weight)); } } return(info); }
public int CalcNumberQuestionsAsked() { return(Questions.Count()); }
public override void Calculate() { var qCount = Questions.Count(); var eCount = Experts.Count(); var qDict = Questions.ToDictionary(x => x, x => 0d); int index = 0; var qIndexDict = Questions.ToDictionary(x => x, x => index++); index = 0; var eIndexDict = Experts.ToDictionary(x => x, x => index++); var matrix = new double[eCount, qCount]; var coeffitient = (double)qCount / MaxNormalizedAnswer; //Нормализую ответы, относительно максимума, чтобы результат был меньше кол-ва вопросов foreach (var answer in ExpertAnswer) { var qIndex = qIndexDict[answer.Question]; var eIndex = eIndexDict[answer.Expert]; matrix[eIndex, qIndex] = answer.NormalizedAnswer * coeffitient; } //Нормализую ответы, убирая одинаковые ответы, не соотносящиеся с рангами Normalize(matrix); _normalizedMartix = matrix; //Сумма ответов по вопросам var totalSum = 0d; //Среднее значение ответов от сумм ответов по вопросам var middleSum = 0d; //Суммы ответов по вопросам var qSumm = new double[qCount]; QSumms = qSumm; //Отклонение от средней суммы ответов по вопросам var qDSumm = new double[qCount]; QDSumms = qDSumm; //Квадраты ответов по вопросам var qDoubleSumm = new double[qCount]; QDoubleSumms = qDoubleSumm; for (int q = 0; q < qCount; q++) { var qSum = 0d; for (int e = 0; e < eCount; e++) { qSum += matrix[e, q]; } totalSum += qSum; qSumm[q] = qSum; } middleSum = qSumm.Sum() / qSumm.Length; for (int q = 0; q < qDSumm.Length; q++) { qDSumm[q] = qSumm[q] - middleSum; } for (int q = 0; q < qDoubleSumm.Length; q++) { qDoubleSumm[q] = qDSumm[q] * qDSumm[q]; } S = qDoubleSumm.Sum(); const string sName = "S"; const string expName = "exp"; const string queName = "que"; CoefficientOfConcordance = GetFormula($"(12*{sName})/(({expName}*{expName})*({queName}*{queName}*{queName}-{queName}))"); CoefficientOfConcordance.TrySetValue(sName, (decimal)S); CoefficientOfConcordance.TrySetValue(expName, eCount); CoefficientOfConcordance.TrySetValue(queName, qCount); }
/// <summary>Возвращает количество ответов "Не знаю"</summary> /// <returns>Количество ответов "Не знаю"</returns> public int GetDontKnowCount() { return(Questions.Count(question => question.Answer == AnswerType.MbDontKnow)); }
public int QuestionCount() { return(Questions.Count()); }