Пример #1
0
    void Awake()
    {
        // Set this before calling into the realtime database.
        /*FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://ssadpancake.firebaseio.com/");*/

        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://ssad-c9270.firebaseio.com/");
        // Get the root reference location of the database.
        mDatabaseRef = FirebaseDatabase.DefaultInstance.RootReference;



        ////////////////////////////This function will create a new question in the database//////////////////////////////////////
        ///Specify which world, chap and difficulty level of the question into the function
        GetQuestion sample = new GetQuestion();

        sample.question.question   = "22+20=?";
        sample.question.ans1       = "39";
        sample.question.ans2       = "40";
        sample.question.ans3       = "41";
        sample.question.ans4       = "42";
        sample.question.correctAns = "42";
        sample.UniqueKey           = "1114554";

        AddNewQuestion("world1", "Chap1", "easy", sample.question);
    }
 private void JokerOne_OnClick(object sender, RoutedEventArgs e)
 {
     if (Is50JokerUsed == false)
     {
         if (counterRounds < 5)
         {
             var currentQuestion = GetQuestion.GetEasyQuestion(counterRounds);
             currentQuestion.WrongAnswers[0] = "";
             currentQuestion.WrongAnswers[1] = "";
             Is50JokerUsed = true;
             CallEasyQuestions(currentQuestion);
         }
         else if (counterRounds >= 5 && counterRounds < 10)
         {
             var currentQuestion = GetQuestion.GetMediumQuestion(counterRounds - 5);
             currentQuestion.WrongAnswers[0] = "";
             currentQuestion.WrongAnswers[1] = "";
             Is50JokerUsed = true;
             CallMediumQuestions(currentQuestion);
         }
         else
         {
             var currentQuestion = GetQuestion.GetHardQuestion(counterRounds - 10);
             currentQuestion.WrongAnswers[0] = "";
             currentQuestion.WrongAnswers[1] = "";
             Is50JokerUsed = true;
             CallHardQuestions(currentQuestion);
         }
     }
     else
     {
         MessageBox.Show($"This Joker has been already used!");
     }
 }
        public MainWindow()
        {
            var currentQuestion = GetQuestion.GetEasyQuestion(counterRounds);

            InitializeComponent();
            CallEasyQuestions(currentQuestion);
        }
Пример #4
0
        public async Task <IActionResult> PutGetQuestion([FromRoute] long id, [FromBody] GetQuestion getQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != getQuestion.QuestionId)
            {
                return(BadRequest());
            }

            _context.Entry(getQuestion).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GetQuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #5
0
    public void getQuestion(string world, string chap, string difficulty, System.Action <GetQuestion[]> callback)
    {
        FirebaseDatabase.DefaultInstance
        .GetReference("question").Child(world).Child(chap).Child(difficulty)
        .GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.Log("Failed to connect");
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                //Debug.Log("Code Runs");

                DataSnapshot snapshot = task.Result;


                int index = 0;
                GetQuestion[] questionList = new GetQuestion[100];
                foreach (DataSnapshot s in snapshot.Children)
                {
                    questionList[index]            = new GetQuestion();
                    questionList[index].UniqueKey  = s.Key;
                    questionList[index++].question = JsonUtility.FromJson <UploadQuestion>(s.GetRawJsonValue());
                }

                callback(questionList);
                //Debug.Log("Code End");
            }
        });
    }
