private void button3_Click(object sender, EventArgs e) { string text = tbText.Text; Subject subj = cbSubjects.SelectedItem as Subject; int complexity = rbVeryEz.Checked ? 1 : rbEz.Checked ? 2 : rbMiddle.Checked ? 3 : rbHard.Checked ? 4 : rbHardcore.Checked ? 5 : 0; Question q; if (lbOptions.Items.Count > 0) { List <string> strings = new List <string>(); foreach (var t in lbOptions.Items) { strings.Add(t.ToString()); } q = new TestQuestion(strings, text, complexity, subj); } else { q = new SimpleQuestion(text, complexity, subj); } if (updateMode == false) { controller.AddQuestion(q); } else { q.ID = this.q.ID; controller.UpdateQuestion(q); } Close(); }
private void LoadQuestion() { TryAnswer.Visible = true; GoNext.Visible = false; QuestionPanel.Visible = true; using (ForumContainer container = new ForumContainer()) { var quest = Questions.FirstOrDefault(x => x.Position == CurrentPosition).QuestionSet; var question = container.QuestionSet.FirstOrDefault(x => x.QuestionId == quest.QuestionId); SimpleQuestion simpleQuestion = new SimpleQuestion(new Size(443, 291), question) { Dock = DockStyle.Fill }; QuestionPanel.Controls.Add(simpleQuestion); } }
private void dgvSimpleQuestion_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } string question = "Question: "; SimpleQuestion sq = lstSimple.ElementAt(e.RowIndex); question += sq.question + "\r\n"; // MessageBox.Show("SList question=" + lstSimple.Count); for (int i = 0; i < sq.answer.Count; ++i) { question += (char)(65 + i) + ". " + sq.answer.ElementAt(i) + "\r\n"; } question += "=> Correct: " + (char)(65 + sq.correctAnswer) + "\r\n"; txtView.Text = question; }
public void RequestHelp(string question, int channelid) { if (string.IsNullOrWhiteSpace(question)) { question = ""; } Connection con = DB.Connections.Find(Context.ConnectionId); if (con == null) { return; } User userFromDb = con.User; if (userFromDb == null) { return; } Channel channel = DB.Channels.Find(channelid); if (userFromDb.AreUserQuestioning(channel)) { Clients.Caller.SetQuestionState(true, channelid); return; } Question q = userFromDb.RequestHelp(channel, question); if (q == null) { return; } DB.Questions.Add(q); DB.SaveChanges(); SimpleQuestion sq = q.ToSimpleQuestion(); foreach (Connection connection in channel.Users.SelectMany(user => user.Connections)) { Clients.Client(connection.ConnectionId).AddQuestion(sq, channel.Id); } foreach (Connection connection in userFromDb.Connections) { Clients.Client(connection.ConnectionId).SetQuestionState(true, channelid); } }
void Start() { animalFood001 = new SimpleQuestion() { number = 1, questionName = "carrots", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Cat"), answerOptions = new List <string>() { "mouse", "horse", "cat", "rabbit" }, tags = new List <string>() { "animals" }, size = 1 }; }
void Start() { animalActions001 = new SimpleQuestion() { number = 1, questionName = "shark", fairyTalk = "A shark", answer = "swims", answerOptions = new List <string>() { "swims", "runs", "jumps", null }, tags = new List <string>() { "animals", "actions", "verbs" }, size = 1 }; animalActions002 = new SimpleQuestion() { number = 2, questionName = "parrot", fairyTalk = "A parrot can", answer = "fly", answerOptions = new List <string>() { "jump", "fly", "hop", null }, tags = new List <string>() { "animals", "actions", "verbs" }, size = 1 }; animalActions003 = new SimpleQuestion() { number = 3, questionName = "walk", fairyTalk = "Who walks?", answer = "tortoise", answerOptions = new List <string>() { "tortoise", "lizard", "mouse", null }, tags = new List <string>() { "animals", "actions", "verbs" }, size = 1 }; // tortoise joke animalActions004 = new SimpleQuestion() { number = 4, questionName = "penguin", fairyTalk = "I am a bird, but I can not", answer = "fly", answerOptions = new List <string>() { "fly", "run", null, null }, tags = new List <string>() { "animals", "actions", "verbs" }, size = 1 }; animalActions006 = new SimpleQuestion() { number = 6, questionName = "hop", fairyTalk = "Who hops?", answer = "rabbit", answerOptions = new List <string>() { "rabbit", "snail", "ant", null }, tags = new List <string>() { "animals", "actions", "verbs" }, size = 1 }; animalActions007 = new SimpleQuestion() { number = 7, questionName = "kangaroo", fairyTalk = "I am a kangaroo. I can", answer = "jump", answerOptions = new List <string>() { "run", "swim", "jump", null }, tags = new List <string>() { "animals", "actions", "verbs" }, size = 1 }; // kangaroo joke // Fairy talk: "Fairy: now you have to choose two correct answers." }
void Start() { animalName001 = new SimpleQuestion() { number = 1, questionName = "cat", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Cat"), answerOptions = new List <string>() { "bear", "dog", "cat", "horse" }, tags = new List <string>() { "animals" }, size = 1 }; animalName002 = new SimpleQuestion() { number = 2, questionName = "dog", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Dog"), answerOptions = new List <string>() { "mouse", "cat", "duck", "dog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName003 = new SimpleQuestion() { number = 3, questionName = "horse", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Horse"), answerOptions = new List <string>() { "dog", "horse", "mouse", "ant" }, tags = new List <string>() { "animals" }, size = 1 }; animalName004 = new SimpleQuestion() { number = 4, questionName = "bear", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Bear"), answerOptions = new List <string>() { "bear", "horse", "mouse", "ant" }, tags = new List <string>() { "animals" }, size = 1 }; animalName005 = new SimpleQuestion() { number = 5, questionName = "wolf", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Wolf"), answerOptions = new List <string>() { "cat", "wolf", "mouse", "ant" }, tags = new List <string>() { "animals" }, size = 1 }; animalName006 = new SimpleQuestion() { number = 6, questionName = "zebra", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Zebra"), answerOptions = new List <string>() { "dog", "horse", "mouse", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName007 = new SimpleQuestion() { number = 7, questionName = "owl", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Owl"), answerOptions = new List <string>() { "dog", "horse", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName008 = new SimpleQuestion() { number = 8, questionName = "monkey", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Monkey"), answerOptions = new List <string>() { "monkey", "horse", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName009 = new SimpleQuestion() { number = 9, questionName = "squirrel", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Squirrel"), answerOptions = new List <string>() { "monkey", "squirrel", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName010 = new SimpleQuestion() { number = 10, questionName = "giraffe", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Giraffe"), answerOptions = new List <string>() { "giraffe", "squirrel", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName011 = new SimpleQuestion() { number = 11, questionName = "lion", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Lion"), answerOptions = new List <string>() { "giraffe", "squirrel", "lion", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName012 = new SimpleQuestion() { number = 12, questionName = "alligator", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Alligator"), answerOptions = new List <string>() { "alligator", "squirrel", "lion", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName013 = new SimpleQuestion() { number = 13, questionName = "rhinoceros", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Rhinoceros"), answerOptions = new List <string>() { "rhinoceros", "squirrel", "lion", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName014 = new SimpleQuestion() { number = 14, questionName = "duck", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Duck"), answerOptions = new List <string>() { "rhinoceros", "squirrel", "lion", "duck" }, tags = new List <string>() { "animals" }, size = 1 }; animalName015 = new SimpleQuestion() { number = 15, questionName = "pig", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Pig"), answerOptions = new List <string>() { "rhinoceros", "squirrel", "pig", "duck" }, tags = new List <string>() { "animals" }, size = 1 }; animalName016 = new SimpleQuestion() { number = 16, questionName = "donkey", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Donkey"), answerOptions = new List <string>() { "rhinoceros", "squirrel", "pig", "donkey" }, tags = new List <string>() { "animals" }, size = 1 }; animalName017 = new SimpleQuestion() { number = 17, questionName = "rabbit", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Rabbit"), answerOptions = new List <string>() { "rabbit", "squirrel", "pig", "donkey" }, tags = new List <string>() { "animals" }, size = 1 }; animalName018 = new SimpleQuestion() { number = 18, questionName = "frog", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Frog"), answerOptions = new List <string>() { "rabbit", "squirrel", "pig", "frog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName019 = new SimpleQuestion() { number = 19, questionName = "tiger", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Tiger"), answerOptions = new List <string>() { "tiger", "squirrel", "pig", "frog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName020 = new SimpleQuestion() { number = 20, questionName = "goat", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Goat"), answerOptions = new List <string>() { "tiger", "squirrel", "goat", "frog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName021 = new SimpleQuestion() { number = 21, questionName = "chicken", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Chicken"), answerOptions = new List <string>() { "tiger", "squirrel", "goat", "chicken" }, tags = new List <string>() { "animals" }, size = 1 }; animalName022 = new SimpleQuestion() { number = 22, questionName = "elephant", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Elephant"), answerOptions = new List <string>() { "tiger", "elephant", "goat", "chicken" }, tags = new List <string>() { "animals" }, size = 1 }; animalName023 = new SimpleQuestion() { number = 23, questionName = "iguana", sprite = Resources.Load <Sprite>("SimpleApp/Questions/Iguana"), answerOptions = new List <string>() { "tiger", "elephant", "goat", "iguana" }, tags = new List <string>() { "animals" }, size = 1 }; }
private void GetData(object path) { //numOfAnswer++ Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); SimpleQuestion qItem = null; // Define an object to pass to the API for missing parameters object miss = System.Reflection.Missing.Value; object readOnly = true; Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); int flag = 0; for (int i = 1; i <= docs.Paragraphs.Count; i++) { string temp = docs.Paragraphs[i].Range.Text.Trim(); if (temp.Trim().ToLower().Equals("<multi>"))// multi question { MultiQuestion qMul = new MultiQuestion(); //int no_multi_ques = 0; do { temp = docs.Paragraphs[++i].Range.Text; if (temp.Trim() == "") { break; } qMul.content += temp + "\r\n"; //lọc công thức toán /* * temp = docs.Paragraphs[++i].Range.Text; * if (LocCongThucToan(temp, i, no_multi_ques)) * { * MessageBox.Show("Chen anh answ " + i); * } */ } while (temp != string.Empty); if (temp.Trim() != "") { MessageBox.Show("Lỗi cú pháp tại \"" + qMul.content + "\"..."); lstSimple.Clear(); lstMulti.Clear(); return; } while (!temp.Trim().ToLower().Equals("</multi>")) { temp = docs.Paragraphs[++i].Range.Text.Trim(); if (temp != "") { qItem = new SimpleQuestion(); qItem.question = temp; qItem.correctAnswer = -1; List <string> answer = new List <string>(); do { temp = docs.Paragraphs[++i].Range.Text.Trim(); if (temp == string.Empty || temp.ToLower().Equals("</multi>")) { break; } temp = Regex.Replace(temp, "[a-z1-4](\\.|\\))[ \t]+", "", RegexOptions.IgnoreCase); if (temp.EndsWith("*")) { qItem.correctAnswer = answer.Count; temp = temp.Substring(0, temp.Length - 1).Trim(); answer.Add(temp); } else { answer.Add(temp); } } while (temp != string.Empty); qItem.answer = answer; if (qItem.correctAnswer != -1) { qMul.lstQuestion.Add(qItem); } else { MessageBox.Show("Câu hỏi \"" + qItem.question + "\" không có câu trả lời đúng"); lstSimple.Clear(); lstMulti.Clear(); return; } } else { MessageBox.Show("Lỗi cú pháp tại " + qMul.content + "\"..."); lstSimple.Clear(); lstMulti.Clear(); return; } } lstMulti.Add(qMul); //hiển thị list câu hỏi lên rtxtFileNoiDung string question = ""; question += qMul.content; question += "\n================================================" + "\r\n"; foreach (SimpleQuestion sq in qMul.lstQuestion) { question += sq.question + "\r\n"; for (int idx = 0; idx < sq.answer.Count; ++idx) { question += (char)(65 + idx) + ". " + sq.answer.ElementAt(idx) + "\r\n"; } question += "=> Correct: " + (char)(65 + sq.correctAnswer) + "\r\n\r\n\n"; } rtxtFileNoiDung.Text += question; //Ignore blank paragraph i++; } else if (temp != string.Empty) //simple question { if (flag % 2 == 0) { //remove question number like Câu 1, Câu 2,... temp = Regex.Replace(temp, "^[0-9]+\\.[ ]*|^Câu [0-9]+:[ ]*|^Question [0-9]+:[ ]*", "", RegexOptions.IgnoreCase); qItem = new SimpleQuestion(); //lọc công thức toán học /* if(LocCongThucToan(temp,i)) * { * MessageBox.Show("Chen anh "); * }*/ qItem.question = temp; } else { List <string> answer = new List <string>(); qItem.correctAnswer = -1; // int no_ans = 0; while (temp != string.Empty) { //lọc công thức toán học /* no_ans++; * * if (LocCongThucToan(temp, i, no_ans)) * { * MessageBox.Show("Chen anh answ "+i); * }*/ //remove answer key, like A,B,C,D temp = Regex.Replace(temp, "[a-z1-4](\\.|\\))[ \t]+", "", RegexOptions.IgnoreCase); if (temp.EndsWith("*")) { qItem.correctAnswer = answer.Count; temp = temp.Substring(0, temp.Length - 1).Trim(); answer.Add(temp); } else { answer.Add(temp); } temp = docs.Paragraphs[++i].Range.Text.Trim(); } qItem.answer = answer; if (qItem.correctAnswer != -1) { lstSimple.Add(qItem); //hiển thị lstSimple lên txtFileNoiDung string question = "Question: "; question += qItem.question + "\r\n"; for (int idx = 0; idx < qItem.answer.Count; ++idx) { question += (char)(65 + idx) + ". " + qItem.answer.ElementAt(idx) + "\r\n"; } question += "=> Correct: " + (char)(65 + qItem.correctAnswer) + "\r\n\n"; rtxtFileNoiDung.Text += question; } else { MessageBox.Show("Câu hỏi \"" + qItem.question + "\" không có câu trả lời đúng"); lstSimple.Clear(); lstMulti.Clear(); return; } } flag++; } else { MessageBox.Show("Lỗi cú pháp tại " + lstSimple.ElementAt(lstSimple.Count - 1).question); lstSimple.Clear(); lstMulti.Clear(); return; } } docs.Close(); word.Quit(); }
public async Task ImportsSimpleQuestions() { // Arrange const string name = "name"; const string tags = "tags,tags"; var fileNames = new[] { "file1" }; var questionnaire = new Questionnaire { Revision = 1, Name = name, Tags = tags }; var question1 = new SimpleQuestion { Revision = 1, SimpleQuestionType = SimpleQuestionType.SingleChoice, Text = "Text1", Answers = new List <SimpleAnswer> { new SimpleAnswer { IsCorrect = true, Text = "Answer1.1" }, new SimpleAnswer { IsCorrect = false, Text = "Answer1.2" } } }; var answers1 = question1.Answers.ToList(); var question2 = new SimpleQuestion { Revision = 1, SimpleQuestionType = SimpleQuestionType.TrueFalse, Text = "Text2", Answers = new List <SimpleAnswer> { new SimpleAnswer { IsCorrect = false, Text = "Answer2.1" }, new SimpleAnswer { IsCorrect = true, Text = "Answer2.2" }, new SimpleAnswer { IsCorrect = true, Text = "Answer2.3" } } }; var answers2 = question2.Answers.ToList(); var fileText = "1;;;;;;;\n" + "Text;Typ;Text Antwort 1;Anwort korrekt?;Text Antwort 2;;;\n" + $"\"{question1.Text}\";{(int)question1.SimpleQuestionType};{answers1[0].Text};{answers1[0].IsCorrect};{answers1[1].Text};{answers1[1].IsCorrect};;\r\n" + $"{question2.Text};{(int)question2.SimpleQuestionType};\"{answers2[0].Text}\";{answers2[0].IsCorrect};{answers2[1].Text};{answers2[1].IsCorrect};{answers2[2].Text};{answers2[2].IsCorrect}\n"; var expectedImportedQuestions = new Dictionary <string, List <string> > { [fileNames[0]] = new List <string> { question1.Text, question2.Text } }; var questionsUow = A.Fake <IQuestionsUnitOfWork>(); var questionnairesUow = A.Fake <IQuestionnairesUnitOfWork>(); var file = A.Fake <IFile>(); A.CallTo(() => file.ReadAllText(A <string> .That.Matches(_ => _ == fileNames[0]))) .Returns(fileText); var testee = new ImportExportService(questionnairesUow, questionsUow, file); // Act (Dictionary <string, List <string> > importedQuestions, List <string> erroredFiles) = await testee.Import(name, tags, fileNames); // Assert importedQuestions.Should().BeEquivalentTo(expectedImportedQuestions); erroredFiles.Should().BeNullOrEmpty(); A.CallTo(() => questionnairesUow.QuestionnairesRepo.Add(A <Questionnaire> .That.Matches(_ => this.matchEntity(_, questionnaire)))) .MustHaveHappened(); A.CallTo(() => questionsUow.SimpleQuestionsRepo.Add(A <SimpleQuestion> .That.Matches(_ => this.matchEntity(_, question1)))) .MustHaveHappened(); A.CallTo(() => questionsUow.SimpleQuestionsRepo.Add(A <SimpleQuestion> .That.Matches(_ => this.matchEntity(_, question2)))) .MustHaveHappened(); A.CallTo(() => questionnairesUow.Complete()) .MustHaveHappened(); A.CallTo(() => questionsUow.Complete()) .MustHaveHappened(Repeated.Exactly.Times(3)); }
void Start() { animalName001 = new SimpleQuestion() { number = 1, questionName = "cat", sprite = Resources.Load <Sprite>("Questions/Animals/Cat"), answerOptions = new List <string>() { "bear", "dog", "cat", "horse" }, tags = new List <string>() { "animals" }, size = 1 }; animalName002 = new SimpleQuestion() { number = 2, questionName = "dog", sprite = Resources.Load <Sprite>("Questions/Animals/Dog"), answerOptions = new List <string>() { "mouse", "cat", "duck", "dog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName003 = new SimpleQuestion() { number = 3, questionName = "horse", sprite = Resources.Load <Sprite>("Questions/Animals/Horse"), answerOptions = new List <string>() { "dog", "horse", "mouse", "ant" }, tags = new List <string>() { "animals" }, size = 1 }; animalName004 = new SimpleQuestion() { number = 4, questionName = "bear", sprite = Resources.Load <Sprite>("Questions/Animals/Bear"), answerOptions = new List <string>() { "bear", "horse", "mouse", "ant" }, tags = new List <string>() { "animals" }, size = 1 }; animalName005 = new SimpleQuestion() { number = 5, questionName = "wolf", sprite = Resources.Load <Sprite>("Questions/Animals/Wolf"), answerOptions = new List <string>() { "cat", "wolf", "mouse", "ant" }, tags = new List <string>() { "animals" }, size = 1 }; animalName006 = new SimpleQuestion() { number = 6, questionName = "zebra", sprite = Resources.Load <Sprite>("Questions/Animals/Zebra"), answerOptions = new List <string>() { "dog", "horse", "mouse", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName007 = new SimpleQuestion() { number = 7, questionName = "owl", sprite = Resources.Load <Sprite>("Questions/Animals/Owl"), answerOptions = new List <string>() { "dog", "horse", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName008 = new SimpleQuestion() { number = 8, questionName = "monkey", sprite = Resources.Load <Sprite>("Questions/Animals/Monkey"), answerOptions = new List <string>() { "monkey", "horse", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName009 = new SimpleQuestion() { number = 9, questionName = "parrot", sprite = Resources.Load <Sprite>("Questions/Animals/Parrot"), answerOptions = new List <string>() { "monkey", "parrot", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName010 = new SimpleQuestion() { number = 10, questionName = "giraffe", sprite = Resources.Load <Sprite>("Questions/Animals/Giraffe"), answerOptions = new List <string>() { "giraffe", "parrot", "owl", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName011 = new SimpleQuestion() { number = 11, questionName = "lion", sprite = Resources.Load <Sprite>("Questions/Animals/Lion"), answerOptions = new List <string>() { "giraffe", "parrot", "lion", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName012 = new SimpleQuestion() { number = 12, questionName = "crocodile", sprite = Resources.Load <Sprite>("Questions/Animals/Crocodile"), answerOptions = new List <string>() { "crocodile", "parrot", "lion", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName013 = new SimpleQuestion() { number = 13, questionName = "cow", sprite = Resources.Load <Sprite>("Questions/Animals/Cow"), answerOptions = new List <string>() { "cow", "parrot", "lion", "zebra" }, tags = new List <string>() { "animals" }, size = 1 }; animalName014 = new SimpleQuestion() { number = 14, questionName = "duck", sprite = Resources.Load <Sprite>("Questions/Animals/Duck"), answerOptions = new List <string>() { "cow", "parrot", "lion", "duck" }, tags = new List <string>() { "animals" }, size = 1 }; animalName015 = new SimpleQuestion() { number = 15, questionName = "pig", sprite = Resources.Load <Sprite>("Questions/Animals/Pig"), answerOptions = new List <string>() { "cow", "parrot", "pig", "duck" }, tags = new List <string>() { "animals" }, size = 1 }; animalName016 = new SimpleQuestion() { number = 16, questionName = "donkey", sprite = Resources.Load <Sprite>("Questions/Animals/Donkey"), answerOptions = new List <string>() { "cow", "parrot", "pig", "donkey" }, tags = new List <string>() { "animals" }, size = 1 }; animalName017 = new SimpleQuestion() { number = 17, questionName = "rabbit", sprite = Resources.Load <Sprite>("Questions/Animals/Rabbit"), answerOptions = new List <string>() { "rabbit", "parrot", "pig", "donkey" }, tags = new List <string>() { "animals" }, size = 1 }; animalName018 = new SimpleQuestion() { number = 18, questionName = "frog", sprite = Resources.Load <Sprite>("Questions/Animals/Frog"), answerOptions = new List <string>() { "rabbit", "parrot", "pig", "frog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName019 = new SimpleQuestion() { number = 19, questionName = "tiger", sprite = Resources.Load <Sprite>("Questions/Animals/Tiger"), answerOptions = new List <string>() { "tiger", "parrot", "pig", "frog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName020 = new SimpleQuestion() { number = 20, questionName = "goat", sprite = Resources.Load <Sprite>("Questions/Animals/Goat"), answerOptions = new List <string>() { "tiger", "parrot", "goat", "frog" }, tags = new List <string>() { "animals" }, size = 1 }; animalName021 = new SimpleQuestion() { number = 21, questionName = "chicken", sprite = Resources.Load <Sprite>("Questions/Animals/Chicken"), answerOptions = new List <string>() { "tiger", "parrot", "goat", "chicken" }, tags = new List <string>() { "animals" }, size = 1 }; animalName022 = new SimpleQuestion() { number = 22, questionName = "elephant", sprite = Resources.Load <Sprite>("Questions/Animals/Elephant"), answerOptions = new List <string>() { "tiger", "elephant", "goat", "chicken" }, tags = new List <string>() { "animals" }, size = 1 }; animalName023 = new SimpleQuestion() { number = 23, questionName = "lizard", sprite = Resources.Load <Sprite>("Questions/Animals/Lizard"), answerOptions = new List <string>() { "tiger", "elephant", "goat", "lizard" }, tags = new List <string>() { "animals" }, size = 1 }; animalName024 = new SimpleQuestion() { number = 24, questionName = "bat", sprite = Resources.Load <Sprite>("Questions/Animals/Bat"), answerOptions = new List <string>() { "tiger", "elephant", "bat", "lizard" }, tags = new List <string>() { "animals" }, size = 1 }; animalName025 = new SimpleQuestion() { number = 25, questionName = "eagle", sprite = Resources.Load <Sprite>("Questions/Animals/Eagle"), answerOptions = new List <string>() { "tiger", "elephant", "bat", "eagle" }, tags = new List <string>() { "animals" }, size = 1 }; animalName026 = new SimpleQuestion() { number = 26, questionName = "kangaroo", sprite = Resources.Load <Sprite>("Questions/Animals/Kangaroo"), answerOptions = new List <string>() { "kangaroo", "elephant", "bat", "eagle" }, tags = new List <string>() { "animals" }, size = 1 }; animalName027 = new SimpleQuestion() { number = 27, questionName = "panda", sprite = Resources.Load <Sprite>("Questions/Animals/Panda"), answerOptions = new List <string>() { "kangaroo", "panda", "bat", "eagle" }, tags = new List <string>() { "animals" }, size = 1 }; animalName028 = new SimpleQuestion() { number = 28, questionName = "penguin", sprite = Resources.Load <Sprite>("Questions/Animals/Penguin"), answerOptions = new List <string>() { "kangaroo", "panda", "bat", "penguin" }, tags = new List <string>() { "animals" }, size = 1 }; animalName029 = new SimpleQuestion() { number = 29, questionName = "sheep", sprite = Resources.Load <Sprite>("Questions/Animals/Sheep"), answerOptions = new List <string>() { "kangaroo", "panda", "bat", "sheep" }, tags = new List <string>() { "animals" }, size = 1 }; animalName030 = new SimpleQuestion() { number = 30, questionName = "snake", sprite = Resources.Load <Sprite>("Questions/Animals/Snake"), answerOptions = new List <string>() { "kangaroo", "panda", "snake", "penguin" }, tags = new List <string>() { "animals" }, size = 1 }; animalName031 = new SimpleQuestion() { number = 31, questionName = "swan", sprite = Resources.Load <Sprite>("Questions/Animals/Swan"), answerOptions = new List <string>() { "kangaroo", "panda", "swan", "sheep" }, tags = new List <string>() { "animals" }, size = 1 }; animalName032 = new SimpleQuestion() { number = 32, questionName = "tortoise", sprite = Resources.Load <Sprite>("Questions/Animals/Tortoise"), answerOptions = new List <string>() { "tortoise", "panda", "swan", "sheep" }, tags = new List <string>() { "animals" }, size = 1 }; }
public virtual int AddCourseInfo(IudicoCourseInfo courseInfo) { var db = this.GetDbContext(); CoursesInfo ci = new CoursesInfo { CourseId = courseInfo.Id, OverallMaxScore = (float)courseInfo.OverallMaxScore }; db.CoursesInfo.InsertOnSubmit(ci); db.SubmitChanges(); foreach (IudicoNodeInfo nodeInfo in courseInfo.NodesInfo) { NodesInfo ni = new NodesInfo { CourseId = courseInfo.Id, NodeId = nodeInfo.Id, MaxScore = (float)nodeInfo.MaxScore }; db.NodesInfo.InsertOnSubmit(ni); db.SubmitChanges(); foreach (IudicoQuestionInfo questionInfo in nodeInfo.QuestionsInfo) { QuestionsInfo qi = new QuestionsInfo { NodeId = nodeInfo.Id, Text = questionInfo.QuestionText, MaxScore = (float)questionInfo.MaxScore }; switch (questionInfo.Type) { case IudicoQuestionType.IudicoSimple: qi.Type = 1; break; case IudicoQuestionType.IudicoChoice: qi.Type = 2; break; case IudicoQuestionType.IudicoCompile: qi.Type = 3; break; } db.QuestionsInfo.InsertOnSubmit(qi); db.SubmitChanges(); switch (questionInfo.Type) { case IudicoQuestionType.IudicoSimple: SimpleQuestion sq = new SimpleQuestion { QuestionId = qi.Id, CorrectAnswer = (questionInfo as IudicoSimpleQuestion).CorrectAnswer }; db.SimpleQuestions.InsertOnSubmit(sq); db.SubmitChanges(); break; case IudicoQuestionType.IudicoChoice: ChoiceQuestionsCorrectChoice cqcc = new ChoiceQuestionsCorrectChoice { QuestionId = qi.Id, CorrectChoice = (questionInfo as IudicoChoiceQuestion).CorrectChoice }; db.ChoiceQuestionsCorrectChoices.InsertOnSubmit(cqcc); db.SubmitChanges(); foreach (var option in (questionInfo as IudicoChoiceQuestion).Options) { ChoiceQuestionsOption cqo = new ChoiceQuestionsOption { QuestionId = qi.Id, Option = option.Item1, Description = option.Item2 }; db.ChoiceQuestionsOptions.InsertOnSubmit(cqo); db.SubmitChanges(); } break; case IudicoQuestionType.IudicoCompile: for (int i = 0; i < (questionInfo as IudicoCompiledTest).NumberOfTests; ++i) { CompiledTestQuestion ctq = new CompiledTestQuestion { QuestionId = qi.Id, TestNumber = i, TestInput = (questionInfo as IudicoCompiledTest).TestInputs[i].Item2, TestOutput = (questionInfo as IudicoCompiledTest).TestOutputs[i].Item2 }; db.CompiledTestQuestions.InsertOnSubmit(ctq); db.SubmitChanges(); } break; } } } return(courseInfo.Id); }
void Start() { animalMaleName001 = new SimpleQuestion() { number = 1, questionName = "boar", sprite = null, answerOptions = new List <string>() { "badger", "guinea pig", "mole", "hedgehog" }, tags = new List <string>() { "animals" }, size = 1 }; animalMaleName002 = new SimpleQuestion() { number = 2, questionName = "buck", sprite = null, answerOptions = new List <string>() { "rabbit", "squirrel", "rat", "hare" }, tags = new List <string>() { "animals" }, size = 1 }; animalMaleName003 = new SimpleQuestion() { number = 1, questionName = "jack", sprite = null, answerOptions = new List <string>() { "hamster", "hare", "donkey", "weasel" }, tags = new List <string>() { "animals" }, size = 1 }; animalMaleName004 = new SimpleQuestion() { number = 1, questionName = "hen", sprite = null, answerOptions = new List <string>() { "salmon", "dove", "goose", "duck" }, tags = new List <string>() { "animals" }, size = 1 }; }
private void GetData(object path) { //numOfAnswer++ Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); SimpleQuestion qItem = null; // Define an object to pass to the API for missing parameters object miss = System.Reflection.Missing.Value; object readOnly = true; Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); int flag = 0; for (int i = 1; i <= docs.Paragraphs.Count; i++) { string temp = docs.Paragraphs[i].Range.Text.Trim(); if (temp.Trim().ToLower().Equals("<multi>")) { MultiQuestion qMul = new MultiQuestion(); do { temp = docs.Paragraphs[++i].Range.Text; if (temp.Trim() == "") { break; } qMul.content += temp + "\r\n"; } while (temp != string.Empty); if (temp.Trim() != "") { MessageBox.Show("Syntax error at \"" + qMul.content + "\"..."); lstSimple.Clear(); lstMulti.Clear(); return; } while (!temp.Trim().ToLower().Equals("</multi>")) { temp = docs.Paragraphs[++i].Range.Text.Trim(); if (temp != "") { qItem = new SimpleQuestion(); qItem.question = temp; qItem.correctAnswer = -1; List <string> answer = new List <string>(); do { temp = docs.Paragraphs[++i].Range.Text.Trim(); if (temp == string.Empty || temp.ToLower().Equals("</multi>")) { break; } temp = Regex.Replace(temp, "[a-z1-4](\\.|\\))[ \t]+", "", RegexOptions.IgnoreCase); if (temp.EndsWith("*")) { qItem.correctAnswer = answer.Count; temp = temp.Substring(0, temp.Length - 1).Trim(); answer.Add(temp); } else { answer.Add(temp); } } while (temp != string.Empty); qItem.answer = answer; if (qItem.correctAnswer != -1) { qMul.lstQuestion.Add(qItem); } else { MessageBox.Show("Question \"" + qItem.question + "\" have no correct answer"); lstSimple.Clear(); lstMulti.Clear(); return; } } else { MessageBox.Show("Syntax error at " + qMul.content + "\"..."); lstSimple.Clear(); lstMulti.Clear(); return; } } lstMulti.Add(qMul); //Ignore blank paragraph i++; } else if (temp != string.Empty) { if (flag % 2 == 0) { //remove question number like Câu 1, Câu 2,... temp = Regex.Replace(temp, "^[0-9]+\\.[ ]*|^Câu [0-9]+:[ ]*|^Question [0-9]+:[ ]*", "", RegexOptions.IgnoreCase); qItem = new SimpleQuestion(); qItem.question = temp; } else { List <string> answer = new List <string>(); qItem.correctAnswer = -1; while (temp != string.Empty) { //remove answer key, like A,B,C,D temp = Regex.Replace(temp, "[a-z1-4](\\.|\\))[ \t]+", "", RegexOptions.IgnoreCase); if (temp.EndsWith("*")) { qItem.correctAnswer = answer.Count; temp = temp.Substring(0, temp.Length - 1).Trim(); answer.Add(temp); } else { answer.Add(temp); } temp = docs.Paragraphs[++i].Range.Text.Trim(); } qItem.answer = answer; if (qItem.correctAnswer != -1) { lstSimple.Add(qItem); } else { MessageBox.Show("Question \"" + qItem.question + "\" have no correct answer"); lstSimple.Clear(); lstMulti.Clear(); return; } } flag++; } else { MessageBox.Show("Syntax error at " + lstSimple.ElementAt(lstSimple.Count - 1).question); lstSimple.Clear(); lstMulti.Clear(); return; } } docs.Close(); word.Quit(); BindSimpleQuestion(lstSimple); BindMultiQuestion(lstMulti); }
void Start() { // sprites dogSprite = Resources.Load <Sprite>("Questions/Animals/Dog"); horseSprite = Resources.Load <Sprite>("Questions/Animals/Horse"); catSprite = Resources.Load <Sprite>("Questions/Animals/Cat"); rabbitSprite = Resources.Load <Sprite>("Questions/Animals/Rabbit"); frogSprite = Resources.Load <Sprite>("Questions/Animals/Frog"); lionSprite = Resources.Load <Sprite>("Questions/Animals/Lion"); tigerSprite = Resources.Load <Sprite>("Questions/Animals/Tiger"); zebraSprite = Resources.Load <Sprite>("Questions/Animals/Zebra"); elephantSprite = Resources.Load <Sprite>("Questions/Animals/Elephant"); monkeySprite = Resources.Load <Sprite>("Questions/Animals/Monkey"); chickenSprite = Resources.Load <Sprite>("Questions/Animals/Chicken"); parrotSprite = Resources.Load <Sprite>("Questions/Animals/Parrot"); cowSprite = Resources.Load <Sprite>("Questions/Animals/Cow"); mouseSprite = Resources.Load <Sprite>("Questions/Animals/Mouse"); dolphinSprite = Resources.Load <Sprite>("Questions/Animals/Dolphin"); animalFood001 = new SimpleQuestion() { number = 1, questionName = "carrots", fairyTalk = "Who likes carrots?", answer = null, answerList = new List <string>() { "horse", "rabbit" }, answerOptionsSprites = new List <Sprite>() { dogSprite, horseSprite, catSprite, rabbitSprite }, answerOptions = new List <string>() { "dog", "horse", "cat", "rabbit" }, tags = new List <string>() { "animals", "food" }, size = 1 }; animalFood002 = new SimpleQuestion() { number = 2, questionName = "meat", fairyTalk = "Who eats meat?", answer = null, answerList = new List <string>() { "tiger", "lion" }, answerOptionsSprites = new List <Sprite>() { frogSprite, lionSprite, rabbitSprite, tigerSprite }, answerOptions = new List <string>() { "frog", "lion", "rabbit", "tiger" }, tags = new List <string>() { "animals", "food" }, size = 1 }; animalFood003 = new SimpleQuestion() { number = 3, questionName = "cheese", fairyTalk = "Who eats cheese?", answer = "mouse", answerOptionsSprites = new List <Sprite>() { mouseSprite, dolphinSprite, catSprite, parrotSprite }, answerOptions = new List <string>() { "mouse", "dolphin", "cat", "parrot" }, tags = new List <string>() { "animals", "food" }, size = 1 }; animalFood004 = new SimpleQuestion() { number = 4, questionName = "grass", fairyTalk = "Who eats grass?", answer = null, answerList = new List <string>() { "cow", "zebra" }, answerOptionsSprites = new List <Sprite>() { zebraSprite, parrotSprite, cowSprite, dogSprite }, answerOptions = new List <string>() { "zebra", "parrot", "cow", "dog" }, tags = new List <string>() { "animals", "food" }, size = 1 }; animalFood005 = new SimpleQuestion() { number = 5, questionName = "banana", fairyTalk = "Who eats bananas?", answer = "monkey", answerOptionsSprites = new List <Sprite>() { elephantSprite, chickenSprite, mouseSprite, monkeySprite }, answerOptions = new List <string>() { "elephant", "chicken", "mouse", "monkey" }, tags = new List <string>() { "animals", "food" }, size = 1 }; animalFood006 = new SimpleQuestion() { number = 6, questionName = "bone", fairyTalk = "Who eats bones?", answer = "dog", answerOptionsSprites = new List <Sprite>() { lionSprite, dogSprite, mouseSprite, monkeySprite }, answerOptions = new List <string>() { "lion", "dog", "mouse", "monkey" }, tags = new List <string>() { "animals", "food" }, size = 1 }; animalFood007 = new SimpleQuestion() { number = 7, questionName = "fish", fairyTalk = "Who eats fish?", answer = "dolphin", answerOptionsSprites = new List <Sprite>() { lionSprite, dolphinSprite, mouseSprite, monkeySprite }, answerOptions = new List <string>() { "lion", "dolphin", "mouse", "monkey" }, tags = new List <string>() { "animals", "food" }, size = 1 }; }