//1 // How many X are there in September? public void DayCount() { // Debug.Log("Day Count"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "How many yyy are there in month displayed?"; if (ques.Contains("yyy")) { // Debug.Log("Day count Logic"); int a = Random.Range(0, 7); ques = ques.Replace("yyy", WeekDays[a]); int n = daysDisplay.getQuestionDay(); int z = daysDisplay.GetQuestionWeekDay(); int ans = occurrenceDays(n, WeekDays[z], a); addQuestion.question = ques; addQuestion.answer = ans.ToString(); addQuestion.option1 = (Mathf.Abs(ans - 1)).ToString(); addQuestion.option2 = (ans + 1).ToString(); addQuestion.option3 = (ans + 2).ToString(); addQuestion.option4 = ans.ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); } else { Debug.Log("No question possible->Day Count"); } }
// public int DateAfter1(int days,int firstday,int desiredDay,int round,int afterDate,int month){ // int date =DateAfter1(n,z,a,b,0,m); //10 //If your birthday is on the 2nd Tuesday of august which date it would be? public void birthdayQuestion() { QuestionStructure addQuestion = new QuestionStructure(); // Debug.Log("birthdayQuestion"); string ques = "If your birthday is on the xxx yyy of month displayed which date it would be?"; int a = Random.Range(1, 3); int b = Random.Range(0, 7); if (ques.Contains("yyy")) { ques = ques.Replace("yyy", WeekDays[b]); ques = ques.Replace("xxx", a.ToString()); int m = daysDisplay.GetMonth(); int n = daysDisplay.getQuestionDay(); int z = daysDisplay.GetQuestionWeekDay(); // int date = DateFinder(n,z,b,a); int date = DateAfter1(n, z, b, a, 0, m); addQuestion.question = ques; addQuestion.answer = date.ToString(); addQuestion.option1 = ((date + 1) % 30).ToString(); addQuestion.option2 = ((date - 1) % 30).ToString(); addQuestion.option3 = (date).ToString(); addQuestion.option4 = (date + 2).ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); } else { Debug.Log("No question formation possible"); } }
//8 //Last day of the year? public void LastDay() { // Debug.Log("LastDay"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "Last day of the year yyy?"; int a = Random.Range(1996, 2100); if (ques.Contains("yyy")) { ques = ques.Replace("yyy", a.ToString()); ques = ques.Replace("yyy", a.ToString()); addQuestion.question = ques; addQuestion.answer = "31st December"; addQuestion.option1 = "31st December"; addQuestion.option2 = "1st February"; addQuestion.option3 = "1st November"; addQuestion.option4 = "1st January"; addQuestion.isCalendarView = false; questionList.Add(addQuestion); } else { Debug.Log("No question formation possible"); } }
//5 //How many days are there in April? public void NumDays() { string [] Month = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; int [] day = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; // Debug.Log("NumDays"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "How many days are there in xxx,yyy?"; int a = Random.Range(0, 12); int b = Random.Range(1996, 2100); // int m = daysDisplay.GetMonth(); // Debug.Log(m); // Debug.Log(Month[m]); if (ques.Contains("xxx")) { ques = ques.Replace("xxx", Month[a]); ques = ques.Replace("yyy", b.ToString()); addQuestion.question = ques; addQuestion.answer = day[a].ToString(); addQuestion.option1 = (day[a] + 1).ToString(); addQuestion.option2 = (day[a] - 1).ToString(); addQuestion.option3 = (day[a]).ToString(); addQuestion.option4 = (day[a] - 2).ToString(); addQuestion.isCalendarView = false; questionList.Add(addQuestion); } else { Debug.Log("No question possible->DayCount"); } }
//4 //What is the date of the first Sunday after 14thJuly? public void DateCount() { // Debug.Log("DateCount"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "What is the date of the xxx yyy after zzz?"; int a = Random.Range(1, 2); int b = Random.Range(0, 7); int c = Random.Range(1, 12); int n = daysDisplay.getQuestionDay(); int z = daysDisplay.GetQuestionWeekDay(); int m = daysDisplay.GetMonth(); if (ques.Contains("xxx")) { ques = ques.Replace("xxx", a.ToString()); ques = ques.Replace("yyy", WeekDays[b]); ques = ques.Replace("zzz", c.ToString()); // string ans = DateAfter(n,z,a,b,c,m,0); int ans = DateAfter1(n, z, b, a, c, m); addQuestion.question = ques; addQuestion.answer = ans.ToString(); addQuestion.option1 = (ans + 1).ToString(); addQuestion.option2 = (ans + 2).ToString(); addQuestion.option3 = ans.ToString(); addQuestion.option4 = ((ans - 1) % day[m]).ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); } else { Debug.Log("No question possible->DayCount"); } }
//3 //What is the date 4 days after 7th September? public void DayAfterCount() { // Debug.Log("DayCount"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "What is the date zz days after zzzth in month displayed?"; int a = Random.Range(1, 12); int b = Random.Range(3, 18); if (ques.Contains("zzz")) { ques = ques.Replace("zzz", b.ToString()); ques = ques.Replace("zz", a.ToString()); addQuestion.question = ques; addQuestion.answer = ((a + b) % 30).ToString(); addQuestion.option1 = ((a + b + 1) % 30).ToString(); addQuestion.option2 = ((a + b) % 30).ToString(); addQuestion.option3 = ((a + b - 1) % 30).ToString(); addQuestion.option4 = ((a + b - 2) % 30).ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); } else { Debug.Log("No question possible->DayCount"); } }
//2 //What is date of the first X in September? public void DateDisplay() { // Debug.Log("Date Display"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "What is the date of the zzz yyy in month displayed?"; if (ques.Contains("yyy")) { int a = Random.Range(0, 7); int b = Random.Range(1, 3); ques = ques.Replace("yyy", WeekDays[a]); ques = ques.Replace("zzz", b.ToString()); int n = daysDisplay.getQuestionDay(); int z = daysDisplay.GetQuestionWeekDay(); int m = daysDisplay.GetMonth(); // int date = DateFinder(n,z,a,b); int date = DateAfter1(n, z, a, b, 0, m); addQuestion.question = ques; addQuestion.answer = date.ToString(); addQuestion.option1 = ((date + 1) % 30).ToString(); addQuestion.option2 = (date + 3).ToString(); addQuestion.option3 = (date).ToString(); addQuestion.option4 = (date + 2).ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); } else { Debug.Log("No question possible->Date Display"); } }
public ViewModel() { QuestionStructure q1 = new QuestionStructure { Id = 1, Question = "How many days in a leap year?", PossibleAnswear = "2356,366,212,365" }; QuestionStructure q2 = new QuestionStructure { Id = 2, Question = "What is the next number in the series 2, 3, 5, 7, 11...?", PossibleAnswear = "15,88,99,13" }; QuestionStructure q3 = new QuestionStructure { Id = 3, Question = "How many wheel has a bike got?", PossibleAnswear = "5,3,4,2" }; QuestionStructure q4 = new QuestionStructure { Id = 4, Question = "How many fingers have you got?", PossibleAnswear = "5,8,20,10" }; List <QuestionStructure> items = new List <QuestionStructure>(); items.Add(q1); items.Add(q2); items.Add(q3); items.Add(q4); this.Questions = items; }
IEnumerator GetQuestion() { WaitForSeconds wait = new WaitForSeconds(5); yield return(wait); Item item = new Item(); while (true) { QuestionStructure question = board.GetQuestion(); awnsers.Clear(); tags.Clear(); item = new Item(); if (question != null) { question.pergunta_texto = question.pergunta_texto.ToLower(); question.pergunta_texto = TextCleaner.CleanText(question.pergunta_texto); Debug.Log("Respondendo: " + question.pergunta_texto); if (item.LoadItem(question.produto_nome)) { Debug.Log("Verficando Tags"); foreach (string key in item.intents.Keys) { if (question.pergunta_texto.Contains(key)) { tags.Add(key); Debug.Log("Tag Encontrada: " + key); awnsers.Add(item.intents[key]); } } if (awnsers.Count > 0) { CreateAwnser(); } else { board.Next(); } } else { Debug.Log("Item nao cadastrado"); } } yield return(wait); } }
//13 //Number of months with 31 days > number of months with 30 days (True or False) public void TruFalse() { QuestionStructure addQuestion = new QuestionStructure(); string ques = "Let A = Number of months with 30 days and B = Number of months with 31 days. Which is correct option?"; addQuestion.question = ques; addQuestion.answer = "A>B"; addQuestion.option1 = "A<B"; addQuestion.option2 = "A=B"; addQuestion.option3 = "A>B"; addQuestion.option4 = "A>=B"; questionList.Add(addQuestion); }
//12 //Abbreviation Questions!! public void Abbre() { string [] weekDayAbbre = new string [] { "Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun" }; int a = Random.Range(0, 7); QuestionStructure addQuestion = new QuestionStructure(); string ques = "Abbreviation for "; ques = ques + WeekDays[a]; addQuestion.question = ques; addQuestion.answer = weekDayAbbre[(a) % 7]; addQuestion.option1 = weekDayAbbre[(a + 1) % 7]; addQuestion.option2 = weekDayAbbre[(a + 2) % 7]; addQuestion.option3 = weekDayAbbre[(a + 4) % 7]; addQuestion.option4 = weekDayAbbre[(a) % 7]; questionList.Add(addQuestion); }
//9 //No of weekdays in given image public void numWeekDay() { string ques = "No of weekdays in given month"; int a = daysDisplay.getQuestionDay(); QuestionStructure addQuestion = new QuestionStructure(); int z = daysDisplay.GetQuestionWeekDay(); int n = NumberOfWeekDays(a, WeekDays[z]); addQuestion.question = ques; addQuestion.answer = n.ToString(); addQuestion.option1 = (n - 1).ToString(); addQuestion.option2 = (n - 2).ToString(); addQuestion.option3 = (n + 1).ToString(); addQuestion.option4 = (n).ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); }
public CourseStructure CreateCourseStructure(int courseId) { Course course = db.Courses.Find(courseId); CourseStructure courseStructure = new CourseStructure(); courseStructure.IdCourse = course.Id; List <ParagraphStructure> listParag = new List <ParagraphStructure>(); var paragraphs = db.Paragraphs.Where(p => p.CourseId == courseId).ToList(); foreach (var par in paragraphs) { List <TestStructure> tests = new List <TestStructure>(); var t = db.Tests.Where(te => te.ParagraphId == par.Id).ToList(); foreach (var test in t) { var questions = db.Questions.Where(q => q.TestId == test.Id); TestStructure testStructure = new TestStructure() { NumQuestion = questions.Count(), IdTest = test.Id, NumInParagraph = test.NumInParagraph }; List <QuestionStructure> queStructure = new List <QuestionStructure>(); foreach (var que in questions) { QuestionStructure q = new QuestionStructure() { Passed = false, NumInTest = que.NumInTest, IdQuestion = que.Id }; queStructure.Add(q); } testStructure.QuestionStructures = queStructure; db.TestStructures.Add(testStructure); tests.Add(testStructure); } ParagraphStructure paragraphStructure = new ParagraphStructure() { NumTest = tests.Count, Tests = tests, IdParagraph = par.Id, NumInCourse = par.NumInCourse }; db.ParagraphStructures.Add(paragraphStructure); listParag.Add(paragraphStructure); } courseStructure.NumParagraph = listParag.Count(); courseStructure.Paragraphs = listParag; db.CourseStructures.Add(courseStructure); db.SaveChanges(); return(courseStructure); }
//6 //Which days are considered as weekends? public void Weekends() { // Debug.Log("Weekends"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "Which days are considered as weekends?"; addQuestion.question = ques; int m = Random.Range(5, 7); int n = Random.Range(0, 5); addQuestion.answer = WeekDays[m]; addQuestion.option1 = WeekDays[(n + 1) % 5]; addQuestion.option2 = WeekDays[(n + 3) % 5]; addQuestion.option3 = WeekDays[(n + 2) % 5]; addQuestion.option4 = WeekDays[m]; addQuestion.isCalendarView = false; questionList.Add(addQuestion); }
//11 //If your parents anniversary is 1 week before your birthday what is your parents anniversary date? public void AnniversaryQuestion() { // Debug.Log("AnniversaryQuestions"); QuestionStructure addQuestion = new QuestionStructure(); string ques = "If your parents anniversary is 1 week before your birthday which is on 2nd Wednesday,what is your parents anniversary date?"; int a = Random.Range(1, 4); int b = Random.Range(0, 7); int c = Random.Range(1, 28); int n = daysDisplay.getQuestionDay(); int z = daysDisplay.GetQuestionWeekDay(); int m = daysDisplay.GetMonth(); int ans = FirstWedneday(n, z); addQuestion.question = ques; addQuestion.answer = ans.ToString(); addQuestion.option1 = ((ans + 1)).ToString(); addQuestion.option2 = ((ans + 3) % day[m]).ToString(); addQuestion.option3 = ans.ToString(); addQuestion.option4 = ((a + 2) % day[m]).ToString(); addQuestion.isCalendarView = true; questionList.Add(addQuestion); }
void BuildQuestion(string s) { CreateGap(); QuestionStructure qs = FindImageTags(s); int textId = 0; int imgId = 0; foreach (char c in qs.order) { switch (c) { case 't': CreateText(qs.texts[textId]); textId++; break; case 'i': CreateImage(qs.imgs[imgId]); imgId++; break; default: break; } CreateGap(); } CreateAnswers(); CreateGap(); }
//Retrieve Single Question Data public bool RetrieveData(int QuestionNumber, int Section) { if (CheckForQuestionExistance(this.TestCode, QuestionNumber, Section)) { using (var Con = new SqlConnection(GC.ConnectionString)) { Con.Open(); string Query = "Select Section,qtn_number,detail,qtn_type,ExamData from Temporary_Questions inner join Exams on Temporary_Questions.ExamCode=Exams.Exam_Code where Exams.id=(select Exams.id from Exams where Exams.Exam_code='" + this.TestCode + "') and Temporary_Questions.qtn_number='" + QuestionNumber + "' and Temporary_Questions.Section='" + Section + "' "; using (var Com = new SqlCommand(Query, Con)) { Qs = new QuestionStructure(); Db.Reader = Com.ExecuteReader(); while (Db.Reader.Read()) { DataRow Drow = Dt.NewRow(); questionNumber = Convert.ToInt32(Db.Reader["qtn_number"].ToString()); Drow["Question Number"] = Convert.ToInt32(Db.Reader["qtn_number"].ToString()); Drow["Question"] = Db.Reader["detail"].ToString(); Drow["Question Type"] = Convert.ToInt32(Db.Reader["qtn_type"].ToString()); Drow["Section"] = Convert.ToInt32(Db.Reader["Section"].ToString()); Drow["ConfigFile"] = Db.Reader["ExamData"].ToString(); Qs.QuestionNumber = Convert.ToInt32(Db.Reader["qtn_number"].ToString()); Qs.Question = Db.Reader["detail"].ToString(); Qs.QuestionType = Convert.ToInt32(Db.Reader["qtn_type"].ToString()); Qs.Section = Convert.ToInt32(Db.Reader["Section"].ToString()); Qs.ConfigurationFile = Db.Reader["ExamData"].ToString(); if (Convert.ToInt32(Db.Reader["qtn_type"].ToString()) == 1 || Convert.ToInt32(Db.Reader["qtn_type"].ToString()) == 3) { //Task Run on a different thread to operate Objectives Task QuestionObjectives = Task.Run(() => { object[] Objs = new object[] { }; List <ObjectivesContent> ObjsList = new List <ObjectivesContent>(); using (var con = new SqlConnection(GC.ConnectionString)) { con.Open(); string Query2 = "select x.id,x.detail,validity from temporary_objectives x inner join Temporary_Questions on x.Qtn_id=Temporary_Questions.id where x.ExamCode=(select Exam_Code from Exams where Exams.Exam_code='" + this.TestCode + "') and Temporary_Questions.qtn_number='" + this.MyQuestionNumber + "'"; using (var com = new SqlCommand(Query2, con)) { SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { ObjectivesContent Ob = new ObjectivesContent(); Ob.Detail = reader["detail"].ToString(); Ob.validity = Convert.ToInt32(reader["validity"].ToString()); Ob.ObjID = Convert.ToInt32(reader["id"].ToString()); ObjsList.Add(Ob); } Objs = ObjsList.ToArray(); Drow["Objective Data"] = Objs; Qs.Objectives = Objs; com.Dispose(); } con.Close(); } }); QuestionObjectives.Wait(); } else { } Dt.Rows.Add(Drow); } Com.Dispose(); } Con.Close(); } return(true); } else { return(false); } }
// Start is called before the first frame update async void Awake() { //PlayerPrefs.DeleteAll(); // RUN THIS ONCE TO CLEAR PLAYERPREFS SetupPlayerPrefs(); Debug.Log("Start"); DontDestroyOnLoad(gameObject); isFinishedFetching = false; Loader.Load(Loader.Scene.LoginScene); // Get login // PlayerPrefs.SetString("username", "elliott"); string gameUser = PlayerPrefs.GetString("username"); // Fetch class in which participates // Blocked async function interfaceLink = new Interface(); var classesJson = await interfaceLink.GetSignUpClasses(gameUser); Debug.Log(classesJson); UserSpecs specs = JsonConvert.DeserializeObject <UserSpecs>(classesJson); // Fetch leaderboard from each corresponding classTag // Need to fetch leaderboard for each classTag user is on // At every iteration we pick the score from N entry of score try { int z = 0; foreach (string _class in specs.docs[0].classTag) { // fetch Leaderboard var leaderboardJson = await interfaceLink.GetLeaderboard(_class, specs.docs[0].school); Thread.Sleep(1100); Leaderboard leaderboard = new Leaderboard(); leaderboard = JsonConvert.DeserializeObject <Leaderboard>(leaderboardJson); leaderboardList.Add(leaderboard); leaderboardList[z].module = _class; z++; Debug.Log(leaderboardJson); } } catch { Debug.Log("Login failed"); Destroy(gameObject); SceneManager.LoadScene(Loader.Scene.LoginScene.ToString()); return; } foreach (string _class in specs.docs[0].classTag) { // fetch Question var questionJson = await interfaceLink.GetQuestions(_class, specs.docs[0].school); Thread.Sleep(1100); QuestionStructure questionData = new QuestionStructure(); questionData = JsonConvert.DeserializeObject <QuestionStructure>(questionJson); questionData.module = _class; questionList.Add(questionData); Debug.Log(questionJson); } // Size of RoundData array int moduleSize = questionList.Count; // Initialize RoundData for Elliot and Array of set questionSet = new RoundData[moduleSize]; for (int i = 0; i < moduleSize; i++) { questionSet[i] = new RoundData(); questionSet[i].module = specs.docs[0].classTag[i]; // Initialize array of easy and hard questions questionSet[i].hardOrEasy = new DifficultyData[2]; questionSet[i].hardOrEasy[0] = new DifficultyData(); questionSet[i].hardOrEasy[1] = new DifficultyData(); questionSet[i].hardOrEasy[0].isHard = true; questionSet[i].hardOrEasy[1].isHard = false; // Get number of "Easy" and "Hard" questions int[] diffCount = GetEasyNumber(questionList[i].docs); // Define number of questions per module questionSet[i].hardOrEasy[0].questions = new QuestionsList[diffCount[0]]; questionSet[i].hardOrEasy[1].questions = new QuestionsList[diffCount[1]]; int easyCount = 0; int hardCount = 0; for (int j = 0; j < questionList[i].docs.Count; j++) { // Check number of options for question int numberAnswers = GetNumberAnswers(questionList[i].docs[j]); // Fill easy questions with difficulty == hard if (questionList[i].docs[j].difficulty == "Hard") { // Create question instance questionSet[i].hardOrEasy[0].questions[hardCount] = new QuestionsList(); // Fill question questionSet[i].hardOrEasy[0].questions[hardCount].question = questionList[i].docs[j].question; // Fill answers for the question questionSet[i].hardOrEasy[0].questions[hardCount].answers = new AnswersList[numberAnswers]; FillEasyAnswers(numberAnswers, questionSet[i].hardOrEasy[0].questions[hardCount].answers, i, j); hardCount++; } // Fill hard questions with difficulty == easy else if (questionList[i].docs[j].difficulty == "Easy") { // Create question instance questionSet[i].hardOrEasy[1].questions[easyCount] = new QuestionsList(); // Fill question questionSet[i].hardOrEasy[1].questions[easyCount].question = questionList[i].docs[j].question; // Fill answers for the question questionSet[i].hardOrEasy[1].questions[easyCount].answers = new AnswersList[numberAnswers]; FillEasyAnswers(numberAnswers, questionSet[i].hardOrEasy[1].questions[easyCount].answers, i, j); easyCount++; } } } questionSetWanted = questionSet[0]; // Transform Leaderboard List into Leaderboard Array Object // Create Leaderboard Array Object leaderboardArray = new LeaderboardStructure[specs.docs[0].classTag.Count]; for (int i = 0; i < specs.docs[0].classTag.Count; i++) { leaderboardArray[i] = new LeaderboardStructure(); leaderboardArray[i].module = leaderboardList[i].module; leaderboardArray[i].score = new List <string>(); leaderboardArray[i].user = new List <string>(); // Initialize string list for (int j = 0; j < leaderboardList[i].docs.Count; j++) { // Iterate through users found // Assign each module its scores and users corresponding for (int k = 0; k < leaderboardList[i].docs[j].classTag.Count; k++) { if (leaderboardList[i].docs[j].classTag[k] == leaderboardList[i].module) { leaderboardArray[i].score.Add(leaderboardList[i].docs[j].score[k]); leaderboardArray[i].user.Add(leaderboardList[i].docs[j]._id); } } } } leaderboardWanted = leaderboardArray[0]; // The Fetching is done isFinishedFetching = true; var responseMessage = interfaceLink.UpdateHighScore(specs.docs[0]); Loader.Load(Loader.Scene.MainMenu); }