Functions not working in the left counter.

Functions not working in the left counter.

by Neelima Ramesh -
Number of replies: 19
Hi everyone,

I have a rather confusing problem. Let me try to put it as simply as possible.

I have two major problems right now with the left container.

1) I have embedded a small flash player(the most basic one with a play/pause and a stop option) into the left container of many of my exercises. It plays all my audio files without any problem when run separately on m computer. But it doesn't work at all when I upload the exercise into moodle (all the required files i.e swf and mp3 files etc are included in the folder too).

2) The 2nd problem is that, I have created this push button in my htm files and have linked it to a function in the _js file. The push button expands the left counter downwards and some text is displayed in that area. When I click on the push button again, the expanded area disappers(along with the text obviously). Now, this is again not working when i try to put it in moodle.

This might be a stupid doubt but just to make sure; I'm reusing [strExerciseSubtitle], which is the variable that holds the subtitle for the text, for the text in the expanded area (in problem 2). Is this effecting the operation by any chance?

Please help ASAP.

Thanks.

Neelima.
Average of ratings: -
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
> Please help ASAP.

Please upload your quiz ASAP to my server so I can investigate ...
... or give me teacher access to your course ASAP so I can come and have look at your custom modification ASAP

thanks
Gordon
In reply to Gordon Bateson

Re: Functions not working in the left counter.

by Neelima Ramesh -
Hi Gordon!
I've uploaded the exercise along with all the other files into your server just now. The name of the folder is "How Horsegram became flat" plz find all the required files there.

Thanks a ton! smile

Neelima
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
The spaces in your folder names and file names are making it impossible for the HotPot module to convert the relative urls to absolute urls, so the references to images, sound files and external javascripts are not available to the quiz.

The first step to fixing your quiz is to remove the spaces from the folder names, file names and relative urls:
  • rename folder "How Horsegram Became Flat" to "How.Horsegram.Became.Flat"
  • rename file "2 0011.JPG" to "2.0011.JPG"
  • rename file "How Horsegram Became Flat.mp3" to "How.Horsegram.Became.Flat.mp3"
  • edit file "St5ex1.htm"
    • replace all "2 0011.JPG" with "2.0011.JPG"
    • replace all "How Horsegram Became Flat.mp3" with "How.Horsegram.Became.Flat.mp3"
That will enable the HotPot module to convert relative urls to absolute urls and your images, sound files, media player and external javascript will be accessible to the quiz.

In reply to Gordon Bateson

Re: Functions not working in the left counter.

by Neelima Ramesh -
Hey Gordon!

Thanks for that! The sound is working perfectly now. smile
But the push button in the left container is still not working.

This is what I want it to do;

When I click on the push button that says "Click to Read/Hide Story", I want the whole left counter to extend downwards and the text appearing in that extended area. Nothing else changes. The right counter remains as it is, the top portion of the left container(above the push button) remains same.

But as you can see, what is happening is;

-When I click on the button (that says "Click to Read/Hide Story"), only the text is appearing outside of the left container (i.e in the background area). The left container is not extending.

-Also, when I click on the button that says "Show all Questions" in the right container, the left container is extending downwards too. The button "Show all Questions" is somehow effecting the left container too, even though 2 separate functions are being used for both of them.

Plz tell me what the problem is.

Neelima.
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
> When I click on the button (that says "Click to Read/Hide Story"),
> only the text is appearing outside of the left container

Then you need to write the javascript to stretch the left container. An easy way to do that is to call the StretchCanvasToCoverContent() function.

> Also, when I click on the button that says "Show all Questions" in the right container,
> the left container is extending downwards too.

Good, that is what is supposed to happen. If you want to do something different, then you will have to modify the StretchCanvasToCoverContent() function.

Gordon
In reply to Gordon Bateson

Re: Functions not working in the left counter.

by Neelima Ramesh -
Could you tell me more about this function? Its syntax and everything else?
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
> Could you tell me more about this function?
> Its syntax ...

StretchContentToCoverCanvas() is a javascript function that QuizPort uses to make sure the page canvas covers the page content that is currently displayed to the user. It is necessary to call this function when the content of the page changes in order for the Moodle footer to be positioned just below the visible quiz content.

this function does not take any arguments. you call it just like this:
  • StretchContentToCoverCanvas()
> ... and everything else

Please be more specific wink
Gordon
In reply to Gordon Bateson

Re: Functions not working in the left counter.

by Neelima Ramesh -
hmm.. This is the function I had written instead of StretchContentToCoverCanvas()


var shown = null;
function show(it) {
if (shown == null)
{shown = document.getElementById(it);}
else
{if (shown.id != it)
{shown.style.display = "none";
shown = document.getElementById(it);}
}
shown.style.display = (shown.style.display == "none") ? "block" : "none";
}

Here, "it" contains the text to be displayed. This works fine outside moodle (in hotpotatoes), but it doesn't work when I upload the exercise in moodle. How come?
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
> it doesn't work when I upload the exercise in moodle. How come?

Because you need to call the StretchCanvasToCoverContent() function. That it was I meant when I said "It is necessary to call this function when the content of the page changes".
In reply to Gordon Bateson

Re: Functions not working in the left counter.

by Neelima Ramesh -

Hey Gordon!

I tried that function but in vain. I'm putting up some screen shots of what is expected and what is actually happening. Plz have a look at them and tell me what the problem is.

(1) This is how the exercise looks initially.
Attachment sc1.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
(2) This is how it looks when you click on the button that says "click to Show/Hide Story" in the left container. Notice that the left container has been extended downwards but the right container remains the same.
Attachment sc2.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
(3) This is how it looks when you click on the button on the left counter that says "Click to Show/Hide Story" again (notice that the text has been hidden again and the counter has been resized again) and then when you click on the button that says "Show all questions". Notice that the right counter has been extended and the left counter is not effected.
Attachment sc3.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
This is what is happening when I upload the exercise into moodle.

(1) This is how it looks initially.
Attachment sc1.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
(2) This is how it looks when you click on "Show/Hide story" in the left counter. Notice that the right counter is also being effected (which is not desirable).
Attachment sc2.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
(3) This is how it looks when i click on the "Show/Hide Story" button again. The text gets hidden but the container's size remains extended.
Attachment sc3.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
(4) This is how it looks when I click on "Show all questions" in the right container. Notice that the left container also extends as much as the right container (and this is really bad for me. not appealing)
Attachment sc4.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

by Neelima Ramesh -
(5) and lastly, after I click on "show questions one by one" in the right container and "show/hide story" on the left container again, this is what is happening. (Again really really bad for me).

Plzz help.
Attachment sc5.JPG
In reply to Neelima Ramesh

Re: Functions not working in the left counter.

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

When you have a situation such as your 5th screenshot where the container does not cover the page content, copy and paste the following to your browser's address bar ...

  • javascript:alert(StretchCanvasToCoverContent(true))

... then hit your Enter key, and you will find that the container is automatically adjusted to cover the content.

The above line will also fix the situation such as your 3rd screenshot, where the container goes too far down the page.

Plzz try the above, confirm that it works, and then consider for yourself what you need to do to fix your custom javascript so that it calls StretchCanvasToCoverContent(true) at the appropriate time. i.e. just after the custom content is shown or hidden.

P.S. If you do not like the left and right containers always being the same length, you should create your own version of StretchCanvasToCoverContent() which behaves the way that you want. In case you haven't been able to find it yet, I have included a copy of the function in the attached file.