0

Im trying to display questions and have multiple choice using SurveyJS and among the choices is this character \?. How can I display \? in vueJS? It outputs error:

error: Unnecessary escape character: \?

Here is my code:

<template>
    <div id="surveyElement" style="display:inline-block;width:100%;">
        <survey :survey='survey'/>
    </div>
</template>

<script>
import * as SurveyVue from "survey-vue";
// import * as showdown from 'vue-showdown'
import "bootstrap/dist/css/bootstrap.css";
var Survey = SurveyVue.Survey;
Survey.cssType = "bootstrap";
export default {
    components:{
        Survey
    },
    data(){
        var json = {
            title: "Chapter 7 - Quiz",
            showProgressBar: "bottom",
            showTimerPanel: "top",
            maxTimeToFinishPage: 10,
            maxTimeToFinish: 100,
            firstPageIsStarted: true,
            startSurveyText: "Start Quiz",
            pages: [
                {
                    questions: [
                        {
                            type: "html",
                            html: "You are about to start quiz in chapter 7. <br/>You have 10 seconds for every number and 100 seconds for the whole quiz of 10 questions.<br/>Please click on <b>'Start Quiz'</b> button when you are ready."
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.1",
                            title: "A function used to input a single character from the keyboard.",
                            choicesOrder: "random",
                            choices: [
                                "getche", "getch", "char", "gets"
                            ],
                            correctAnswer: "getch"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.2",
                            title: "A function used to display the argument list on the monitor.",
                            choicesOrder: "random",
                            choices: [
                                "printf", "getchar", "char", "gets"
                            ],
                            correctAnswer: "printf"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.3",
                            title: "It is used to print a question mark.",
                            choicesOrder: "random",
                            choices: [
                                "%u", "\?", "%s", "%%"
                            ],
                            correctAnswer: "\?"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.4",
                            title: "A function used to input single character or sequence of characters from the keyboard.",
                            choicesOrder: "random",
                            choices: [
                                "printf", "getchar", "puts", "scanf"
                            ],
                            correctAnswer: "scanf"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.5",
                            title: "It is used to print backslash.",
                            choicesOrder: "random",
                            choices: [
                                "%u", "\?", "\\", "//"
                            ],
                            correctAnswer: "\\"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.6",
                            title: "A function used to display the argument list or string on the monitor. It is like overwriting a character",
                            choicesOrder: "random",
                            choices: [
                                "printf", "getchar", "putchar", "scanf"
                            ],
                            correctAnswer: "putchar"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.7",
                            title: "A statement used to display the argument list or string on the monitor",
                            choicesOrder: "random",
                            choices: [
                                "Output Statement", "Input Statement", "putchar","scanf"
                            ],
                            correctAnswer: "Output Statement"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.8",
                            title: "A function used to display the argument list or string on the monitor. It does not need the help of the control string codes",
                            choicesOrder: "random",
                            choices: [
                                "printf", "getchar", "puts", "scanf"
                            ],
                            correctAnswer: "puts"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.9",
                            title: "A statement used to input a single character or a sequence of characters from the keyboard",
                            choicesOrder: "random",
                            choices: [
                                "Output Statement", "Input Statement", "putchar", "scanf"
                            ],
                            correctAnswer: "Input Statement"
                        }
                    ]
                }, {
                    questions: [
                        {
                            type: "radiogroup",
                            name: "chapter 7.10",
                            title: "A function used to input a single character from the keyboard, the character pressed echoed on the monitor, like the READLN in PASCAL",
                            choicesOrder: "random",
                            choices: [
                                "getche", "getch", "char", "gets"
                            ],
                            correctAnswer: "getche"
                        }
                    ]
                }, 
            ],
            completedHtml: "<h4>You have answered correctly <b>{correctedAnswers}</b> questions from <b>{questionCount}</b>.</h4>"
        };
        var model = new SurveyVue.Model(json);
        model
            .onComplete
            .add(function (result) {
                document
                    .querySelector('#surveyResult')
                    .textContent = "Result JSON:\n" + JSON.stringify(result.data, null, 3);
            });
        // var converter = new showdown.Converter();
        // model
        //     .onTextMarkdown
        //     .add(function (survey, options) {
        //         //convert the mardown text to html
        //         var str = converter.makeHtml(options.text);
        //         //remove root paragraphs <p></p>
        //         str = str.substring(3);
        //         str = str.substring(0, str.length - 4);
        //         //set html
        //         options.html = str;
        //     });
        return {
        survey: model
        };
    }
}
</script>

Please help, it would be greatly appreciated

deceze
  • 510,633
  • 85
  • 743
  • 889

0 Answers0