Semantics

Warning: This is probably a retarded question. Leave now if you can't handle noobs.

I downloaded the single choice set. I am now looking at the code. This code is from the H5P.SingleChoiceSet-1.4/semantics.json

      "fields": [
        {
          "name": "question",
          "type": "text",
          "widget": "html",
          "tags": ["p", "br", "strong", "em"],
          "label": "Question"
        },

If I change the type from "text" to "image", and get rid of widget and tags, is that the only thing that I have to do to add images instead of text? It can't be this simple right?

fnoks's picture

There is no such thing as a retarded question - only retarded answers ;)

In your example, if you change type from text to image, the editor will create an image widget, so you can upload an image. The problem is that the JavaScript code assumes text is what is coming in, and will therefore not handle this very well. Conclusion: in your case, the JavaScript code also needs to be changed.

Thanks. I appreciate it. Okay, so I changed the code to the following:

        {
          "name": "question",
          "type": "image",
          "label": "Question"
        },

What file do I change next so that the JavaScript code assumes that an image is coming?

fnoks's picture

Hi,

You could look at how this is done in the JavaScript-files in other content types displaying images. I see you have been looking at the Greeting card tutorial - that's a good start :)

I checked the other content types but it is very overwhelming. I think I need to see a barebones basic library that handles each file type.

fnoks's picture

Have you looked at H5P.GreetingCard? It contains one textfield and one image in semantics.json.

Yes. I checked it out