protected override bool SaveAs(string name)
        {
            StringBuilder output = new StringBuilder("{\"content\":[{");

            for (int i = 0, end = Count; i < end; ++i)
            {
                WorstResponse wd = this[i];
                output.Append("\"x\":false,\"id\":").Append(wd.ID);
                if (string.IsNullOrWhiteSpace(wd.Question))
                {
                    ResponseIssue(string.Format("No question given for response ID {0}.", wd.ID));
                    return(false);
                }
                output.Append(",\"category\":\"").Append(Parsing.MakeTextCompatible(wd.Question)).Append("\",\"bumper\":\"\"}");
                if (i != end - 1)
                {
                    output.Append(",{");
                }
                else
                {
                    output.Append("],\"episodeid\":1242}");
                }
            }
            File.WriteAllText(name, output.ToString());
            return(true);
        }
예제 #2
0
        protected override bool SaveAs(string name)
        {
            StringBuilder output = new StringBuilder("{\"content\":[{");

            for (int i = 0, end = Count; i < end; ++i)
            {
                WorstDrawing wd = this[i];
                output.Append("\"x\":false,\"id\":").Append(wd.ID);
                if (string.IsNullOrWhiteSpace(wd.Category))
                {
                    DrawingIssue(string.Format("No category given for drawing ID {0}.", wd.ID));
                    return(false);
                }
                output.Append(",\"category\":\"").Append(Parsing.MakeTextCompatible(wd.Category));
                if (i != end - 1)
                {
                    output.Append("\"},{");
                }
                else
                {
                    output.Append("\"}],\"episodeid\":1258}");
                }
            }
            File.WriteAllText(name, output.ToString());
            return(true);
        }
예제 #3
0
        protected override bool SaveAs(string name)
        {
            StringBuilder output = new StringBuilder("{\"episodeid\":1244,\"content\":[");

            for (int i = 0, end = Count; i < end; ++i)
            {
                Question q = this[i];
                output.Append("{\"x\":false,\"id\":").Append(q.ID);
                if (string.IsNullOrWhiteSpace(q.Text))
                {
                    QuestionIssue(string.Format("No text given for question ID {0}.", q.ID));
                    return(false);
                }
                output.Append(",\"text\":\"").Append(Parsing.MakeTextCompatible(q.Text)).Append("\",\"pic\": false,\"choices\":[");
                if (q.Correct < 1 || q.Correct > 4)
                {
                    QuestionIssue(string.Format("No correct answer set for question \"{0}\".", q.Text));
                    return(false);
                }
                for (int answer = 1; answer <= 4; ++answer)
                {
                    if (answer != 1)
                    {
                        output.Append("},{");
                    }
                    else
                    {
                        output.Append("{");
                    }
                    if (answer == q.Correct)
                    {
                        output.Append("\"correct\":true,");
                    }
                    if (string.IsNullOrWhiteSpace(q[answer]))
                    {
                        QuestionIssue(string.Format("No answer {0} for question \"{1}\".", answer, q.Text));
                        return(false);
                    }
                    output.Append("\"text\":\"").Append(Parsing.MakeTextCompatible(q[answer])).Append("\"");
                }
                if (i != end - 1)
                {
                    output.Append("}]},");
                }
                else
                {
                    output.Append("}]}]}");
                }
            }
            File.WriteAllText(name, output.ToString());
            return(true);
        }
예제 #4
0
        protected override bool SaveAs(string name)
        {
            StringBuilder output = new StringBuilder("{\"episodeid\":1253,\"content\":[");

            for (int i = 0, end = Count; i < end; ++i)
            {
                FinalRounder q = this[i];
                output.Append("{\"x\":false,\"id\":").Append(q.ID);
                if (string.IsNullOrWhiteSpace(q.Text))
                {
                    FinalRoundIssue(string.Format("No text given for topic ID {0}.", q.ID));
                    return(false);
                }
                output.Append(",\"text\":\"").Append(Parsing.MakeTextCompatible(q.Text)).Append("\",\"pic\": false,\"choices\":[");
                for (int choice = 0, choices = this[i].Items.Count; choice < choices; ++choice)
                {
                    FinalRounderChoice item = (FinalRounderChoice)this[i].Items[choice];
                    if (choice != 0)
                    {
                        output.Append("},{");
                    }
                    else
                    {
                        output.Append("{");
                    }
                    if (item.Correct)
                    {
                        output.Append("\"correct\":true,");
                    }
                    else
                    {
                        output.Append("\"correct\":false,");
                    }
                    if (string.IsNullOrEmpty(item.Text))
                    {
                        FinalRoundIssue(string.Format("Choice without text found for topic \"{0}\".", q.Text));
                        return(false);
                    }
                    output.Append("\"text\":\"").Append(Parsing.MakeTextCompatible(item.Text)).Append("\"");
                }
                if (i != end - 1)
                {
                    output.Append("}]},");
                }
                else
                {
                    output.Append("}]}]}");
                }
            }
            File.WriteAllText(name, output.ToString());
            return(true);
        }