Example #1
0
        private void ProcessFile(string sourceFile)
        {
            ClearText();

            ShowOutput("Processing file " + sourceFile);

            // detect file format
            ShowOutput("Detecting file format....", false);
            string fileFormat = QuestionLib.GetFileFormat(sourceFile);

            ShowOutput(fileFormat);

            // get questions
            ShowOutput("Getting questions....", false);

            List <Question> questions = QuestionLib.GetQuestions(sourceFile);

            ShowOutput(questions.Count.ToString() + " questions found.");

            // look for questions with new feedback, cloze and multichoiceset
            List <Question> qNewFeedback = QuestionLib.GetQuestionsWithNewFeedback(questions);

            ShowOutput("Questions with new feedback: " + qNewFeedback.Count.ToString());


            // show questions in tab
            foreach (Question q in questions)
            {
                txtQuestions.AppendText(q.GetDebug() + Environment.NewLine + Environment.NewLine);
            }

            // check questions
            ShowOutput("Checking for errors....", false);
            List <string> errorList = QuestionLib.CheckQuestions(questions);

            ShowOutput(errorList.Count.ToString() + " errors found.");

            txtErrors.Text = "";

            if (errorList.Count > 0)
            {
                txtErrors.AppendText(Environment.NewLine + errorList.Count.ToString() + " errors in " + sourceFile + Environment.NewLine);
            }

            foreach (string e in errorList)
            {
                txtErrors.AppendText(e + Environment.NewLine);
            }



            // create output (Pelesys CSV)
            string        csvFilename = Path.Combine(CFG.outputDir, JwCSV.GetFileName(sourceFile));
            List <string> result      = Pelesys.CreateOutput(csvFilename, questions);

            for (int i = 0; i < result.Count; i++)
            {
                ShowOutput(result[i]);
            }


            // check output files
            ShowOutput("Checking CSV file....", false);
            List <string> errors = Pelesys.CheckFile(csvFilename);

            if (errors.Count == 0)
            {
                ShowOutput("OK");
            }
            else
            {
                ShowOutput(errors.Count.ToString() + " errors found. See Errors tab.");
                txtErrors.AppendText(Environment.NewLine + errors.Count.ToString() + " errors in " + csvFilename + Environment.NewLine);

                foreach (string e in errors)
                {
                    txtErrors.AppendText(e + Environment.NewLine);
                }
            }

            ShowMessage("Done. " + errors.Count.ToString() + " errors in output file.");
        }
Example #2
0
        private void getQuestionsInFile(string sourceFile)
        {
            ClearText();

            ShowOutput("Processing file " + sourceFile);

            // detect file format
            ShowOutput("Detecting file format....", false);
            string fileFormat = QuestionLib.GetFileFormat(sourceFile);

            ShowOutput(fileFormat);

            // get questions
            ShowOutput("Getting questions....", false);
            List <Question> questions = QuestionLib.GetQuestions(sourceFile);

            ShowOutput(questions.Count.ToString() + " questions found.");

            foreach (Question q in questions)
            {
                txtQuestions.AppendText(q.GetDebug() + Environment.NewLine + Environment.NewLine);
            }


            // check questions
            ShowOutput("Checking for errors....", false);
            List <string> errorList = QuestionLib.CheckQuestions(questions);

            ShowOutput(errorList.Count.ToString() + " errors found.");

            txtErrors.Text = "";

            if (errorList.Count > 0)
            {
                txtErrors.AppendText(Environment.NewLine + errorList.Count.ToString() + " errors in " + sourceFile + Environment.NewLine);
            }

            foreach (string e in errorList)
            {
                txtErrors.AppendText(e + Environment.NewLine);
            }


            // look for questions with embedded images
            ShowOutput("Looking for questions with images....", false);
            List <Question> withImages = QuestionLib.GetQuestionListWithImages(questions);

            ShowOutput(withImages.Count.ToString() + " found.");



            // look for questions with new feedback, cloze and multichoiceset
            List <Question> qNewFeedback = QuestionLib.GetQuestionsWithNewFeedback(questions);

            ShowOutput("Questions with new feedback: " + qNewFeedback.Count.ToString());



            // finished
            ShowMessage("Done. " + questions.Count.ToString() + " questions found.");
        }