Пример #6
0
        public async Task <Question> Execute(PangulDbContext db, GetQuestion query)
        {
            query.Validate();

            var qStatement = db.Question
                             .Where(q => q.QuestionId == query.Derived.QuestionId);

            if (!query.IgnoreRowVersion)
            {
                qStatement = qStatement.Where(q => q.RowVersion == query.Derived.RowVersion);
            }

            if (query.LightWeightOnly)
            {
                return(await qStatement.FirstOrDefaultAsync());
            }

            var question = await qStatement
                           .Include(i => i.Tags)
                           .Include(i => i.Meta)
                           .Include(i => i.Topic)
                           .FirstOrDefaultAsync();

            if (question != null)
            {
                question.CanEdit = await _internalUserPermissionService.HasWriteAccessFor(question, query.UserContext);
            }

            return(question);
        }
        private async Task AddQuestion(string question, IList <string> answers)
        {
            var createQuestion = new CreateQuestion(question, answers);

            QuestionViewModel questionViewModel;

            try
            {
                var questionId = await _mediator.Send(createQuestion)
                                 .OnError(error => throw new InvalidOperationException(error.ToString()));

                var getQuestion = new GetQuestion(questionId);
                questionViewModel = await _mediator.Send(getQuestion)
                                    .OnError(error => throw new InvalidOperationException(error.ToString()));
            }
            catch (Exception exception)
            {
                exception.WriteToConsole();
                return;
            }

            Console.WriteLine();
            Console.WriteLine(questionViewModel);
            Console.WriteLine();
        }
Пример #8
0
        public IActionResult getQuestionPart([FromBody] GetQuestion user)
        {
            if (user != null)
            {
                try
                {
                    var qr = db.Questions.FromSqlRaw("select q.isActive,q.id,q.id_part,q.title_question,q.id_lession,q.question,q.dapanA,q.dapanB,q.dapanC,q.dapanD,q.answer,q.image,q.sound,q.description " +
                                                     "from `question` as q,`lession` as l,`category` as c, `part` as p, (SELECT q.sound as ss " +
                                                     "from `question` q where q.id_part = " +
                                                     user.Id_part +
                                                     " GROUP BY q.sound) as q2 " +
                                                     "WHERE c.id = l.id_category and l.id = q.id_lession and c.id = " +
                                                     user.Id +
                                                     " and p.id=q.id_part and l.id=" +
                                                     user.Id_lession +
                                                     " and q.sound=q2.ss").ToList();

                    return(Ok(qr));
                }
                catch (global::System.Exception)
                {
                    return(Ok("lỗi"));
                }
            }
            return(Ok("lỗi"));
        }
Пример #9
0
        public async Task Should_Return_Error_On_Twice_Vote_On_Same_Question()
        {
            await LogInAsAdministrator();

            var createQuestion = new CreateQuestion(
                questionText: "Some question?",
                answers: new[] { "First answer", "Second answer" });
            var createQuestionResponse = await Mediator.Send(createQuestion);

            var createdQuestionId = AssertNotError.Of(createQuestionResponse);

            var getQuestion      = new GetQuestion(createdQuestionId);
            var questionResponse = await Mediator.Send(getQuestion);

            var createdQuestion = AssertNotError.Of(questionResponse);

            await LogInAsVoter();

            var voteFor = new VoteFor(
                questionId: createdQuestion.Id,
                answerId: createdQuestion.Answers[1].Id);
            var voteForResponse = await Mediator.Send(voteFor);

            var voteForDuplicate = new VoteFor(
                questionId: createdQuestion.Id,
                answerId: createdQuestion.Answers[0].Id);
            var voteForResponseDuplicate = await Mediator.Send(voteForDuplicate);

            AssertError <DomainError> .Of(voteForResponseDuplicate);
        }
Пример #10
0
        public async Task Check_If_Votes_Incremented()
        {
            await LogInAsAdministrator();

            var createQuestion = new CreateQuestion(
                questionText: "Some question?",
                answers: new[] { "First answer", "Second answer" });
            var createQuestionResponse = await Mediator.Send(createQuestion);

            var createdQuestionId = AssertNotError.Of(createQuestionResponse);

            var getQuestion      = new GetQuestion(createdQuestionId);
            var questionResponse = await Mediator.Send(getQuestion);

            var createdQuestion = AssertNotError.Of(questionResponse);

            await LogInAsVoter();

            var voteFor = new VoteFor(
                questionId: createdQuestion.Id,
                answerId: createdQuestion.Answers[1].Id);
            var voteForResponse = await Mediator.Send(voteFor);

            var getQuestionResult      = new GetQuestionResult(createdQuestion.Id);
            var questionResultResponse = await Mediator.Send(getQuestionResult);

            AssertNotError.Of(voteForResponse);
            var questionResult = AssertNotError.Of(questionResultResponse);

            Assert.Multiple(() =>
            {
                Assert.That(questionResult.Answers[0].Votes, Is.EqualTo(0));
                Assert.That(questionResult.Answers[1].Votes, Is.EqualTo(1));
            });
        }
