Esempio n. 1
0
    internal void SetTestName(string name)
    {
        TestsList testsList = TestReader.GetTestList(name);

        ResetTest();
        EditTest(testsList);
    }
Esempio n. 2
0
 private void EditTest(TestsList testList)
 {
     m_testNameT.text        = testList.m_name;
     m_roundCount.text       = testList.m_countOfRounds.ToString();
     m_questionsInRound.text = testList.m_countQuestionsInRound.ToString();
     foreach (var question in testList.m_tests)
     {
         AddQuestion(question);
     }
 }
Esempio n. 3
0
 private void BtnRemove_Click(object sender, RoutedEventArgs e)
 {
     for (int i = TestsList.Count - 1; i >= 0; i--)
     {
         if (TestsList[i].IsSelected)
         {
             TestsList.RemoveAt(i);
         }
     }
 }
Esempio n. 4
0
    public static void SaveTestList(string fileName, TestsList list)
    {
        string fullPath = GetFullPath(fileName);

        if (!File.Exists(fullPath))
        {
            File.Create(fullPath);
        }

        File.WriteAllText(fullPath, JsonUtility.ToJson(list));
    }
Esempio n. 5
0
 private void SortByTesterId(ListSortDirection?direction)
 {
     if (direction == ListSortDirection.Descending)
     {
         TestsList = TestsList.OrderByDescending(test => test.TesterId).ToList();
     }
     else
     {
         TestsList = TestsList.OrderBy(test => test.TesterId).ToList();
     }
 }
Esempio n. 6
0
        public void MakeListFromJsonTest()
        {
            TestsList list = new TestsList("ACCOUNTID", "AUTHTOKEN", FreeClimbListTest.inputJson);

            Assert.AreEqual(list.getTotalSize, 2);
            Assert.AreEqual(list.getLocalSize, 1);
            Assert.IsNotNull(list.get(0));
            Assert.IsInstanceOfType(list.get(0), typeof(Test));
            Assert.AreEqual(list.get(0).testValue, "VALUE!!!");
            Assert.IsNotNull(list.export());
            Assert.AreEqual(list.export().Count, list.getLocalSize);
        }
Esempio n. 7
0
    // This is called from start and will run each phase of the game one after another. ONLY ON SERVER (as Start is only called on server)
    private IEnumerator GameLoop()
    {
        while (m_Players.Count < 1)//LobbyManager.s_Singleton.numPlayers)
        {
            yield return(null);
        }

        while (!AllPlayersReady())
        {
            RpcCheckReady();
            yield return(m_LoadingWait);
        }

        //Hack_SetupTestList();
        //TestReader.SaveTestList("test", m_currentTestList);
        //PlayFab.Internal.
        m_currentTestList = TestReader.GetTestList(m_testListName);
        if (m_currentTestList == null)
        {
            RpcShowMessageAll(FILE_NOT_FOUND);
            yield return(new WaitForSeconds(m_endGameWaitingTime));

            LobbyManager.s_Singleton.ServerReturnToLobby();
        }
        m_currentTestList.InitTests();

        RpcSetupGame(m_currentTestList.m_countOfRounds);

        while (m_currentTestList.IsRoundAvaliable())
        {
            // Start off by running the 'RoundStarting' coroutine but don't return until it's finished.
            yield return(StartCoroutine(RoundStarting()));

            // Once the 'RoundStarting' coroutine is finished, run the 'RoundPlaying' coroutine but don't return until it's finished.
            yield return(StartCoroutine(RoundPlaying()));

            // Once execution has returned here, run the 'RoundEnding' coroutine.
            yield return(StartCoroutine(RoundEnding()));

            m_currentTestList.SetTestsForNextRound();
        }

        m_GameWinnerId = GetGameWinnerId();
        RpcEndGame(m_GameWinnerId);
        UpdatePlayfabScore();
        yield return(new WaitForSeconds(m_endGameWaitingTime));

        ShowResultScreen();
    }
