public void HandleOpenQuestion(OpenWFileQuestion question, Dictionary <int, Word.Document> mapIdDocuments, Word.Application wordApplication) { int index = question.Index; string emptyFilePath = question.EmptyFilePath; if (wordApplication != null && wordApplication.Documents != null) { // if not open yet if (!mapIdDocuments.ContainsKey(index)) { var doc = wordApplication.Documents.Open(emptyFilePath); mapIdDocuments.Add(index, doc); } else { wordApplication.Activate(); mapIdDocuments[index].Activate(); } } FitIntoArea(wordApplication); }
/// <summary> /// @Hoang implement here, consider to define new Question type (extend AbstractQuestion) /// maybe need more params, you can add new by yourself /// </summary> /// <param name="type_l2"></param> /// <returns></returns> public IQAPair Convert(int id, string raw_content, string html_content, string markdown_content, int type_l2, string question_file, string answer_file, string description, int index, string workspace) { IQuestion question = null; IAnswer answer = null; IAnswer correctAnswer = new ABIAnswer(); switch (type_l2) { case 1: case 2: case 3: case 22: question = new OpenWFileQuestion(); answer = new OpenWFileAnswer(); ((OpenWFileQuestion)question).EmptyFilePath = Path.Combine(workspace, "empty.docx"); break; case 24: question = new CloseWFileQuestion(); answer = new CloseWFileAnswer(); break; case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: question = new CompareWFileQuestion(); answer = new CompareWFileAnswer(); if (answer_file != null) { ((ABIAnswer)correctAnswer).File = new WordFile(Path.Combine(workspace, answer_file)); } break; } if (question_file != null) { question.File = new WordFile(Path.Combine(workspace, question_file)); } if (question != null) { question.Index = index; question.HtmlContent = html_content; question.RawContent = raw_content; question.MarkdownContent = markdown_content; question.Description = description; question.Type_l2 = type_l2; if (question is OpenWFileQuestion) { if (question.HtmlContent != null) { ((OpenWFileQuestion)question).HtmlContent += ": <b>" + Path.Combine(workspace, question_file) + "</b>"; } if (question.MarkdownContent != null) { ((OpenWFileQuestion)question).MarkdownContent += ": **" + Path.Combine(workspace, question_file) + "**"; } } } return(new ABIQAPair(question, answer, correctAnswer)); }