コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public TaskQuestions GetTaskQuestions(int id)
        {
            TaskQuestions target = null;

            foreach (TaskQuestions tq in _tasksQuestions)
            {
                if (tq.Task.Data.Id == id)
                {
                    target = tq;
                    break;
                }
            }
            return(target);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public void ResetReusableQuestions(int id)
        {
            TaskQuestions tq = GetTaskQuestions(id);

            ResetReusableQuestions(tq);
        }
コード例 #7
0
        public void ResetReusableQuestions(ITask task)
        {
            TaskQuestions tq = GetTaskQuestions(task);

            ResetReusableQuestions(tq);
        }
コード例 #8
0
        public bool TaskQuestionsInitialized(int id)
        {
            TaskQuestions tq = GetTaskQuestions(id);

            return(tq != null);
        }
コード例 #9
0
        public bool TaskQuestionsInitialized(ITask task)
        {
            TaskQuestions tq = GetTaskQuestions(task);

            return(tq != null);
        }
コード例 #10
0
        public bool TaskHasQuestions(ITask task)
        {
            TaskQuestions tq = GetTaskQuestions(task);

            return(tq == null ? false : tq.QuestionsCount != 0);
        }