Knowing what is next?

Knowing what is next?

by Chris Berri -
Number of replies: 3

When you reach the end of a lesson in view.php, is there any easy way to find out what resource (lesson, quiz, file, whatever) is next in that same "topic" or "section" of your course? 

I want to create a button with a message that appears at the end of a lesson to either take the next lesson or if a quiz, to take the quiz, without going back to the course view.

Any suggestions?  Easy ways to do this without a ton of database calls?

--Chris Berri

Average of ratings: -
In reply to Chris Berri

Re: Knowing what is next?

by Chris Berri -

Nevermind.  I figured out a way to do it without any database calls. 

;)

--Chris Berri

In reply to Chris Berri

Re: Knowing what is next?

by Ray Kingdon -
Hi, don't keep us in suspenders big grin What's the answer? Is it here?
In reply to Ray Kingdon

Re: Knowing what is next?

by Chris Berri -

I'm not sure about that.  Here is what I did..

in mod/lesson/view.php where the end of lesson button is printed I added this:

$test1=explode('}', $course->modinfo);
 //find out where in the course topic we are and what is next

 foreach($test1 as $test) {
    $line=explode('"', $test); 


//pos 5 is the id   //pos 13 is the section num.  //pos 9 is the module
if(($check)&&($line[13]==$section)) {
   //if another lesson ....    
 if($line[9]=='lesson') {
          $id2=$line[5];
          echo "<p align=\"center\"><a href=\"view.php?id=$id2&action=navigation\">Next  Lesson</a></p>"; exit;
    } 

//else, if a quiz..
     else if($line[9]=='quiz') {
          $id2=$line[5];
          echo "<p align=\"center\"><a href=\"../quiz/view.php?id=$id2\">Take this Module Assessment</a></p>"; exit; }
    }

//if what is next is the next topic, just give the main menu link.
    if(($check)&&($line[13]!=$section)) exit; 

//if we find our lesson, grab the section id and set the check for the next resource.    
    if($id==$line[5]) { 
        $check=true; $section=$line[13];
    }
} //close the foreach loop.