Esempio n. 8
0
    private void Hack_SetupTestList()
    {
        m_currentTestList = new TestsList();

        Variant[] vars1 =
        {
            new Variant("Hello",                    1)
            ,                    new Variant("World", 2)
            ,                    new Variant("How are", 3)
            ,                    new Variant("you?", 4)
        };

        int[] answers1 = { 1, 2, 3, 4 };

        Test test1 = new Test
        {
            m_type       = TestTypes.ARRANGE,
            m_question   = "Combine first program correctly",
            m_answerTime = 20.0f,
            m_variants   = vars1,
            m_answers    = answers1
        };

        Variant[] vars2 =
        {
            new Variant("Lol",                  1)
            ,                  new Variant("Kek", 2)
            ,                  new Variant("Chebu", 3)
            ,                  new Variant("Rek", 4)
        };

        int[] answers2 = { 1, 2, 3, 4 };

        Test test2 = new Test
        {
            m_type       = TestTypes.ARRANGE,
            m_question   = "Piu",
            m_answerTime = 20.0f,
            m_variants   = vars2,
            m_answers    = answers2
        };

        m_currentTestList.m_countOfRounds         = 2;
        m_currentTestList.m_countQuestionsInRound = 5;
        m_currentTestList.m_tests.Add(test1);
        m_currentTestList.m_tests.Add(test2);
    }
Esempio n. 9
0
    public void OnSaveTest()
    {
        TestsList testList = new TestsList();

        testList.m_name                  = m_testNameT.text;
        testList.m_countOfRounds         = int.Parse(m_roundCount.text);
        testList.m_countQuestionsInRound = int.Parse(m_questionsInRound.text);
        foreach (var question in m_questions)
        {
            Test test = new Test();
            test.m_question   = question.m_questionNameField.text;
            test.m_answerTime = float.Parse(question.m_timeField.text);
            test.m_type       = (TestTypes)question.m_testType.value;

            var answerList = question.GetAnswersList();
            test.m_variants = new Variant[answerList.Count];

            int totalCountOfRight = 0;
            for (int i = 0; i < answerList.Count; ++i)
            {
                if (answerList[i].m_isRight.isOn)
                {
                    ++totalCountOfRight;
                }
            }

            test.m_answers = new int[totalCountOfRight];
            int countOfRight = 0;
            for (int i = 0; i < answerList.Count; ++i)
            {
                Variant variant = new Variant(answerList[i].m_text.text, i);
                test.m_variants[i] = variant;
                if (answerList[i].m_isRight.isOn)
                {
                    test.m_answers[countOfRight] = i;
                    ++countOfRight;
                }
            }

            testList.m_tests.Add(test);
        }

        TestReader.SaveTestList(testList);
        OnBack();
    }
Esempio n. 10
0
 public SymptomsPageVM()
 {
     foreach (FieldInfo field in typeof(Symptoms).GetFields())
     {
         if (field.Name.Equals("SymptomsDict"))
         {
             continue;
         }
         if (field.Name.Equals("tested_positive"))
         {
             Symptom symptom = new Symptom(field.Name);
             TestsList.Add(symptom);
         }
         else
         {
             Symptom symptom = new Symptom(field.Name);
             SymptomsList.Add(symptom);
         }
     }
 }
Esempio n. 11
0
        public IActionResult CreateTest(TestsList testsList)
        {
            if (ModelState.IsValid)
            {
                Tests test = new Tests
                {
                    Date       = testsList.Date,
                    TestTypeID = testsList.TestType.TestTypeId
                };

                db.Add(test);
                db.SaveChanges();
                if (test.TestId > 0)
                {
                    return(RedirectToAction("Details", new { id = test.TestId }));
                }
            }
            ViewBag.ListOfTests = db.TestTypes.ToList();
            ModelState.AddModelError("", "some thing went wrong");
            return(View());
        }
Esempio n. 12
0
        public static void InitializeTests(NurseList nurseList, List <Days> schedDayList)
        {
            Punishment   = 0;
            hardBroken   = 0;
            hard1Broken  = 0;
            hard2Broken  = 0;
            hard3Broken  = 0;
            hard4Broken  = 0;
            hard5Broken  = 0;
            hard6Broken  = 0;
            hard7Broken  = 0;
            hard8Broken  = 0;
            hard9Broken  = 0;
            hard10Broken = 0;
            soft1Broken  = 0;
            soft3Broken  = 0;
            soft6Broken  = 0;
            soft8Broken  = 0;
            soft11Broken = 0;
            soft12Broken = 0;
            startTest    = TestHardConst_1;
            startTest   += TestHardConst_2;
            startTest   += TestHardConst_3;
            startTest   += TestHardConst_4;
            startTest   += TestHardConst_5;
            startTest   += TestHardConst_6;
            startTest   += TestHardConst_7;
            startTest   += TestHardConst_8;
            startTest   += TestHardConst_9;
            startTest   += TestHardConst_10;
            startTest   += TestSoftConst_1;
            startTest   += TestSoftConst_3;
            startTest   += TestSoftConst_6;
            startTest   += TestSoftConst_8;
            startTest   += TestSoftConst_11;
            startTest   += TestSoftConst_12;


            startTest(nurseList, schedDayList);
        }
