コード例 #1
0
        public static string GetQuestionHotspotAsCSV(Question q)
        {
            string csv = "";

            // name - code
            csv += "\"" + q.name + "\"" + ",";

            // questionText - body
            csv += "\"" + q.text + "\"" + ",";

            csv += "\"" + q.data + "\"" + ",";

            // answer options
            for (int i = 0; i < 10; i++)
            {
                csv += ",";
            }

            csv += "Open,L1,";

            // category - question_category_code
            csv += "\"" + q.category + "\"" + ",";

            //string feedback_right = "";
            //string feedback_wrong = "";

            String[] fb = QuestionLib.ParseFeedbacks(q);

            string images = "";

            for (int j = 0; j < q.images.Count; j++)
            {
                if (images != String.Empty)
                {
                    images += ";";
                }
                images += q.images[j].name;
            }

            csv += "\"" + images + "\"" + ",n," + "\"" + fb[0] + "\"" + "," + "\"" + fb[1] + "\"";

            return(csv);
        }
コード例 #2
0
        public static string GetQuestionMResponseAsCSV(Question q)
        {
            string csv = "";

            if ((q.type == "multichoice" || q.type == "Multiple Choice" || q.type == "multichoiceset") == false)
            {
                return("");
            }

            // name - code
            csv += "\"" + q.name + "\"" + ",";

            // questionText - body
            csv += "\"" + q.text + "\"" + ",";

            // answer options
            for (int i = 0; i < 10; i++)
            {
                if (i < q.options.Count)
                {
                    csv += "\"" + q.options[i].text + "\"" + ",";
                    if (q.options[i].grade <= 0)
                    {
                        csv += "FALSE,";
                    }
                    else
                    {
                        csv += "TRUE,";
                    }
                }
                else
                {
                    csv += "\"\",\"\",";
                }
            }

            csv += "Open,L1,";

            // category - question_category_code
            csv += "\"" + q.category + "\"" + ",";

            csv += "\"\",\"\"";

            // feedback
            String[] fb = QuestionLib.ParseFeedbacks(q);
            csv += ",\"" + fb[0] + "\"";
            csv += ",\"" + fb[1] + "\"";
            //csv += ",\"" + q.generalfeedback + "\"";
            //csv += ",\"" + q.partiallycorrectfeedback + "\"";

            for (int i = 1; i <= 10; i++)
            {
                string optionFeedback = "";
                if (i <= q.options.Count)
                {
                    optionFeedback = q.options[i - 1].feedback;
                }
                csv += ",\"" + optionFeedback + "\"";
            }

            return(csv);
        }
コード例 #3
0
        public static string GetQuestionAsCSV(Question q)
        {
            string csv = "";

            if ((q.type == "multichoice" || q.type == "truefalse" || q.type == "Multiple Choice" || q.type == "cloze") == false)
            {
                return("");
            }

            //TODO - this is duplicated in GetCSVText
            List <string> errors = QuestionLib.CheckQuestion(q);

            if (errors.Count > 0)
            {
                return("");
            }

            // name - code
            csv += "\"" + q.name + "\"" + ",";

            // questionText - body
            csv += "\"" + q.text + "\"" + ",";

            // correct_choice
            int correct_choice = 1;

            for (int i = 0; i < q.options.Count; i++)
            {
                if (q.options[i].grade == 100)
                {
                    correct_choice = i + 1;
                }
            }
            csv += "choice_" + correct_choice.ToString() + ",";

            // answer options
            for (int i = 0; i < 10; i++)
            {
                if (i < q.options.Count)
                {
                    csv += "\"" + q.options[i].text + "\"" + ",";
                }
                else
                {
                    csv += ",";
                }
            }

            csv += "Open,L1,";

            // category - question_category_code
            csv += "\"" + q.category + "\"" + ",";


            string images = "";

            for (int j = 0; j < q.images.Count; j++)
            {
                if (images != String.Empty)
                {
                    images += ";";
                }
                images += q.images[j].name;
            }

            // process feedback
            String[] fb = QuestionLib.ParseFeedbacks(q);

            csv += "\"" + images + "\"" + ",n," + "\"" + fb[0] + "\"" + "," + "\"" + fb[1] + "\"";

            //csv += "\"" + images + "\"" + ",n," + "\"" + q.correctfeedback + "\"" + "," + "\"" + q.incorrectfeedback + "\"";
            //csv += ",\"" + q.generalfeedback + "\"";
            //csv += ",\"" + q.partiallycorrectfeedback + "\"";

            for (int i = 1; i <= 10; i++)
            {
                string optionFeedback = "";
                if (i <= q.options.Count)
                {
                    optionFeedback = q.options[i - 1].feedback;
                }
                csv += ",\"" + optionFeedback + "\"";
            }


            return(csv);
        }