public async Task <IActionResult> PutQuizType(Guid id, QuizType quizType) { if (id != quizType.Id) { return(BadRequest()); } _context.Entry(quizType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuizTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(Guid id, [Bind("Name,CreatedBy,CreatedAt,EditedBy,EditedAt,Id")] QuizType quizType) { if (id != quizType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(quizType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuizTypeExists(quizType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(quizType)); }
public async Task <ActionResult <QuizType> > PostQuizType(QuizType quizType) { _context.QuizTypes.Add(quizType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetQuizType", new { id = quizType.Id }, quizType)); }
public void DisplayFeatureQuiz(QuizType type) { quizType = type; List <Feature> featuresToGuessFrom = new List <Feature>(); // featuresToGuessFrom.AddRange() foreach (Game r in currentGames) { if (r.featureList.ContainsKey(type)) { featuresToGuessFrom.AddRange(r.featureList[type]); } } int index = Random.Range(0, featuresToGuessFrom.Count); Feature theOne = featuresToGuessFrom[index]; featureAskedAboutInQuestion = theOne; print("found " + featuresToGuessFrom.Count + " " + type.ToString() + "s Picking " + theOne.Name); string q = FindQuestionString(quizType); q = string.Format(q, theOne.Name); PopulateQuestion(q, currentGames); }
public void DisplayImageQuiz() { quizType = QuizType.Image; List <Game> gamesToGuessFrom = new List <Game>(); foreach (Game r in currentGames) { if (r.images != null) { if (r.images.Count > 0) { gamesToGuessFrom.Add(r); } } } Game g = gamesToGuessFrom[Random.Range(0, gamesToGuessFrom.Count)]; string imgURL = g.images[Random.Range(0, g.images.Count)].medium_url; StartCoroutine(PullImage(imgURL)); string q = FindQuestionString(quizType); q = string.Format(q, g.name); PopulateQuestion(q, currentGames); gameImageWasFrom = g; }
public string FindDescriptorString(QuizType type) { string s = ""; switch (type) { case QuizType.Platform: s = "came out for the"; break; case QuizType.Character: s = "stars"; break; case QuizType.Location: s = "takes place in"; break; case QuizType.Concept: s = "includes"; break; case QuizType.Object: s = "has"; break; case QuizType.Theme: s = "brings themes of"; break; case QuizType.Developer: s = "was made by"; break; case QuizType.Publisher: s = "published by"; break; case QuizType.Genre: s = "is a"; break; case QuizType.People: s = "with"; break; case QuizType.DLC: s = "future DLC includes"; break; case QuizType.KilledCharacter: s = "these characters will die:"; break; } return(s); }
void AddTypeToPreviousTypes(QuizType typ) { previouslyAskedQuestions.Enqueue(typ); if (previouslyAskedQuestions.Count > 5) { previouslyAskedQuestions.Dequeue(); } }
public Result(User userTakingTheTest, List <Question> questionsAsked, List <Answer> selectedAnswers, QuizType quizType, DateTime dateTime, QuizTemplate questionSuite) { User = userTakingTheTest; QuestionsAsked = questionsAsked; SelectedAnswers = selectedAnswers; QuizType = quizType; DateTime = dateTime; QuestionSuite = questionSuite; }
public QuizViewModel(QuizType type, DateTime?startTime, int?timeLimit, List <Question> questions, int?questionSuiteId) { this.ResultType = type; this.StartTime = startTime; this.TimeLimit = timeLimit; foreach (Question question in questions) { DisplayedQuestions.Add(new QuestionQuizzViewModel(question)); } this.QuestionSuiteId = questionSuiteId; }
public async Task <IActionResult> Create([Bind("Name,CreatedBy,CreatedAt,EditedBy,EditedAt,Id")] QuizType quizType) { if (ModelState.IsValid) { quizType.Id = Guid.NewGuid(); _context.Add(quizType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(quizType)); }
public QuizPage(QuizType quiz) { NavigationPage.SetHasNavigationBar(this, false); NavigationPage.SetHasBackButton(this, false); InitializeComponent(); Clear(); if (quiz.View != null) { ((quiz.View as ContentView).BindingContext as BaseQuiz)?.ResetScore(); ((quiz.View as ContentView).BindingContext as BaseQuiz)?.OnResume(); QuizContent.Children.Add(quiz.View); } }
private void SetUpQuiz(HLHWord[] words, int quizWordIndex) { //int quizTypeInt = Random.Range(0, 2); currentQuizType = QuizType.ChToEn; HLHWord questionWord = words[quizWordIndex]; switch (currentQuizType) { case QuizType.EnToCh: pronounceButton.gameObject.SetActive(true); spellQuesiton.text = questionWord.spell; explainationQuestion.text = string.Empty; phoneticSymbolForExplainSelect.text = questionWord.phoneticSymbol; exampleSentenceText.text = questionWord.sentenceEN; for (int i = 0; i < words.Length; i++) { if (i < choiceTexts.Length) { Text choiceText = choiceTexts[i]; choiceText.text = words[i].explaination; choiceText.color = CommonData.darkYellowTextColor; } } break; case QuizType.ChToEn: pronounceButton.gameObject.SetActive(false); spellQuesiton.text = string.Empty; explainationQuestion.text = questionWord.explaination; phoneticSymbolForExplainSelect.text = string.Empty; exampleSentenceText.text = string.Empty; for (int i = 0; i < words.Length; i++) { if (i < choiceTexts.Length) { Text choiceText = choiceTexts[i]; choiceText.text = words[i].spell; choiceText.color = CommonData.darkYellowTextColor; } } break; } interactiveMask.enabled = false; }
//public List<Feature> TypeToFeature(QuizType q, Game g) //{ // Feature f; // switch (q) // { // case QuizType.Platform: // return g.platforms.OfType<Feature>().ToList(); // break; // } //} public void AddFeatureToMashup(QuizType q, Game g) { switch (q) { case QuizType.Platform: mashupGame.platforms.Add(featureAskedAboutInQuestion as Platform); break; case QuizType.Character: mashupGame.characters.Add(featureAskedAboutInQuestion as Character); break; case QuizType.Concept: mashupGame.concepts.Add(featureAskedAboutInQuestion as Concept); break; case QuizType.Developer: mashupGame.developers.Add(featureAskedAboutInQuestion as Developer); break; case QuizType.Location: mashupGame.locations.Add(featureAskedAboutInQuestion as Location); break; case QuizType.Object: mashupGame.objects.Add(featureAskedAboutInQuestion as Obj); break; case QuizType.People: mashupGame.people.Add(featureAskedAboutInQuestion as Person); break; case QuizType.Publisher: mashupGame.publishers.Add(featureAskedAboutInQuestion as Publisher); break; case QuizType.Theme: mashupGame.themes.Add(featureAskedAboutInQuestion as Theme); break; } apiHandler.FillGame(mashupGame); }
public void DisplayQuiz() { ShowRawDebugText(); if (deck.games.Count > 0) { // CompareGameToCurGames(deck.games[deck.games.Count - 1].gameIAm); } List <QuizType> validTypes = new List <QuizType>(); validTypes = TestForFeatures(); if (TestForImages()) { validTypes.Add(QuizType.Image); } QuizType typ = FindFeatureToAskAbout(validTypes); print(typ.ToString()); AddTypeToPreviousTypes(typ); if (typ == QuizType.Image) //noot great { DisplayImageQuiz(); } else { DisplayFeatureQuiz(typ); } StartCoroutine(Util.MoveToPos(question.rectTransform.anchoredPosition - outOfScreenX, question.rectTransform.anchoredPosition, question.rectTransform, curves.moveCurve, 2)); for (int i = 0; i < 3; i++) { float delay = Random.Range(0, 0.5f); StartCoroutine(Util.MoveToPos(uiGames[i].ownRect.anchoredPosition + outOfScreenX, uiGames[i].ownRect.anchoredPosition, uiGames[i].ownRect, curves.moveCurve, 1.2f, delay)); StartCoroutine(Util.WaitToEnable(uiGames[i].ownRect.gameObject, delay)); } }
/** * @param proficiency 表示只选择这个熟练度以下(包括当前)的,当取ProficiencyCount时表示不限熟练度 * @param bAllTime 选取全部时间范围的词 */ public bool InitQuiz(ArrayList wordPads, QuizType type, int testWordCount, NewWordItem.ProficiencyLevel proficiency, DateTime starDate, DateTime endDate, bool bAllTime = true) { HashSet<int> alreadyChoosedWordIndice = new HashSet<int>(); ArrayList totalWords = new ArrayList(); ArrayList totalWordsForOption = new ArrayList(); //不考虑时间的所有词,作为选项候选 int totalWordCount = 0; System.Collections.IEnumerator iterator = wordPads.GetEnumerator(); DateTime earliestTime = new DateTime(8000, 12, 31); DateTime latestTime = new DateTime(1000, 1, 1); while ( iterator.MoveNext() ) { WordPad wordPad = iterator.Current as WordPad; totalWordsForOption.AddRange(wordPad.Words); if ( bAllTime ) { totalWordCount += wordPad.Words.Count; totalWords.AddRange(wordPad.Words); } else { ArrayList wordsWithinTimeRange = wordPad.GetWordsByTimeRange(starDate, endDate); totalWordCount += wordsWithinTimeRange.Count; totalWords.AddRange(wordsWithinTimeRange); if (earliestTime.CompareTo(wordPad.EarliestAddTime) > 0) earliestTime = wordPad.EarliestAddTime; if (latestTime.CompareTo(wordPad.LatestAddTime) < 0) latestTime = wordPad.LatestAddTime; } } if (!bAllTime && (starDate.CompareTo(latestTime) > 0 // not in time range || endDate.CompareTo(earliestTime) < 0) ) { MessageBox.Show("specified time range exceed all the words' total time range!"); return false; } if ( totalWords.Count <= 3 ) { MessageBox.Show("Not sufficient words for a valid test!"); return false; } if (testWordCount > totalWords.Count) { testWordCount = totalWords.Count; MessageBox.Show("test word count is more than word count in all selected wordpads, so clamp to the actual count: " + totalWords.Count); } Random randGenerator = new Random(Convert.ToInt32(DateTime.Now.Millisecond)); for (int i = 0; i < testWordCount; i++ ) { int globalIndex = randGenerator.Next(0, totalWordCount); NewWordItem candidateWord = (NewWordItem)totalWords[globalIndex]; // exclude words not fit condition while ( alreadyChoosedWordIndice.Contains(globalIndex) || candidateWord.Meaning == "" || candidateWord.Proficiency > proficiency || ( !bAllTime && ( candidateWord.AddTime.CompareTo(starDate) < 0 // not in time range || candidateWord.AddTime.CompareTo(endDate) > 0 ) ) ) { globalIndex = randGenerator.Next(0, totalWordCount); candidateWord = (NewWordItem)totalWords[globalIndex]; } // add test word m_testWords.Add(totalWords[globalIndex]); // add meaning options for words HashSet<int> optionsChoosedForCurWord = new HashSet<int>(); optionsChoosedForCurWord.Add(globalIndex); ArrayList optionWords = new ArrayList(); for (int j = 0; j < 3; j++) { int optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); while (optionsChoosedForCurWord.Contains(optionWordIndex) || ((NewWordItem)totalWordsForOption[optionWordIndex]).Meaning == "") { optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); } optionWords.Add(totalWordsForOption[optionWordIndex]); optionsChoosedForCurWord.Add(optionWordIndex); } // insert correct word option int insertPos = randGenerator.Next(0, 3); optionWords.Insert(insertPos, totalWords[globalIndex]); m_wordToOptionMap.Add( ((NewWordItem)totalWords[globalIndex]).Name, optionWords); alreadyChoosedWordIndice.Add(globalIndex); } m_curTestWordIndex = 0; m_startTime = DateTime.Now; UpdateWordUI(); return true; }
public string FindQuestionString(QuizType type) { string s = ""; switch (type) { case QuizType.Platform: s = "Which of these games came out for the {0}?"; break; case QuizType.Character: s = "In which of these games is {0} a character?"; break; case QuizType.Location: s = "Which one of these games take place in {0}?"; break; case QuizType.Concept: s = "One of these games use {0}. Which one?"; break; case QuizType.Object: s = "Which of these games has a {0}?"; break; case QuizType.Theme: s = "Which of these games has a {0} theme?"; break; case QuizType.Developer: s = "Which of these games was made by {0}?"; break; case QuizType.Publisher: s = "Which of these games was published by {0}?"; break; case QuizType.People: s = "{0} worked on or has a connection to one of these games. Which one?"; break; case QuizType.Genre: s = "Which of these games fall under the {0} Genre?"; break; case QuizType.DLC: s = "The DLC {0} was for which game?"; break; case QuizType.KilledCharacter: s = "{0} died in one of these games. Which one?"; break; case QuizType.Image: s = "Which game is this image from?"; break; } return(s); }
private void SetQuizGroup(QuizType quizType) { _curTypeQuizList = (_allQuizList.Where(quiz => quiz.QuizType == quizType)).ToList(); ShowQuiz(_curTypeQuizList[_curQuizIndex]); }
public async Task Add(QuizType quizType) { _context.QuizTypes.Add(quizType); await _context.SaveChangesAsync(); }
/** * @param proficiency 表示只选择这个熟练度以下(包括当前)的,当取ProficiencyCount时表示不限熟练度 * @param bAllTime 选取全部时间范围的词 */ public bool InitQuiz(ArrayList wordPads, QuizType type, int testWordCount, NewWordItem.ProficiencyLevel proficiency, DateTime starDate, DateTime endDate, bool bAllTime = true) { HashSet <int> alreadyChoosedWordIndice = new HashSet <int>(); ArrayList totalWords = new ArrayList(); ArrayList totalWordsForOption = new ArrayList(); //不考虑时间的所有词,作为选项候选 int totalWordCount = 0; System.Collections.IEnumerator iterator = wordPads.GetEnumerator(); DateTime earliestTime = new DateTime(8000, 12, 31); DateTime latestTime = new DateTime(1000, 1, 1); while (iterator.MoveNext()) { WordPad wordPad = iterator.Current as WordPad; totalWordsForOption.AddRange(wordPad.Words); if (bAllTime) { totalWordCount += wordPad.Words.Count; totalWords.AddRange(wordPad.Words); } else { ArrayList wordsWithinTimeRange = wordPad.GetWordsByTimeRange(starDate, endDate); totalWordCount += wordsWithinTimeRange.Count; totalWords.AddRange(wordsWithinTimeRange); if (earliestTime.CompareTo(wordPad.EarliestAddTime) > 0) { earliestTime = wordPad.EarliestAddTime; } if (latestTime.CompareTo(wordPad.LatestAddTime) < 0) { latestTime = wordPad.LatestAddTime; } } } if (!bAllTime && (starDate.CompareTo(latestTime) > 0 || // not in time range endDate.CompareTo(earliestTime) < 0) ) { MessageBox.Show("specified time range exceed all the words' total time range!"); return(false); } if (totalWords.Count <= 3) { MessageBox.Show("Not sufficient words for a valid test!"); return(false); } if (testWordCount > totalWords.Count) { testWordCount = totalWords.Count; MessageBox.Show("test word count is more than word count in all selected wordpads, so clamp to the actual count: " + totalWords.Count); } Random randGenerator = new Random(Convert.ToInt32(DateTime.Now.Millisecond)); for (int i = 0; i < testWordCount; i++) { int globalIndex = randGenerator.Next(0, totalWordCount); NewWordItem candidateWord = (NewWordItem)totalWords[globalIndex]; // exclude words not fit condition while (alreadyChoosedWordIndice.Contains(globalIndex) || candidateWord.Meaning == "" || candidateWord.Proficiency > proficiency || (!bAllTime && (candidateWord.AddTime.CompareTo(starDate) < 0 || // not in time range candidateWord.AddTime.CompareTo(endDate) > 0) ) ) { globalIndex = randGenerator.Next(0, totalWordCount); candidateWord = (NewWordItem)totalWords[globalIndex]; } // add test word m_testWords.Add(totalWords[globalIndex]); // add meaning options for words HashSet <int> optionsChoosedForCurWord = new HashSet <int>(); optionsChoosedForCurWord.Add(globalIndex); ArrayList optionWords = new ArrayList(); for (int j = 0; j < 3; j++) { int optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); while (optionsChoosedForCurWord.Contains(optionWordIndex) || ((NewWordItem)totalWordsForOption[optionWordIndex]).Meaning == "") { optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); } optionWords.Add(totalWordsForOption[optionWordIndex]); optionsChoosedForCurWord.Add(optionWordIndex); } // insert correct word option int insertPos = randGenerator.Next(0, 3); optionWords.Insert(insertPos, totalWords[globalIndex]); m_wordToOptionMap.Add(((NewWordItem)totalWords[globalIndex]).Name, optionWords); alreadyChoosedWordIndice.Add(globalIndex); } m_curTestWordIndex = 0; m_startTime = DateTime.Now; UpdateWordUI(); return(true); }
public QuizViewModel(QuizType type, DateTime?startTime, QuizTemplate suite) : this(type, startTime, suite.TimeLimit, suite.Questions, suite.Id) { }
public QuizViewModel(QuizType resultType, List <Question> list) : this(resultType, null, null, list, null) { }
public QuizViewModel(QuizType type, DateTime?startTime, int eXAM_TIME_LIMIT, List <Question> questions) : this(type, startTime, eXAM_TIME_LIMIT, questions, null) { }