Пример #11
0
        public async Task Should_Return_Error_When_Not_Logged()
        {
            await LogInAsAdministrator();

            var createQuestion = new CreateQuestion(
                questionText: "Some question?",
                answers: new[] { "First answer", "Second answer" });
            var createQuestionResponse = await Mediator.Send(createQuestion);

            var createdQuestionId = AssertNotError.Of(createQuestionResponse);

            var getQuestion      = new GetQuestion(createdQuestionId);
            var questionResponse = await Mediator.Send(getQuestion);

            var createdQuestion = AssertNotError.Of(questionResponse);

            LogOut();

            var voteFor = new VoteFor(
                questionId: createdQuestion.Id,
                answerId: createdQuestion.Answers[1].Id);
            var voteForResponse = await Mediator.Send(voteFor);

            AssertError <AuthorizationError> .Of(voteForResponse);
        }
Пример #12
0
    void Start()
    {
        crudQuestion = GetComponent <DummyCRUDQuestion>();

        world                        = "world1";
        chap                         = "chap1";
        difficulty                   = "easy";
        oldDifficulty                = "easy";
        newDifficulty                = "hard";
        gameID                       = "1234";
        question                     = new GetQuestion();
        question.UniqueKey           = "123";
        question.question.question   = "1+1=?";
        question.question.ans1       = "1";
        question.question.ans2       = "2";
        question.question.ans3       = "3";
        question.question.ans4       = "4";
        question.question.correctAns = "2";
        userid                       = "user123";
        questions                    = new GetQuestion[1];
        questions[0]                 = question;
        AddNewQuestion(world, chap, difficulty, question.question);
        UpdateQuestion(world, chap, difficulty, question);
        UpdateQuestionDifficulty(world, chap, oldDifficulty, newDifficulty, question);
        getQuestion(world, chap, difficulty);
        studentAddNewQuestions(userid, questions, 2);
        getStudentGameIDList();
        getStudentGameQuestion(gameID);
    }
