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

How to add photo and video to JSON quiz format?

本文关键字:JSON 测试 格式 添加 视频 照片      更新时间:2024-01-22

我正在用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上有链接的问题中嵌入视频文件?

想明白了。这就是嵌入视频的方式:

{ 
        "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>" 
        }