Quiz

 
 
Picture of Chris Wells
Hide Description when Student completes Quiz (2.5)
 

I have setup a quiz that Students can take with a description on the view.php page for the quiz, the same page as the Attempt Quiz Now button.

I want it so that when the student completes the quiz, the description and the messages (in this case, Attempts allowed and Time limit) are not shown - just the back to course button (I have already changed the text to be a thank you message).

Alternatively, is there a way to get a class in to the <body> that says if an activity has been completed? At least then I can hide it with CSS.

Thanks for any help.

 
Average of ratings: -
Picture of Chris Wells
Re: Hide Description when Student completes Quiz (2.5)
 

OK - I sorted this now.

It's not pretty, but here is my solution:

In the function view_information() in quiz/renderer.php I amended the code to include an if(quiz_num_attempt_summary($quiz,$cm,$content) == 0) { .. } around the content that I wanted to remove.

Since the page refreshed when the activity was complete, this was caught in the render and since it was no longer == '', the information was skipped over.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Hide Description when Student completes Quiz (2.5)
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

That is not quite right. quiz_num_attempt_summary is the total number of attempts by all students, not the number of attempts by this student.

In the renderer, the attempts for the current student should be being passed in.

But overriding the renderer is the right way to take control of this, like you want to. http://docs.moodle.org/dev/Overriding_a_renderer

 
Average of ratings: -
Picture of Chris Wells
Re: Hide Description when Student completes Quiz (2.5)
 

Hi Tim,

That's disappointing sad

What is the actual function that I should be using, and what do I need to pass in to my overwritten method?

Thanks!

 
Average of ratings: -
Picture of Chris Wells
Re: Hide Description when Student completes Quiz (2.5)
 

Never mind - sorted it smile

I didn't overwrite it in the truest sense, just replaced the function I was using with: $foo = quiz_get_user_attempts($quiz->id,$USER->id);

I've run a quick test and that seems to do the job, returning a full array if an attempt on the quiz had been made.

 
Average of ratings: -