public IQuestion GetRandomAvailableQuestion(ITask task) { IQuestion result = null; TaskQuestions tq = GetTaskQuestions(task); int count = tq.AvailableQuestions.Count; if (tq != null && count != 0) { result = tq.AvailableQuestions[Random.Range(0, count)]; } return(result); }
public void MarkQuestionAsUsed(IQuestion question, ITask task) { TaskQuestions tq = GetTaskQuestions(task); if (tq == null) { return; } tq.AvailableQuestions.Remove(question); tq.UsedQuestions.Remove(question); tq.UsedQuestions.Add(question); }
public void InitTaskQuestions(ITask task, List <IQuestion> questions) { TaskQuestions tq = GetTaskQuestions(task); if (tq == null) { tq = new TaskQuestions(); tq.Task = task; _tasksQuestions.Add(tq); } tq.UsedQuestions = new List <IQuestion>(); tq.AvailableQuestions = questions; }
public TaskQuestions GetTaskQuestions(int id) { TaskQuestions target = null; foreach (TaskQuestions tq in _tasksQuestions) { if (tq.Task.Data.Id == id) { target = tq; break; } } return(target); }
private void ResetReusableQuestions(TaskQuestions tq) { List <int> indices = new List <int>(); for (int i = 0; i < tq.UsedQuestions.Count; i++) { if (tq.UsedQuestions[i].Reusable) { indices.Add(i); } } foreach (int index in indices.OrderByDescending(x => x)) { tq.AvailableQuestions.Add(tq.UsedQuestions[index]); tq.UsedQuestions.RemoveAt(index); } }
public void ResetReusableQuestions(int id) { TaskQuestions tq = GetTaskQuestions(id); ResetReusableQuestions(tq); }
public void ResetReusableQuestions(ITask task) { TaskQuestions tq = GetTaskQuestions(task); ResetReusableQuestions(tq); }
public bool TaskQuestionsInitialized(int id) { TaskQuestions tq = GetTaskQuestions(id); return(tq != null); }
public bool TaskQuestionsInitialized(ITask task) { TaskQuestions tq = GetTaskQuestions(task); return(tq != null); }
public bool TaskHasQuestions(ITask task) { TaskQuestions tq = GetTaskQuestions(task); return(tq == null ? false : tq.QuestionsCount != 0); }