Custom nav-next

Custom nav-next

by Andre Paz Leal -
Number of replies: 7

So this is my need, at first it look kind of simple, for me was just, hey create two another buttons inside the player.php, one before the tocmenu and another right after.

Ok so I did.

echo '<div id="scormnav" class="scorm-right"><input id="nav_prev" class="form-submit" type="submit" value="Previous" ></input>'.$result->tocmenu.'<input id="nav_next" class="form-submit" type="submit" value="Next"></input></div>';

Ok I got it it´s all fancy and just how I designed with the same blue buttom from the submit class and dadadada, now what I think, well I have a module.js that´s loaded within the page if I just change the element id for the same that´s used inside the JS file that should work right? So I got it wrong. Can someone enlighten me?

Average of ratings: Useful (1)
In reply to Andre Paz Leal

Re: Custom nav-next

by Andre Paz Leal -

Sorry you guys, I have to bump this thread is critical important for me, I have try a few ways without any luck.

In reply to Andre Paz Leal

Re: Custom nav-next

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You've bumped this, but not really added anything to explain what:

a) you want to do (you say you want to add a couple of buttons - from the screenshot it looks like you've succeeded in this)

b) what is not working (are the buttons not where you wanted them? are they not doing what you wanted them to do? in what ways are they not doing what you wanted them to do? are there any error messages displayed?)

 

In reply to Davo Smith

Re: Custom nav-next

by Andre Paz Leal -

Davo, thank you.

Well as you can see I´ve only added the button to the player.php as I show.

My need is at the same way that the two buttons created, work the same way the buttons inside module.js, go to the next sco or previous.

As the player.php call the module.js I think that using the same id for the buttons I´ve created inside player.php should work, since the buttons from the module.js are not loaded with a "Display course structure in player" option set as "In a drop down menu".

Thank you.

In reply to Andre Paz Leal

Re: Custom nav-next

by Andre Paz Leal -

Sorry Davo, I have been struglin for one week whithout any luck. 

In reply to Andre Paz Leal

Re: Custom nav-next

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You've been struggling for a week, but it still isn't particularly clear what you've actually tried to do in that time.

You have identified that the code for making the SCORM go to the next/previous page is in module.js. What ways have you tried changing the javascript in this file?

From a quick glance at the code, you need to give your buttons unique 'id' values (as HTML does not allow you to have more than one element with the same value), then, somewhere suitable within module.js, you need to bind an event handler to the 'click' event for each button and get it to call 'scorm_launch_next_sco()' or 'scorm_launch_prev_sco()'. You might also want to add some code to disable/enable the buttons when you get to the first/last item in the SCORM.

 

In reply to Davo Smith

Re: Custom nav-next

by Andre Paz Leal -

Ok continuing the development, I have changed the function to call the next SCO:

var scorm_launch_next_sco = function () {
scorm_activate_item(scorm_skipnext(scorm_current_node, true));};

But only goes thru one time after the first click, calling the function thru a simple button created on the player.php.

Y.one('#andreNext').on('flick', scorm_launch_next_sco);

 

 

 

 

 

 

 

 

In reply to Andre Paz Leal

Re: Custom nav-next

by Andre Paz Leal -

This os not the solution that I´ve wanted but I only know JS so.

 var scoidElements = document.getElementsByName('scoid')[0];
 var nextButton = document.getElementById('nextButton');
var previousButton = document.getElementById('previousButton');

var nextScoid = function() {
var i = scoidElements.selectedIndex;
scoidElements.selected = true;
scoidElements.selectedIndex = i+1;
document.getElementById('tocmenu').submit()
}
var previousScoid = function() {
var i = scoidElements.selectedIndex;
scoidElements.selected = true;
scoidElements.selectedIndex = i-1;
document.getElementById('tocmenu').submit()
}
nextButton.onclick=function() {
nextScoid();
};
previousButton.onclick=function() {
previousScoid();
};