Пример #13
0
    public void CreateGame()
    {
        if (selectedQuestions.Count < 10)
        {
            errorList.text    = "Please select at least 10 questions";
            errorList.enabled = true;
        }
        else
        {
            GetQuestion[] allQuestions = new GetQuestion[selectedQuestions.Count];
            int           i            = 0;
            bool          found;
            foreach (var item in selectedQuestions)
            {
                found = false;
                foreach (var world in fullArray)
                {
                    if (found)
                    {
                        break;
                    }
                    foreach (var chapter in world)
                    {
                        if (found)
                        {
                            break;
                        }
                        foreach (var diff in chapter)
                        {
                            if (found)
                            {
                                break;
                            }
                            foreach (var record in diff)
                            {
                                if (record != null && record.question.question == item)
                                {
                                    found           = true;
                                    allQuestions[i] = record;
                                    i++;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            view.enabled          = false;
            successCanvas.enabled = true;
            shareButton.SetActive(true);

            /*errorList.text = "testing 1 2 3";
             * errorList.enabled = true;*/
            string returnValue = crudqn.studentAddNewQuestions(StaticVariable.UserID /*"userid1159"*/, allQuestions, selectedQuestions.Count);


            success.text = "Game ID: '" + returnValue + "'.";
        }
    }
Пример #14
0
    public void UpdateQuestion(string world, string chap, string difficulty, GetQuestion question)
    {
        Debug.Log("Update question from database");
        Debug.Log("Call Question manager to update data");
        crudQuestion.UpdateQuestion(world, chap, difficulty, question);

        Debug.Log("Data Updated");
    }
Пример #15
0
    public void getQuestion()
    {
        GetQuestion getQuestion = new GetQuestion();

        getQuestion.action = "getQuestion";
        getQuestion.token  = token;
        SendWebSocketMessage(JsonUtility.ToJson(getQuestion));
    }
Пример #16
0
 public bool UpdateQuestion(string world, string chap, string difficulty, GetQuestion question)
 {
     if (world != null && chap != null && difficulty != null && question != null)
     {
         return(true);
     }
     return(false);
 }
Пример #17
0
        public async Task <IActionResult> Create([FromBody] CreateQuestion request)
        {
            var questionId = await _mediator.Send(request);

            var getQuestion = new GetQuestion(questionId);
            var response    = await _mediator.Send(getQuestion);

            return(HandleErrors(response, Ok));
        }
Пример #18
0
        public async Task Check_If_Votes_Exists_In_My_Votes_After_Voting_2_Of_3_Questions()
        {
            await LogInAsAdministrator();

            var createFirstQuestion = new CreateQuestion(
                questionText: "Some question?",
                answers: new[] { "First answer", "Second answer" });
            var createFirstQuestionResponse = await Mediator.Send(createFirstQuestion);

            var firstQuestionId = AssertNotError.Of(createFirstQuestionResponse);

            var getFirstQuestion      = new GetQuestion(firstQuestionId);
            var firstQuestionResponse = await Mediator.Send(getFirstQuestion);

            var firstQuestion = AssertNotError.Of(firstQuestionResponse);

            var createSecondQuestion = new CreateQuestion(
                questionText: "Another question?",
                answers: new[] { "Any answer", "Some answer" });
            var createSecondQuestionResponse = await Mediator.Send(createSecondQuestion);

            _ = AssertNotError.Of(createSecondQuestionResponse); // I will not vote on this question

            var createThirdQuestion = new CreateQuestion(
                questionText: "Third question?",
                answers: new[] { "Any answer", "Some answer", "I don't know answer" });
            var createThirdQuestionResponse = await Mediator.Send(createThirdQuestion);

            var thirdQuestionId = AssertNotError.Of(createThirdQuestionResponse);

            var getThirdQuestion      = new GetQuestion(thirdQuestionId);
            var thirdQuestionResponse = await Mediator.Send(getThirdQuestion);

            var thirdQuestion = AssertNotError.Of(thirdQuestionResponse);

            await LogInAsVoter();

            var voteForFirst = new VoteFor(
                questionId: firstQuestion.Id,
                answerId: firstQuestion.Answers[0].Id);
            await Mediator.Send(voteForFirst);

            var voteForThird = new VoteFor(
                questionId: thirdQuestion.Id,
                answerId: thirdQuestion.Answers[2].Id);
            await Mediator.Send(voteForThird);

            var getMyVotes         = new GetMyVotes();
            var getMyVotesResponse = await Mediator.Send(getMyVotes);

            var myVotes = AssertNotError.Of(getMyVotesResponse);

            CollectionAssert.AreEquivalent(
                new[] { firstQuestion.Id, thirdQuestion.Id },
                myVotes.QuestionsId);
        }
Пример #19
0
    public void UpdateQuestion(string world, string chap, string difficulty, GetQuestion question)
    {
        Debug.Log("Update question from database");
        Debug.Log("Call Question manager to update data");
        bool result = crudQuestion.UpdateQuestion(world, chap, difficulty, question);

        if (result != false)
        {
            Debug.Log("Question Updated");
        }
    }
Пример #20
0
        public async Task <IActionResult> PostGetQuestion([FromBody] GetQuestion getQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Questions.Add(getQuestion);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGetQuestion", new { id = getQuestion.QuestionId }, getQuestion));
        }
Пример #21
0
    public void getStudentGameQuestion(string gameID, System.Action <GetQuestion[], string> callback)
    {
        FirebaseDatabase.DefaultInstance
        .GetReference("studentGame")
        .GetValueAsync().ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                //Debug.Log("Failed to connect");
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                //Debug.Log("Code Runs");
                DataSnapshot snapshot = task.Result;


                int index = 0;
                GetQuestion[] questionList = new GetQuestion[10];
                string GameOwneruserid     = null;
                foreach (DataSnapshot s in snapshot.Children)
                {
                    foreach (DataSnapshot ss in s.Children)
                    {
                        if (gameID == ss.Key)
                        {
                            GameOwneruserid = s.Key;
                            foreach (DataSnapshot sss in ss.Child("question").Children)
                            {
                                if (index > 9)
                                {
                                    break;
                                }
                                questionList[index]            = new GetQuestion();
                                questionList[index].UniqueKey  = sss.Key;
                                questionList[index++].question = JsonUtility.FromJson <UploadQuestion>(sss.GetRawJsonValue());
                                //Debug.Log("Question: " + questionList[index - 1].question.question);
                            }
                            break;
                        }
                    }
                }


                callback(questionList, GameOwneruserid);

                //Debug.Log("Code End");
            }
        });
    }
        private void CheckForAnswer(Button Answer)
        {
            bool check;

            if (counterRounds < 5)
            {
                check = Answer.Content == GetQuestion.GetEasyQuestion(counterRounds).Answer;
            }
            else if (counterRounds >= 5 && counterRounds < 10)
            {
                check = Answer.Content == GetQuestion.GetMediumQuestion(counterRounds - 5).Answer;
            }
            else
            {
                check = Answer.Content == GetQuestion.GetHardQuestion(counterRounds - 10).Answer;
            }
            if (check)
            {
                counterRounds++;
                if (counterRounds >= 5 && counterRounds < 10)
                {
                    var currentQuestion = GetQuestion.GetMediumQuestion(counterRounds - 5);
                    CallMediumQuestions(currentQuestion);
                }
                else if (counterRounds < 5)
                {
                    var currentQuestion = GetQuestion.GetEasyQuestion(counterRounds);
                    CallEasyQuestions(currentQuestion);
                }
                else if (counterRounds >= 10 && counterRounds < 15)
                {
                    var currentQuestion = GetQuestion.GetHardQuestion(counterRounds - 10);
                    CallHardQuestions(currentQuestion);
                }
                else
                {
                    MessageBox.Show("You won all the money there is, please spare us, Master!");
                }
            }
            else
            {
                Is50JokerUsed       = false;
                IsFriendJokerUsed   = false;
                IsAudienceJokerUsed = false;
                MessageBox.Show("Wrong аnswer!");
                counterRounds = 0;
                var currentQuestion = GetQuestion.GetEasyQuestion(counterRounds);
                CallEasyQuestions(currentQuestion);
            }
        }
Пример #23
0
 public IActionResult getLogByDay([FromBody] GetQuestion question)
 {
     if (question != null)
     {
         try
         {
             var qr = db.Logs.FromSqlRaw("select * from log where current_day = '" + question.Day + "'").ToList();
             return(Ok(qr));
         }
         catch (Exception e)
         {
             return(BadRequest(new { message = " incorrect " + e.Message }));
         }
     }
     return(BadRequest(new { message = "null" }));
 }
Пример #24
0
    public void RandomlyGenerateStudentQuestion()
    {
        GetQuestion[] test = new GetQuestion[10];

        for (int i = 0; i < 10; i++)
        {
            test[i] = new GetQuestion();
            test[i].question.question   = "22+" + 20 + i + "+=?";
            test[i].question.ans1       = (39 + i).ToString();
            test[i].question.ans2       = (40 + i).ToString();
            test[i].question.ans3       = (41 + i).ToString();
            test[i].question.ans4       = (42 + i).ToString();
            test[i].question.correctAns = (42 + i).ToString();
            test[i].UniqueKey           = Random.Range(0, 10000).ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString();
        }

        studentAddNewQuestions("student3", test, 10);
    }
Пример #25
0
        public async Task <IActionResult> GetQuestion([FromBody] GetQuestion getQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }

            Logger.LogInformation($"{nameof(QuestionsController)}.{nameof(GetQuestion)}.Start");

            var question = await MainDb.Questions.FindQuestion(getQuestion.UserId, getQuestion.QuestionId);

            GetTagsAndPhotos(getQuestion.UserId, getQuestion.QuestionId, out var tags, out var firstPhotos,
                             out var secondPhotos, out var comments);

            var result = question.MapToGetQuestionsViewModel(MediaConverter, tags, firstPhotos, secondPhotos, comments,
                                                             getQuestion.BackgroundSizeType);
            await Hub.Monitoring.UpdateUrlMonitoring(getQuestion.UserId, UrlMonitoringType.OpensQuestionPage);

            Logger.LogInformation($"{nameof(QuestionsController)}.{nameof(GetQuestion)}.End");

            return(new OkResponseResult(result));
        }
 private void JokerTwo_OnClick(object sender, RoutedEventArgs e)
 {
     if (IsFriendJokerUsed == false)
     {
         if (counterRounds < 5)
         {
             var currentQuestion = GetQuestion.GetEasyQuestion(counterRounds);
             MessageBox.Show($"I think the answer is {currentQuestion.Answer}");
             IsFriendJokerUsed = true;
         }
         else if (counterRounds >= 5 && counterRounds < 10)
         {
             var           currentQuestion = GetQuestion.GetMediumQuestion(counterRounds - 5);
             List <string> answers         = new List <string>();
             answers.Add(currentQuestion.Answer);
             answers.Add(currentQuestion.WrongAnswers.ElementAt(0));
             Random r     = new Random();
             int    index = r.Next(2);
             MessageBox.Show($"I think the answer is {answers.ElementAt(index)}");
             IsFriendJokerUsed = true;
         }
         else
         {
             var           currentQuestion = GetQuestion.GetHardQuestion(counterRounds - 10);
             List <string> answers         = new List <string>();
             answers.Add(currentQuestion.Answer);
             answers.Add(currentQuestion.WrongAnswers.ElementAt(0));
             Random r     = new Random();
             int    index = r.Next(2);
             MessageBox.Show($"I think the answer is {answers.ElementAt(index)}");
             IsFriendJokerUsed = true;
         }
     }
     else
     {
         MessageBox.Show($"This Joker has been already used!");
     }
 }
Пример #27
0
    //change scene
    public void changeScene(string sceneName, string world, string chap, string difficulty, GetQuestion questionObj, string id)
    {
        SceneManager.LoadScene(sceneName);


        PlayerPrefs.SetString("qn", questionObj.question.question);
        PlayerPrefs.SetString("a1", questionObj.question.ans1);
        PlayerPrefs.SetString("a2", questionObj.question.ans2);
        PlayerPrefs.SetString("a3", questionObj.question.ans3);
        PlayerPrefs.SetString("a4", questionObj.question.ans4);
        PlayerPrefs.SetString("ca", questionObj.question.correctAns);
        PlayerPrefs.SetString("difficulty", difficulty);

        StaticVariable.id       = id;
        QuestionData.difficulty = difficulty;

        Debug.Log("Difficulty: " + QuestionData.difficulty);
        Debug.Log("ID: " + StaticVariable.id);
        Debug.Log("Question: " + questionObj.question.question);
    }
Пример #28
0
    // gets current value of input fields and updates the database (either just the questions or also the difficulty)
    public void updateQuestion()
    {
        question   = GameObject.Find("InputQuestion").GetComponent <InputField>();
        a1         = GameObject.Find("InputAnswer1").GetComponent <InputField>();
        a2         = GameObject.Find("InputAnswer2").GetComponent <InputField>();
        a3         = GameObject.Find("InputAnswer3").GetComponent <InputField>();
        a4         = GameObject.Find("InputAnswer4").GetComponent <InputField>();
        correctAns = GameObject.Find("CorrectAnswer").GetComponent <InputField>();

        dropIndex      = dropdown.value;
        dropValueafter = dropdown.options[dropIndex].text;

        q = question.text;
        sharingQforProf = question.text;
        ans1            = a1.text;
        ans2            = a2.text;
        ans3            = a3.text;
        ans4            = a4.text;
        correctA        = correctAns.text;

        bool comp1 = correctA.Equals(ans1);
        bool comp2 = correctA.Equals(ans2);
        bool comp3 = correctA.Equals(ans3);
        bool comp4 = correctA.Equals(ans4);

        bool emptyInputQ  = question.Equals("");
        bool emptyInputA1 = ans1.Equals("");
        bool emptyInputA2 = ans2.Equals("");
        bool emptyInputA3 = ans3.Equals("");
        bool emptyInputA4 = ans4.Equals("");
        bool emptyInputCA = correctAns.Equals("");

        //checks if every input field has a value otherwise error message
        if (emptyInputQ | emptyInputA1 | emptyInputA2 | emptyInputA3 | emptyInputA4 | emptyInputCA)
        {
            Debug.Log("No Input given");
            setEmptyText();
        }
        else
        {
            // checks if the difficulty remained the same
            if (dropValuebefore.Equals(dropValueafter))
            {
                if (comp1 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestion(QuestionData.world, chapterString, dropValueafter, getQuestion);
                    setText();
                }
                else if (comp2 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestion(QuestionData.world, chapterString, dropValueafter, getQuestion);
                    setText();
                }
                else if (comp3 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestion(QuestionData.world, chapterString, dropValueafter, getQuestion);
                    setText();
                }
                else if (comp4 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestion(QuestionData.world, chapterString, dropValueafter, getQuestion);
                    setText();
                }
                else
                {
                    setIncorrectText();
                }
            }
            else
            {
                if (comp1 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestionDifficulty(QuestionData.world, chapterString, dropValuebefore, dropValueafter, getQuestion);
                    setText();
                }
                else if (comp2 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestionDifficulty(QuestionData.world, chapterString, dropValuebefore, dropValueafter, getQuestion);
                    setText();
                }
                else if (comp3 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestionDifficulty(QuestionData.world, chapterString, dropValuebefore, dropValueafter, getQuestion);
                    setText();
                }
                else if (comp4 == true)
                {
                    GetQuestion getQuestion = new GetQuestion();
                    getQuestion.uploadQuestion(q, ans1, ans2, ans3, ans4, correctA, StaticVariable.id);
                    crudQuestion.UpdateQuestionDifficulty(QuestionData.world, chapterString, dropValuebefore, dropValueafter, getQuestion);
                    setText();
                }
                else
                {
                    setIncorrectText();
                }
            }
        }
    }
Пример #29
0
 public void UpdateQuestionDifficulty(string world, string chap, string oldDifficulty, string newDifficulty, GetQuestion question)
 {
     mDatabaseRef.Child("question").Child(world).Child(chap).Child(oldDifficulty).Child(question.UniqueKey).SetValueAsync(null);
     AddNewQuestion(world, chap, newDifficulty, question.question);
 }
Пример #30
0
    public void UpdateQuestion(string world, string chap, string difficulty, GetQuestion question)
    {
        string json = JsonUtility.ToJson(question.question);

        mDatabaseRef.Child("question").Child(world).Child(chap).Child(difficulty).Child(question.UniqueKey).SetRawJsonValueAsync(json);
    }