Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset functionality #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Add reset functionality #6

wants to merge 8 commits into from

Conversation

timothyylim
Copy link
Contributor

Added functionality to reset H5P summary content type once the tasks have been completed.

Created and registered a JoubelUI button to handle the reset logic.

@thomasmars
Copy link
Member

Looks great, awesome stuff :)
I will create an issue for reviewing this for the next release

$(this).on('click');
});

for (i = 0; i < this.options.summaries.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i is implicitly declared here, making it global

@thomasmars
Copy link
Member

I've had the chance to look at the code a bit, and it looks very promising! 👍

The functionality that has been added and the code looks really good, however it conflicts a bit with some existing functionality that you may not be familiar with:
The "retry" functionality does not work well with the "resume" functionality. To test the "resume" functionality you can enable it in the H5P settings, it should be named "Save content state". This allows you to resume a task where you left off, if you for instance reload or exit the browser.

Try this:

  1. Complete Summary with some wrong answers
  2. Retry
  3. Complete Summary with only correct answers
  4. Reload page
  5. You will see that the wrong answers from the first round is counted as well.

Also the 'retry'-button is not added when resuming Summary if you left off at the last page.

You also might want to have a look at contracts that IV and CP expects when 'retry' is implemented: https://h5p.org/documentation/developers/contracts. Other content types implement a behaviour that lets you enable/disable the 'retry' button.

Soon there! :)

@timothyylim
Copy link
Contributor Author

timothyylim commented Sep 1, 2016

Thanks for the feedback @thomasmars, I've finally gotten around to making some changes:

  • Enable the retry button only at the end of the summary
  • Add the required contracts
  • Edited the order of the contracts to reflect the order on the website: https://h5p.org/documentation/developers/contracts
  • Fixed the bug that was showing the answers incorrectly upon 'resuming'

Hopefully, second time lucky!

this.showSolutions = function() {
// intentionally left blank, no solution view exists
this.getAnswerGiven = function () {
if (this.progress > 0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to return (this.progress > 0);

@thomasmars
Copy link
Member

thomasmars commented Sep 1, 2016

Looking a lot better!
Have left a couple of comments on your commit, and some additional details for you to look at:

  • Should have its own semantics boolean for "enable"/"disable" the "retry" button
    See https://github.com/h5p/h5p-blanks/blob/master/semantics.json#L167-L181
  • The new semantics for 'retry' button should either have a default value of false/disabled
    or a new minor version with an upgradescript that sets all upgraded summary library content's
    'retry' button to disabled so old content will keep looking the same. Then the default value of 'retry'
    can be defaulted to true/enabled

When these issues have been solved I think its ready to go! :)

@timothyylim
Copy link
Contributor Author

timothyylim commented Sep 3, 2016

Fixed the highlighted issues.

I've added a semantics boolean for enabling the retry button with a default value of false.

I think I'll create an upgrade.js script in another pull request as I still need to wrap my head around how upgrading h5p content types work.

behaviour: {
enableRetry: true,
},
enableRetry: true,
Copy link
Member

@thomasmars thomasmars Sep 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have moved the enableRetry variable out of the behaviour group, which means that it no longer satisfies the contract to parents: https://h5p.org/documentation/developers/contracts. The solution could be to create a group for behaviour in the semantics, or make sure that you override enableRetry if it received a behaviour.enableRetry from parent.

@thomasmars
Copy link
Member

Nice, I have left a comment for you in the commit regarding contracts, this should be the last thing that has to be fixed :)

@timothyylim
Copy link
Contributor Author

timothyylim commented Sep 5, 2016

Thanks Thomas 👍

I think I removed it because I didn't see the point of having a behaviour group with only one variable but forgot about the contract.

I've definitely learnt a lot more about how the content types work together :D

@thomasmars
Copy link
Member

That's good for the JS file, but you also have to change it in semantics, to reflect the structure that you expect in your JS.
That is your "enableRetry" semantics should be inside a "behaviour" group, like in Blanks

@timothyylim
Copy link
Contributor Author

timothyylim commented Sep 5, 2016

Ah, should've realized that I had to do that. I was wondering if errors get thrown if the semantics don't match up with the extended options in the js file?

@thomasmars
Copy link
Member

No, the semantics define the json structure of the params you receive in your JS. You can do whatever you want with them.
There is no need to extend params with defaults unless you add new semantic fields without creating a value for them through an upgradescript, so that old content wont have the new params.

@timothyylim
Copy link
Contributor Author

timothyylim commented Sep 6, 2016

Thanks again for the explanation, Thomas 👍

@thomasmars
Copy link
Member

Awesome, this looks really good now! :)
Unfortunately there is a bug/hack in H5P Core that flattens a semantic group with only one field inside of it for historical reasons. We have had a little discussion on this topic and we will fix it next release. This means the review of this issue is on a bit of a hold for now, until we can fix that issue.

@timothyylim
Copy link
Contributor Author

Ok, let's wait until that bug/hack gets resolved then, or until additional behaviours are added :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants