Length of the General Comment
Submitted by Usapuka on Thu, 10/01/2020 - 21:47
Forums:
Hi,
In the Multiple Choice Question, within a Questions Set: how can I make the General Comment (at the end of each question) has more than 255 characters long?
Thanks!
Content types:
otacke
Fri, 10/02/2020 - 08:38
Permalink
Hi Usapuka!Either the H5P
Hi Usapuka!
Either the H5P core team is fine with having longer general comments and someone contributes the code changes (very minimal), or you use the customization functions that the H5P plugin offers ("alter_semantics") to set the field to a larger value, see https://h5p.org/documentation/for-developers/authoring-tool-customization - but I fear at least some basic knowledge of PHP will be required to do that. Downside here: If you share the files, others won't see the comment in full length unless they applied the same customization that you used.
Best,
Oliver
Usapuka
Mon, 10/05/2020 - 00:59
Permalink
How to implement the "alter_semantics"?
Hello Oliver,
Thanks for your help, as I am working on WordPress I have installed the Plugin (h5pmods) and made some Visual Changes. The newbies guide has been very helpful for this.
Is there a newbies guide to implement the "alter_semantics"? With Chrome's development tools it is very easy to find the CSS modifications, but in order to increase the number of characters of the General Comment: where is the information of the semantics to be modified and the necessary steps to do it?
Thanks again,
Best
Gabriel
otacke
Mon, 10/05/2020 - 06:37
Permalink
Hi Gabriel!I don't think
Hi Gabriel!
I don't think there's something tutorial-ish, but you can find similar examples in the thread at https://h5p.org/node/188086. You basically need to retrieve the field for the comment inside semantics.json (that follows the specification at https://h5p.org/semantics), and you'd have to set the max attribute for that field.
Best,
Oliver
Usapuka
Mon, 10/05/2020 - 18:35
Permalink
Hi Oliver,Thanks again for
Hi Oliver,
Thanks again for your help. I think I understand the logic of what I should do. I have studied the semantics of Question Set (https://github.com/h5p/h5p-question-set/blob/master/semantics.json). So I see that in the case of the General Comment, it goes into a "placeholder" that must be limiting the amount to 255 characters. This does not happen in the case that the feedback goes after any answer (see attached).
Since in one case or another the number of characters is not specified in the semantics of the Question Set, what should I modify and where to increase the number of characters in the General Comment?
Thank you.
Best
Gabriel
otacke
Mon, 10/05/2020 - 19:35
Permalink
Hi Gabriel!H5P uses a modular
Hi Gabriel!
H5P uses a modular approach: Content types can include other content types. For instance, Question Set is just a wrapper for Multiple Choice, Fill-in-the-Blanks, etc. (https://github.com/h5p/h5p-question-set/blob/master/semantics.json#L126-L132) I believe you want to and should alter the semantics of Multiple Choice. You could simply use the $library_name variable as a switch for customizing particular semantics files of particular content types.
Best,
Oliver
Usapuka
Mon, 10/05/2020 - 20:22
Permalink
Hi Oliver,I'm sorry but this
Hi Oliver,
I'm sorry but this time I don't understand your answer and what I should do.
The General Comment semantics for the Question Set are here https://github.com/h5p/h5p-question-set/blob/5fa83227f9e58905271ee74247a... and not in the Multiple Choice semantics.
Please be so kind as to explain to me what you mean by that? "You could simply use the $library_name variable as a switch for customizing particular semantics files of particular content types".
Best
Gabriel
otacke
Mon, 10/05/2020 - 22:12
Permalink
Hi Gabriel!The image that you
Hi Gabriel!
The image that you attached didn't show the general feedback of Question Set, but the specific feedback to answers that you can set in Multiple Choice, see https://github.com/h5p/h5p-multi-choice/blob/master/semantics.json#L115-L148.
In the code examples at https://h5p.org/node/188086 you can see how $library_name is used to determine what library is currently loaded (the hook will be called for all of them) to decide whether you want to override the semantics or not. A switch could be something like:
If you prefer, you could use the switch function, too, hence the name switch.
Cheers,
Oliver
Usapuka
Tue, 10/06/2020 - 18:03
Permalink
Hi Oliver,I'm sorry, I still
Hi Oliver,
I'm sorry, I still don't understand the point of what I'm supposed to do, I'm a newbie at this.
My need is to increase the number of characters to more than 255 characters of the General Comment. For this you indicated me that I should modify the Semantics. I assumed that I would get to a place where I would see the definition that limits the number of characters to 255 and could change it to a higher number.
Is my reasoning correct? How does what you are telling me to do relate to increasing the number of characters?
Thank you for your help,
Best
Gabriel
otacke
Tue, 10/06/2020 - 19:39
Permalink
Hi Gabriel!Sorry, I can
Hi Gabriel!
Sorry, I can neither write the whole script for you nor introduce you to coding in PHP. I used to do that before, but I learned that I a cannot be responsible for solving everyone's problems.
The steps would be:
A) Be sure what you want to override. You say you want to override the overall feedback of Question Set, but the image that you attached before showed the per answer feedback of Multple Choice.
B) Locate the appropriate field in semantics. For the overall feedback of Question Set it's feedback (https://github.com/h5p/h5p-question-set/blob/master/semantics.json#L341-L348). For the per answer feedback of Multiple Choice it's chosenFeedback or notChosenFeedback (https://github.com/h5p/h5p-multi-choice/blob/master/semantics.json#L115-L147). Mind the hierarchy those fields are put in.
C) Set up a very basic alter_semantics hook as a customization for your platform, see https://h5p.org/node/2692. As a reference for coding, you can use the examples depicted at https://h5p.org/comment/18767#comment-18767 or https://h5p.org/comment/18898#comment-18898. Try to understand what they are doing. The latter tries to explain how the hierarchy of semantics works.
D) Implement your changes: You need to
Side note: If you in fact want to override the maxLength of the per answer feedback of Multiple Choice, then that's not possible as I just noticed in the specification. Those field have use the HTML widget which does not support the maxLength property.
Best,
Oliver
Usapuka
Wed, 10/07/2020 - 00:18
Permalink
Hi Oliver,Thank you for your
Hi Oliver,
Thank you for your patience and help. I think I'm understanding.
In the two examples that you indicated me, the value of the attribute to be modified is specified in the semantics and the default value is changed.
In the case of the "feedback" where the "type": "text": how may I change an attribute that is defined by default (or in another place) in 255 ? (see attachment).
Best
Gabriel
otacke
Wed, 10/07/2020 - 01:51
Permalink
Hi Gabriel!You're welcome
Hi Gabriel!
You're welcome!
When you have completed step 2, then in PHP you will hold an object (let's call it $field) that contains these attributes. What's
in semantics would be represented by $field and could be read and set, e.g.
Best,
Oliver
Usapuka
Wed, 11/04/2020 - 18:18
Permalink
The same in Multi Choice
Hello Oliver,
To simplify my work I am trying to make the changes in the Multiple Choice question (see attached) https://github.com/h5p/h5p-multi-choice/blob/99ef831a691680ac61a447fc273....
To see if I am on the right track I have tried to change the lebel of the question, without any result. This is what I did:
What am I doing wrong?
Thanks again, bests.
Gabriel
otacke
Thu, 11/05/2020 - 11:20
Permalink
Hi!You're trying to access
Hi!
You're trying to access the variable $semantic_field that doesn't exist. You get $semantics which is an object that holds all the fields. You'll have to parse it to get to the correct field first. That's what the foreach loop in https://h5p.org/comment/18767#comment-18767 is doing (for one level of the object tree).
Best,
Oliver
Usapuka
Sun, 11/08/2020 - 22:48
Permalink
Hi Oliver,Following your
Hi Oliver,
Following your advice I have managed to replace 2 "Overall Feedback" titles (see attached) for which I have used this code:
I have made several attempts to change the "feedback" label (to know that I reached the level where I will change the text maxLength), but I have not succeeded: I will be grateful for any hint you give me to know how to reach that level.
Thanks, best.
Gabriel
otacke
Tue, 11/10/2020 - 11:24
Permalink
function h5pmods_alter
Usapuka
Tue, 11/10/2020 - 16:21
Permalink
Hi Oliver,According to your
Hi Oliver,
According to your indications, the code looks like this:
Unfortunately it does not modify the maxLength of the text.
To check that we are in the right place, I tried the following:
And the lebel did not change either.
What is wrong?
Thanks, best.
Gabriel
otacke
Tue, 11/10/2020 - 19:45
Permalink
My bad. My example wasn't
My bad. My example wasn't properly nested ...
Usapuka
Wed, 11/11/2020 - 14:18
Permalink
Hi Oliver,Excellent, now it's
Hi Oliver,
Excellent, now it's working! (see attachment).
Thanks for all your help, I learned a lot about H5P.
Best,
Gabriel
otacke
Wed, 11/11/2020 - 18:22
Permalink
You're welcome! And kudos to
You're welcome! And kudos to you for your perseverance! Most people wouldn't even have started ("oh, that's coding, I can't do this").