Esempio n. 13
0
 public static void SaveTestList(TestsList list)
 {
     SaveTestList(list.m_name, list);
 }
Esempio n. 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // return to test start on refresh
        if (Page.IsPostBack && _isRefresh)
        {
            Response.Redirect(Request.RawUrl);
        }

        // do not update answers/questions on partial async postback (timer tick)
        if (Page.IsPostBack && ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)
        {
            return;
        }

        string var_id = Request.QueryString["id"];

        //manage page content
        if (var_id != null)
        {
            TestsList_Form.Visible = false;

            if (var_id == "new")
            {
                //display new test UI
                if (Session["teacher"] == null)
                {
                    Response.Redirect("~/Content/Tests.aspx");
                }

                if (!Page.IsPostBack)
                {
                    GenerateEmptyGridView();
                }

                TestsList.Visible    = false;
                NewTest_Form.Visible = true;
            }
            else // display test
            {
                string     SQL_SELECT = "SELECT * FROM " + TestsDB + " WHERE TestID=" + Request.QueryString["id"];
                SqlCommand CMD_SELECT = new SqlCommand(SQL_SELECT, DB_Connection);
                CMD_SELECT.CommandType = CommandType.Text;

                int        TestID         = 0;
                int        QuestionsLimit = 0;
                int        ChancesLimit   = 0;
                int        ChancesUsed    = 0;
                int        TimeLimit      = 0;
                bool       IsFree         = false;
                List <int> Questions      = new List <int>();

                DB_Connection.Open();

                using (SqlDataReader Reader = CMD_SELECT.ExecuteReader())
                {
                    if (Reader.Read())
                    {
                        DisplayTest_Title.Text = Reader["Title"].ToString();
                        TestID         = int.Parse(Reader["TestID"].ToString());
                        QuestionsLimit = int.Parse(Reader["QuestionsLimit"].ToString());
                        ChancesLimit   = int.Parse(Reader["ChancesLimit"].ToString());
                        TimeLimit      = int.Parse(Reader["TimeLimit"].ToString());
                        IsFree         = Convert.ToBoolean(Reader["IsFreeTest"]);

                        if (!IsFree && Session["student"] == null && Session["teacher"] == null)
                        {
                            Response.Redirect("~/Content/Tests.aspx");
                        }
                    }
                }

                if (ViewState["CurrentQuestion"] == null)
                {
                    string     SQL_SELECT_2 = "SELECT * FROM " + TestQuestionsDB + " WHERE TestID=" + TestID;
                    SqlCommand CMD_SELECT_2 = new SqlCommand(SQL_SELECT_2, DB_Connection);
                    CMD_SELECT_2.CommandType = CommandType.Text;

                    //make list of question IDs
                    using (SqlDataReader Reader = CMD_SELECT_2.ExecuteReader())
                    {
                        while (Reader.Read())
                        {
                            Questions.Add(int.Parse(Reader["QuestionID"].ToString()));
                        }
                    }

                    int[] Questions_Array = new int[QuestionsLimit];

                    // shuffle questions
                    for (int i = 0; i < QuestionsLimit; ++i)
                    {
                        int q = Questions[new Random().Next(Questions.Count)];

                        if (Array.IndexOf(Questions_Array, q) < 0)
                        {
                            Questions_Array[i] = q;
                        }
                        else
                        {
                            --i;
                        }
                    }

                    // display test info
                    if (Session["student"] != null || Session["teacher"] != null)
                    {
                        string     SQL_SELECT_3 = "SELECT count(*) FROM " + MarksDB + " WHERE Username='******' AND TestID=" + TestID;
                        SqlCommand CMD_SELECT_3 = new SqlCommand(SQL_SELECT_3, DB_Connection);
                        CMD_SELECT_3.CommandType = CommandType.Text;

                        ChancesUsed            = int.Parse(CMD_SELECT_3.ExecuteScalar().ToString());
                        TestInfo_UserInfo.Text = Session["SurName"].ToString();
                    }

                    int QuestionTimer = (TimeLimit * 60) / QuestionsLimit;

                    TestInfo_QuestionsLimit.Text       = Questions_Array.Length.ToString();
                    TestInfo_TimeLimit.Text            = TimeLimit == 0 ? "Необмежено" : TimeLimit + " хв.";
                    TestInfo_TimePerQuestionLimit.Text = TimeLimit == 0 ? "Необмежено" : QuestionTimer.ToString() + " сек.";
                    TestInfo_TimesPassed.Text          = ChancesLimit == 0 ? "Необмежено" : ChancesUsed.ToString() + " / " + ChancesLimit.ToString();

                    int j = new Random().Next(Questions_Array.Length);

                    ViewState["CurrentQuestion"] = Questions_Array[j];
                    ViewState["Questions"]       = Questions_Array;
                    ViewState["QuestionTimer"]   = QuestionTimer;
                    ViewState["TestTimer"]       = TimeLimit * 60;

                    // no chances left
                    if (ChancesUsed >= ChancesLimit && ChancesLimit != 0)
                    {
                        TestInfo_TimesPassed.ForeColor = System.Drawing.Color.Red;
                        next_question.Enabled          = false;
                    }

                    DisplayTest_InfoForm.Visible = true;
                }
                else
                {
                    // save answer
                    if (ViewState["Answers"] != null && ViewState["PassedQuestions"] != null)
                    {
                        int[] answers     = ViewState["Answers"] as int[];
                        int[] answers_new = new int[answers.Length + 1];

                        for (int i = 0; i < answers.Length; ++i)
                        {
                            answers_new[i] = answers[i];
                        }

                        answers_new[answers_new.Length - 1] = int.Parse(DisplayTest_ChoicesList.SelectedValue);
                        ViewState["Answers"] = answers_new;
                    }
                    else
                    {
                        if (DisplayTest_ChoicesList.SelectedIndex >= 0)
                        {
                            int[] answers = new int[1] {
                                int.Parse(DisplayTest_ChoicesList.SelectedValue)
                            };
                            ViewState["Answers"] = answers;
                        }
                    }

                    //show result if finished test
                    if (ViewState["Answers"] != null && ViewState["Questions"] != null && (ViewState["Answers"] as int[]).Length == (ViewState["Questions"] as int[]).Length)
                    {
                        DisplayTest_TimerPeriodic.Enabled = false;

                        int[] answers = ViewState["Answers"] as int[];
                        int   correct = 0;
                        int   Mark    = 0;

                        for (int i = 0; i < answers.Length; ++i)
                        {
                            string     SQL_SELECT_2 = "SELECT IsCorrect FROM " + TestAnswersDB + " WHERE ChoiceID=" + answers[i];
                            SqlCommand CMD_SELECT_2 = new SqlCommand(SQL_SELECT_2, DB_Connection);
                            CMD_SELECT_2.CommandType = CommandType.Text;

                            using (SqlDataReader Reader = CMD_SELECT_2.ExecuteReader())
                            {
                                if (Reader.Read() && Convert.ToBoolean(Reader["IsCorrect"]))
                                {
                                    ++correct;
                                }
                            }
                        }

                        float Points = (float)100 / answers.Length * correct;
                        Mark = (int)Points;

                        // save to DB if not free and if student logged in
                        if (!IsFree && Session["student"] != null)
                        {
                            string     SQL_SelectGroupID = "(SELECT GroupID FROM " + UsersDB + " WHERE Username='******')";
                            string     SQL_INSERT        = "INSERT INTO " + MarksDB + " VALUES('" + Session["student"].ToString() + "', " + TestID + ", " + Mark + ", '" + DateTime.Now.ToString() + "', " + SQL_SelectGroupID + ")";
                            SqlCommand CMD_INSERT        = new SqlCommand(SQL_INSERT, DB_Connection);
                            CMD_INSERT.CommandType = CommandType.Text;

                            CMD_INSERT.ExecuteNonQuery();
                        }

                        DB_Connection.Close();
                        DisplayTest_Result.Text          = "Кількість правильних відповідей  " + correct + " з " + answers.Length + " запитань. Ви набрали " + Mark + " балів.";
                        DisplayTest_QuestionForm.Visible = false;
                        DisplayTest_ResultForm.Visible   = true;
                        next_question.Visible            = false;
                        return;
                    }

                    // display (next) question

                    // update timer
                    if (ViewState["TestTimer"] != null && ViewState["Questions"] != null)
                    {
                        DisplayTest_TimeLeft.ForeColor = System.Drawing.Color.LightGreen;
                        DisplayTest_TimeLeft.Text      = "Залишилось часу: " + ViewState["QuestionTimer"].ToString() + " сек.";
                        Timer1.Enabled = false;
                    }

                    // show question
                    int CurrentQuestion = int.Parse(ViewState["CurrentQuestion"].ToString());

                    string     SQL_SELECT_3 = "SELECT QuestionText FROM " + TestQuestionsDB + " WHERE QuestionID=" + CurrentQuestion;
                    SqlCommand CMD_SELECT_3 = new SqlCommand(SQL_SELECT_3, DB_Connection);
                    CMD_SELECT_3.CommandType = CommandType.Text;

                    string     SQL_SELECT_4 = "SELECT * FROM " + TestAnswersDB + " WHERE QuestionID=" + CurrentQuestion;
                    SqlCommand CMD_SELECT_4 = new SqlCommand(SQL_SELECT_4, DB_Connection);
                    CMD_SELECT_4.CommandType = CommandType.Text;

                    using (SqlDataReader Reader = CMD_SELECT_3.ExecuteReader())
                    {
                        int    PassedQuestions = ViewState["PassedQuestions"] != null ? (ViewState["PassedQuestions"] as int[]).Length + 1 : 1;
                        string QuestionIndex   = "<b>" + PassedQuestions + "/" + QuestionsLimit + " </b>";

                        if (Reader.Read())
                        {
                            DisplayTest_QuestionText.Text = QuestionIndex + Reader["QuestionText"].ToString() + "<br />";
                        }
                    }

                    using (SqlDataReader Reader = CMD_SELECT_4.ExecuteReader())
                    {
                        DisplayTest_ChoicesList.Items.Clear();

                        //fill list of choices
                        while (Reader.Read())
                        {
                            ListItem item = new ListItem();
                            item.Value = Reader["ChoiceID"].ToString();
                            item.Text  = Reader["ChoiceText"].ToString();
                            DisplayTest_ChoicesList.Items.Add(item);
                        }

                        //shuffle choices
                        for (int i = 0; i < DisplayTest_ChoicesList.Items.Count; ++i)
                        {
                            int      r    = new Random().Next(DisplayTest_ChoicesList.Items.Count);
                            ListItem temp = DisplayTest_ChoicesList.Items[i];
                            DisplayTest_ChoicesList.Items.Remove(temp);
                            DisplayTest_ChoicesList.Items.Insert(r, temp);
                        }

                        //add default selection
                        ListItem item0 = new ListItem();
                        item0.Text     = "<b>жоден із варіантів</b>";
                        item0.Value    = "0";
                        item0.Selected = true;
                        DisplayTest_ChoicesList.Items.Add(item0);
                    }
                }

                TestsList.Visible = false;
                DisplayTest_QuestionForm.Visible = true;
                DisplayTest_Form.Visible         = true;

                DB_Connection.Close();
            }
        }
        else
        {
            // display list of tests
            if (Session["teacher"] == null)
            {
                TestsList.Columns[5].Visible = false;
                TestsList.ShowFooter         = false;
            }

            string SQL_SELECT = "SELECT * FROM " + TestsDB + " WHERE IsFreeTest=1";

            // display full list of tests only for logged in users
            if (Session["student"] != null || Session["teacher"] != null)
            {
                SQL_SELECT = "SELECT * FROM " + TestsDB + " ORDER BY IsFreeTest DESC";
            }

            SqlDataAdapter da = new SqlDataAdapter(SQL_SELECT, DB_Connection);
            DataTable      dt = new DataTable();

            DB_Connection.Open();

            da.Fill(dt);
            TestsList.DataSource = dt;
            TestsList.DataBind();

            DB_Connection.Close();
        }
    }