public List <Answer> Resolve(DatabaseQuestion source, Question destination, List <Answer> member, ResolutionContext context)
        {
            var mapper = context.Mapper;

            var user = _context.GetCurrentUser();

            if (user.IsAdmin() || user.IsLecturer())
            {
                return(mapper.Map <List <Answer> >(source.Answers));
            }

            if (user.IsNotStudent())
            {
                return(null);
            }

            // Ответы на этот тип вопроса представляют собой строки.
            // Все эти строки являются правильным вариантом ответа (просто в разных вариациях).
            if (source.Type == QuestionType.OpenedOneString)
            {
                return(null);
            }

            return(mapper
                   .Map <List <Answer> >(source.Answers)
                   .Execute(x => x.IsRight = null));
        }
Example #2
0
 public Question(DatabaseQuestion dbQuestion)
 {
     this.Text    = dbQuestion.Text;
     this.Answer1 = dbQuestion.Answer1;
     this.Answer2 = dbQuestion.Answer2;
     this.Answer3 = dbQuestion.Answer3;
     this.Answer4 = dbQuestion.Answer4;
 }
Example #3
0
        //Sends a question to the other playerentity in the level and sets the data for updating the board.
        public override void SendQuestionToPlayerEntity(DatabaseQuestion question)
        {
            //Make sure that when the player has taken an action he can't do anymore actions.
            _GuessButton.interactable    = false;
            _QuestionButton.interactable = false;

            _QuestionTextComp.text = question.QuestionText;
            _LastQuestion          = question;
            _QuestionAnswer        = FindObjectOfType <AIManager>().AnswerQuestion(question);
            _LevelManager.NotifyQuestionSend(_PlayerID - 1);
        }
        public static DatabaseQuestion CreateDatabaseQuestion(int studentId = 3, int lecturerId = 2, bool withTheme = true)
        {
            var question = new DatabaseQuestion {
                Type = QuestionType.ClosedManyAnswers
            };

            if (withTheme)
            {
                question.Theme = CreateDatabaseTheme(studentId, lecturerId);
            }

            return(question);
        }
Example #5
0
        public async Task <string> ComputeForQuestionAsync(DatabaseQuestion question)
        {
            var user = await _context.GetCurrentUserAsync();

            var @object = new
            {
                question.Id,
                question.ThemeId,
                question.Theme.DisciplineId,
                question.Type,
                question.Text,

                UserId = user.Id
            };

            return(Compute(@object));
        }
        private static DatabaseQuestion CreateDatabaseQuestion(int id, QuestionType type)
        {
            var question = new DatabaseQuestion
            {
                Id    = id,
                Type  = type,
                Theme = new DatabaseTheme {
                    Discipline = ModelsCreationHelper.CreateDatabaseDiscipline(),
                    ThemeTests = ModelsCreationHelper.CreateDatabaseTestThemes()
                }
            };

            question.Theme.ThemeTests.ForEach(x => x.Test = new DatabaseTest {
                IsActive = true
            });

            return(question);
        }
Example #7
0
    /**
     * this method handles adding a new question created by user to the database
     * @param questionObj - a DatabaseQuestion object containing question created by user
     */
    private IEnumerator AddNewQuestionToFirebase(DatabaseQuestion questionObj)
    {
        string json   = JsonConvert.SerializeObject(questionObj);
        var    DBTask = DBreference.Child("questions").Child(level).Child(childCount.ToString()).SetRawJsonValueAsync(json);

        //var DBTask = DBreference.Child("questions").Child(level).Child("4").SetRawJsonValueAsync(json);
        yield return(new WaitUntil(predicate: () => DBTask.IsCompleted));

        if (DBTask.Exception != null)
        {
            Debug.LogWarning(message: $"Failed to register task with {DBTask.Exception}");
        }
        else
        {
            Debug.Log("successful update to DB");
            UIManager.GetComponent <CustomStageUIManager>().clickOKInAddYourOwnQuestionsUI();
        }
    }
Example #8
0
        //Gets called when there is a question to this player entity.
        public bool AnswerQuestion(DatabaseQuestion question)
        {
            //Loop through the paintingID properties, when the program finds the property the question is about the program finds if it has it or not and returns that value.
            int paintingPropertiesLength = _PaintingID._Characteristics.Length;

            for (int i = 0; i < paintingPropertiesLength; i++)
            {
                if (_PaintingID._Characteristics[i]._PaintingProperty == question.QuestionIsAbout)
                {
                    if (_PaintingID._Characteristics[i]._DoesContain)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #9
0
 //Sends a question to the other playerentity in the level.
 public override void SendQuestionToPlayerEntity(DatabaseQuestion question)
 {
     _QuestionAnswer = FindObjectOfType <PlayerManager>().AnswerQuestion(question);
     FindObjectOfType <LevelManager>().NotifyQuestionSend(_PlayerID - 1);
     _LastQuestion = question;
 }
Example #10
0
    /**
     * this method handles forming the Database Question Object and calling AddNewQuestionToFirebase method
     */
    public void updateToDB()
    {
        DatabaseQuestion question = new DatabaseQuestion(questionTitle.text, A.text, B.text, C.text, correctAns, D.text);

        StartCoroutine(AddNewQuestionToFirebase(question));
    }
Example #11
0
 //Abstract functions.
 public abstract void SendQuestionToPlayerEntity(DatabaseQuestion question);