Ejemplo n.º 1
0
        public static void CreateQuestionResponseFiles_v2(IEnumerable <QuestionResponseData_v2> questionResponses, string directory)
        {
            directory = GetQuestionsDirectory(directory);
            zdir.CreateDirectory(directory);
            int index = 1;

            foreach (QuestionResponseData_v2 questionResponse in questionResponses)
            {
                QuestionResponseHtml questionResponseHtml = new QuestionResponseHtml();
                questionResponseHtml.Year         = questionResponse.Question.Year;
                questionResponseHtml.Type         = questionResponse.Question.Type;
                questionResponseHtml.Number       = questionResponse.Question.QuestionNumber;
                questionResponseHtml.QuestionText = questionResponse.Question.QuestionText;
                // newLine: true
                questionResponseHtml.QuestionHtml = questionResponse.GetHtml(questionNumber: false, questionDiv: false, response: false, newLine: false, replaceSpecialCharacters: true);
                questionResponseHtml.Choices      = questionResponse.Question.Choices;
                questionResponseHtml.Responses    = questionResponse.Response?.Responses;
                questionResponseHtml.SourceFile   = questionResponse.Question.SourceFile;
                questionResponseHtml.SourceLine   = questionResponse.Question.SourceLine;

                string file = zPath.Combine(directory, $"question-{index:00}-{questionResponseHtml.Year:0000}-{questionResponseHtml.Number:000}.json");
                questionResponseHtml.zSave(file, jsonIndent: true);
                index++;
            }
        }
Ejemplo n.º 2
0
        // directory is pdf directory
        public static void SaveQuestion(string directory, string file, string questionHtml, bool trace = false)
        {
            QuestionResponseHtml question = LoadQuestion(directory, file);

            question.QuestionHtml = questionHtml;
            // zPath.Combine(directory, "data", file)
            file = GetLastFileNumber(zPath.Combine(GetQuestionsDirectory(directory), file), saveFile: true);
            if (trace)
            {
                Trace.WriteLine($"SaveQuestion() : file \"{file}\"");
            }
            question.zSave(file, jsonIndent: true);
        }