I am not an expert myself, but I have had a look at your code, and I have some general suggestions ...
You might want to have a look at the coding guidelines of H5P. For example, you should not use 4 spaces but 2 spaces for indenting. This is basically a matter of taste, but keeping it consistent will help others to understand H5P code across different source files.
Don't forget to add comments to your code. They should explain why you did something the way you did rather than translating your code to human language. This will not only help others to understand your code, but also yourself in 6 month or so ;-)
In semantics.json, you might want to use a "list" instead of a "group" for uploading images, see https://h5p.org/semantics#type-list. This wouldn't only make your code more flexible, but also shorter, and people won't have to upload all images again if they decide they could need one more image for the sequence.
You shouldn't use a JavaScript alert to show the score, I think. Why not have a look at some other content types that use the progress bar with the star for feedback?
I have some more proposals, but major things first ;-)
In general I would recommend splitting up your attach method, to make it easier to read. Specially moving the call backs out to seperate class methods.
Thank you for sharing your content type. I have had a look at the code - here's my feedback:
You should not use an alert box. You could e.g. use the score bar, which is part of H5P.JoubelUI (github.com/h5p/h5p-joubel-ui).
It does not handle window resizing.
Usage of jquery UI: should probably use the jquery-ui H5P library instead. Or even better: don't use jquery UI at all :)
Semantics.json is unnecessary complex. Just use a list with min:3, max:6.
Use two spaces for indentation
Variable names are not consistent:
Variables prefixed with $ should be jQuery objects
Don't use underscore in variable names. E.g. instead of e_width use eWidth;
Variables like "N" should not be used, since it doesn't say what it is.
Labels are hardcoded, i.e. this content type is not translatable
Some of the DOM elements have ids that will not be unique if several Image Sequencing H5Ps are placed on the same page. I do not see they are in use, so they probably could be removed? E.g.: dragZone, dropZone and titleZone
Great job on this content type, thanks! I had a friend test this on his ipad and when he taps/drags the image, only the image drags, NOT the "card" with the text and the image. If he taps and drags the "text" portion, the whole card works as expected. Not sure if this can be fixed, but thought I'd share just in case!
Thanks for the feedback, Jimmy. The best way for this to be picked up by the Jithin, the creator of the content type, is to create an issue at the Github repository where the source code lives: https://github.com/jithin-space/h5p-ImageSequencing
Note that you will have to create an account on Github if you don't have one already.
Thanks otacke,tomaj and fnoks for your feedbacks..
I am progressing on standardizing my code as per your feedbacks..I will upload the next version through github as soon as it is finished.. I am very excited to see the feedbacks and thanks for spenting time on my work and for your helping mentality...
It looks like you have done the correct thing, i.e added a dependency to JoubelUI, which means that library will be loaded when your H5P content type is loaded. Have you put the dependency in the right place? I.e, it should be inside preloadedDependencies:
The image in this blogpost is pointing locally to your computer. A trick that I do, is to use the Attachments field at the bottom of the comment form, to upload an image. And the copy the url of that image to be part of the post itself.
I didn't get the idea at first...I just uploaded the attachment, use its url in the post and finally deleted the post..I think it is being displayed now
My Code for H5P.ImageSequencing Content type is being updated. I tried to my best to make use of all your suggestions..It is now properly indented, translatable, resizeable and structured.. Please go through the code and tell me if there exist any more modifications..
Great that you're making progress! I think there are still some kinks to be ironed out, e.g. some global variables that should be avoided, because they can easily be overwritten. In my humble opinion, an awesome tool for getting some hints is JSHint. I embedded it in atom recently, and I love it for showing me possible issues instantly when typing my code.
I see great improvements in your code. It is much tidier, and the way you have divided it into components makes it easy to follow. Great work!
I have done some testing, and especially when the images are of different height/width ratio, the UX-experience is a little strange, since the dropzones are jumping around while dragging. Generally, I think it is a little bit hard to know what I am supposed to do when seeing this content type the first time. If you'd like, I could get a UX designer to suggest a design for this content type - just let me know! I did find a bug when dropping one of the images outside the dropzones, then the image disappeared.
Below you'll find some comments about the code:
Your CSS is setting styles in a generic way (e.g. html, h1, h2, h3, h4, dd) and some of the selectors are too generic. This will be a problem since this content type is included using a DIV-tag, and those CSS-rules will then apply to other elements on the page. The best solution is probably to configure this H5P to be included using an iframe instead. This is done by adding the following to your library.json:
"embedTypes": [
"iframe"
]
A drawback of displaying the H5P inside an iframe is that you need to inform the parent window about any resizing. This is done by triggering the resize event on the main class (ImageSequencing in your case). Eg: self.trigger('resize');
There are still some untranslatable strings in dropper.js ("Drop Here", "please drop")
Somewhere you are setting CSS rules using JS. This should not be necessary unless the values are dynamic/calculated. Instead, you should toggle classes. Here is an example:
Thanks for the feedback from the ux part. I would like to implement the changes as suggested. Could you please provide the design specs as mentioned in the response so that I can implement it quickly..
Code Once again updated based on the suggestions from the ux designer. Major changes include , switch back to H5P jquery ui for smoother sortable functionality and removal of resize event...I think it works good automatically in all screen sizes...Please review the code ..
Does anyone know how to resize the images in this awesome content type? I tried to make changes in the h5p-image-sequencing.css to make the image smaller than 168 px, but it didn't do anything. Really appreicate any insights.
tim
Mon, 04/10/2017 - 09:54
Permalink
Nice work!
Nice work!
jithin
Mon, 04/10/2017 - 11:32
Permalink
Thanks
Thanks Tim,
Is there any suggestions for improvement especially about the code structure, since I am a beginner here...
otacke
Thu, 04/13/2017 - 13:08
Permalink
Hi Jithin!I am not an expert
Hi Jithin!
I am not an expert myself, but I have had a look at your code, and I have some general suggestions ...
I have some more proposals, but major things first ;-)
tomaj
Tue, 04/18/2017 - 08:14
Permalink
Coding
Hi Jithin,
Do you have an account on Github, where you can share your code (makes it easier to review it).
For writing good code, I recommend reading Clean code JavaScript.
In general I would recommend splitting up your attach method, to make it easier to read. Specially moving the call backs out to seperate class methods.
- Tom
fnoks
Tue, 04/18/2017 - 15:20
Permalink
Hi,Thank you for sharing your
Hi,
Thank you for sharing your content type. I have had a look at the code - here's my feedback:
Let us know if anything is unclear - we'll help!
jimmyjames
Tue, 09/26/2017 - 16:31
Permalink
Potential conflict/bug for iPad
Great job on this content type, thanks! I had a friend test this on his ipad and when he taps/drags the image, only the image drags, NOT the "card" with the text and the image. If he taps and drags the "text" portion, the whole card works as expected. Not sure if this can be fixed, but thought I'd share just in case!
Thanks again for sharing your work
tim
Wed, 09/27/2017 - 09:30
Permalink
Thanks for the feedback,
Thanks for the feedback, Jimmy. The best way for this to be picked up by the Jithin, the creator of the content type, is to create an issue at the Github repository where the source code lives:
https://github.com/jithin-space/h5p-ImageSequencing
Note that you will have to create an account on Github if you don't have one already.
jithin
Sat, 04/22/2017 - 11:53
Permalink
Thanks for the feedback
Thanks otacke,tomaj and fnoks for your feedbacks..
I am progressing on standardizing my code as per your feedbacks..I will upload the next version through github as soon as it is finished.. I am very excited to see the feedbacks and thanks for spenting time on my work and for your helping mentality...
tomaj
Mon, 04/24/2017 - 07:34
Permalink
Good luck!
Happy to help! Good luck with your coding!
- Tom
jithin
Tue, 04/25/2017 - 15:44
Permalink
Using JoubelUI
Hi All,
could anyone please tell me how to use joubelUI in my content type...I am getting TypeError: H5P.JoubelUI is undefined....
Here is what I did,
"machineName": "H5P.JoubelUI",
"majorVersion": 1,
"minorVersion": 2
}
please tell what I am missing?
fnoks
Wed, 04/26/2017 - 08:59
Permalink
It looks like you have done
It looks like you have done the correct thing, i.e added a dependency to JoubelUI, which means that library will be loaded when your H5P content type is loaded. Have you put the dependency in the right place? I.e, it should be inside preloadedDependencies:
If this is what your library.json looks like, you should verify version 1.2 of H5P.JoubelUI is installed on your system!
Let us know how it goes
jithin
Wed, 04/26/2017 - 11:26
Permalink
My Code and ScreenShot
Here is the link to my repository...it is not fully working...library json and scripts/image-sequencing.js are the files in consideration...
https://github.com/jithin-space/h5p-ImageSequencing
I beleive h5p.JoubelUI is installed in my drupal setup
tomaj
Thu, 04/27/2017 - 06:56
Permalink
Image not shown
Hi,
- Tom
jithin
Thu, 04/27/2017 - 09:18
Permalink
Image ..
I didn't get the idea at first...I just uploaded the attachment, use its url in the post and finally deleted the post..I think it is being displayed now
jithin
Sun, 04/30/2017 - 15:32
Permalink
resolved..
It is working now...but I am not able to exactly what caused that..Anyway thanks for the help..
jithin
Fri, 05/05/2017 - 14:13
Permalink
Code Updated..
Hi all,
My Code for H5P.ImageSequencing Content type is being updated. I tried to my best to make use of all your suggestions..It is now properly indented, translatable, resizeable and structured.. Please go through the code and tell me if there exist any more modifications..
https://github.com/jithin-space/h5p-ImageSequencing
A screen shot of how a content created using that type is also being attached...
sorry on my previous problem existed on a development branch and I shared the link for the master branch..
tomaj
Tue, 05/09/2017 - 09:40
Permalink
I tested Image Sequencing,
I tested Image Sequencing, and I it looks very cool! :)
But I get an exception from the timer in Chrome 58.
- Tom
fnoks
Tue, 05/09/2017 - 11:57
Permalink
Tomaj: This happens because
Tomaj: This happens because you are not including H5P.Timer. Nothing wrong with the content type :)
otacke
Tue, 05/09/2017 - 11:46
Permalink
Hi jithin!Great that you're
Hi jithin!
Great that you're making progress! I think there are still some kinks to be ironed out, e.g. some global variables that should be avoided, because they can easily be overwritten. In my humble opinion, an awesome tool for getting some hints is JSHint. I embedded it in atom recently, and I love it for showing me possible issues instantly when typing my code.
fnoks
Tue, 05/09/2017 - 14:14
Permalink
Hi,I see great improvements
Hi,
I see great improvements in your code. It is much tidier, and the way you have divided it into components makes it easy to follow. Great work!
I have done some testing, and especially when the images are of different height/width ratio, the UX-experience is a little strange, since the dropzones are jumping around while dragging. Generally, I think it is a little bit hard to know what I am supposed to do when seeing this content type the first time. If you'd like, I could get a UX designer to suggest a design for this content type - just let me know! I did find a bug when dropping one of the images outside the dropzones, then the image disappeared.
Below you'll find some comments about the code:
Your CSS is setting styles in a generic way (e.g. html, h1, h2, h3, h4, dd) and some of the selectors are too generic. This will be a problem since this content type is included using a DIV-tag, and those CSS-rules will then apply to other elements on the page. The best solution is probably to configure this H5P to be included using an iframe instead. This is done by adding the following to your library.json:
A drawback of displaying the H5P inside an iframe is that you need to inform the parent window about any resizing. This is done by triggering the resize event on the main class (ImageSequencing in your case). Eg: self.trigger('resize');
There are still some untranslatable strings in dropper.js ("Drop Here", "please drop")
Somewhere you are setting CSS rules using JS. This should not be necessary unless the values are dynamic/calculated. Instead, you should toggle classes. Here is an example:
Could e.g instead be:
and your CSS could actually set the style:
jithin
Thu, 05/25/2017 - 14:02
Permalink
Code Once Again Updated...
Hi All,
Now I am again with new code because the previously detected bug needed a detailed restructuring.
Please Once Again test my Code and make your suggestions...
I am happy to get the suggestions also from a experienced UX designer as fnoks had mentioned...
https://github.com/jithin-space/h5p-ImageSequencing
jithin
Mon, 06/05/2017 - 12:00
Permalink
No Response..
Hello All,
I am not getting any responses for the past two weeks...please respond so that I can move forward onto more h5p tasks..sorry if you were too busy!!!!
fnoks
Tue, 06/06/2017 - 09:02
Permalink
Hi,Our UX-designer has given
Hi,
Our UX-designer has given some feedback, which is available here:
https://h5ptechnology.atlassian.net/browse/HFP-1156
jithin
Thu, 06/15/2017 - 07:17
Permalink
Design Specs Needed
Hi All,
Thanks for the feedback from the ux part. I would like to implement the changes as suggested. Could you please provide the design specs as mentioned in the response so that I can implement it quickly..
jithin
Tue, 07/04/2017 - 08:52
Permalink
Code Updated --Based On UX Design
Hi,
Code Once again updated based on the suggestions from the ux designer. Major changes include , switch back to H5P jquery ui for smoother sortable functionality and removal of resize event...I think it works good automatically in all screen sizes...Please review the code ..
https://github.com/jithin-space/h5p-ImageSequencing
[email protected]
Thu, 02/28/2019 - 05:14
Permalink
resize image
Hi all,
Does anyone know how to resize the images in this awesome content type? I tried to make changes in the h5p-image-sequencing.css to make the image smaller than 168 px, but it didn't do anything. Really appreicate any insights.