Accordion chunk display

Accordion chunk display

by Susanna Wesson -
Number of replies: 3

Dear Gordon,

Is it possible for Moodle to display text appearing in a 'chunk' at the bottom of the window?  I am using Stan's Accordion chunking method to avoid iframes (he advised avoiding them); my final 'chunk' displays correctly in IE, Chrome and Mozilla but the window will not adjust in Moodle when displaying only one question in jquiz.

I have attached a file in case you have a moment.

Many thanks,

 

Susanna.

Average of ratings: -
In reply to Susanna Wesson

Re: Accordion chunk display

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Suzanna,
I can see what's wrong but I can't see how to fix it easily.

Everytime you click one of the expansion arrows in the left-hand pane of the JQuiz, we should recalculate the height of the left-hand pane and adjust the height of the left-hand pane accordingly.

At the moment, chunks 1-7 are roughly the same height so they display OK without adjusting the height of the left-hand pane. Chunk 8 is slightly taller than the other chunks, so it requires the height of the left-hand pane to be adjusted.

You can force HotPot to adjust the left-pane height if you display Chunk 8, then click the "Show all questions" button, then click the "Show questions one by one".

One solution to this issue would be to modify the javascript that controls the expansion of chunks in the left-hand pane so that it also calls HotPot's "StretchCanvasToCoverContent()" function. Here is the javascript to do that:

  • if (window.StretchCanvasToCoverContent) {
     StretchCanvasToCoverContent();
    }

I can't see immediately where to put that in the file you sent, but maybe the person who created the chunking code would be able to see where to put it.

There may be another solution. It would allow the left-hand pane to expand "naturally" by inserting the following HTML somewhere:

  • <div style="clear:both"></div>

This may make it unnecessary to call "StretchCanvasToCoverContent()". However, I need time to ponder that.

regards
Gordon

In reply to Gordon Bateson

Re: Accordion chunk display

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Suzanna,
I took a closer look at the JavaScript code in that HTML file you sent and it turned out not to be so scary.

The documentation about this effect is here:

The "onopenclose" section looked interesting, so I went here:

The important information is in the section entitled "The onopenclose(...) event".

Using that as my guide, I found that your JQuiz can work in Moodle with the folowing change:

  1. open the HTML file with your favorite text editor
  2. locate the line containing the "onopenclose:function" (around line 2153)
  3. replace the "// do nothing" line with the following code:
    if (state=="block" && isclicked==true){
    if (window.StretchCanvasToCoverContent) {
    StretchCanvasToCoverContent();
    }
    }
  4. save the modified file and upload it Moodle

For reference, I have attached a copy of your original HTML file that has been modified in the way described above.

Please try that out and let me know what happens.

regards
Gordon

In reply to Gordon Bateson

Re: Accordion chunk display

by Susanna Wesson -

Dear Gordon,

All works perfectly.  I have applied the same method to other files and they work properly, too.

Many thanks, yet again.  I'll let you get back to QuizPorts, now.

 

Susanna.