如何将照片和视频添加到JSON测验格式?

时间:2016-04-06 13:28:56

标签: javascript jquery json

我正在整理一个带有JSON,jQuery和JavaScript的测验。

这是我在JSON中的问题:

"questions": [
        {             "q": "At a birthday party you counted 120 eyes. How many people were at the party?",
            "a": [
                {"option": "240",      "correct": false},
                {"option": "60",     "correct": true},
                {"option": "120",      "correct": false},
                {"option": "30",     "correct": false} // no comma here
            ], 

如何在问题中添加图像。这是正确的语法吗?

I have a folder called img
“q”: "At a birthday party you counted 120 eyes. How many people were at the party? <br> <br>"  + 

"<i** src="/i**/eyes.filename\">,   ** denotes mg read: image source 

另外,如何在YouTube中有链接的问题中嵌入视频文件?

1 个答案:

答案 0 :(得分:-2)

想出来。 这就是你嵌入视频的方式:

{ 
        "q": "How would you weigh on the moon compared to earth?",
        "a": [
            {"option": "More",    "correct": false},
            {"option": "The same",     "correct": false}, 
            {"option": "Less",     "correct": true}, 
            {"option": "Need more info",     "correct": false} // no comma here
        ],
        "correct": "<p><span>Good Job!</span> Eat your cheesy pizza, fries, nachos, and fly to the moon to be a size zero or watch this video <br> <center> <iframe width=560 height=315 src=https://www.youtube.com/embed/OIzOCvxJcSE frameborder=0 allowfullscreen></iframe> </center> </p>",
        "incorrect": "<p><span>ERRRR!</span> Weight is determined by gravity, or how strongly gravity pulls on matter. Since the gravity on moon is weak compared to earth, you will weigh less.<br>Ready for a physics class? <center><iframe width=560 height=315 src=https://www.youtube.com/embed/OIzOCvxJcSE frameborder=0 allowfullscreen></iframe> </center> </p>" // no comma here
    } 

这是你在json中添加图片的方式:

{ 
            "q": "What is the amount of matter in an object called? <br> <img src=https://cdn.vectorstock.com/i/composite/08,88/question-weighing-scale-vector-840888.jpg/>",
            "a": [
                {"option": "Weight",               "correct": false},
                {"option": "Density",   "correct": false},
                {"option": "Volume",               "correct": false},
                {"option": "Mass", "correct": true} // no comma here
            ],
            //Make it select any rather than all.
            "correct": "<p><span>Correct!</span> You like fancy words don't you?</p>",
            "incorrect": "<p><span>Fail.</span> Sorry. You need to brush up on your physics vocabulary. Weight is a measure of how strongly gravity pulls on that matter. Density describes how compact or concentrated something is, expressed as mass per unit volume. Volume is Volume is the amount of space that comprises a length, a width and a height, occupied by an object or a material.</p>" 
        }