Place Variables on an Image in Question text

Place Variables on an Image in Question text

by Godfrey Sovis -
Number of replies: 10

I have a question about Variable Numeric question type. Is it possible to place variables on an image in the Question text? I want to place random variables on branches of a Tree diagram. How can I do that? Thanks.


Average of ratings: -
In reply to Godfrey Sovis

Re: Place Variables on an Image in Question text

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, with varnumeric, you can put variable values anywhere in the HTML of the question.

So, the question is really, how would you draw that diagram with HTML? Not easy. Here are some options:

  1. Just write a = 0.1, b = 0.2, c = 0.3 (or whatever values) under the image. (Not great, but easy)
  2. Put the values under the image, each one wrapped in <span style="position:relative; left:XXpx; top:YYpx">...</span> tags. (Tricky and a bit fragile.)
  3. Only have a few possible values, and make a bunch of images like image0.1-0.2-0.3.png.
  4. Don't use an image. Make something that looks a bit like an image using tables and table borders.
  5. See if you can find a filter in the Moodle plugins directory that lets you draw diagrams.

I am not aware of a good plugin like 5. (I hope I am wrong.). 1. is safest. 4. is the only other one of these that is really feasible.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Place Variables on an Image in Question text

by Godfrey Sovis -

Thanks so much for your suggestion. I will try that method and come back with a feedback. regards

In reply to Tim Hunt

Re: Place Variables on an Image in Question text

by Godfrey Sovis -

Thank you so much for shedding some light to find a way to resolve the problem.

As you suggested, I explored the plugins directory to find the add-ons to Atto Text editor

and found the "atto_wordimport" plugin. 

It is in Beta version, but it solved the problem.

I designed the question using "Word 2010" keeping the image as the background.

Then I imported to question text using "Word import".

There I set it in a table with image as the table background; text: inline

Then I could place the variables where I wanted them to appear.

Thanks again for your guidance.

In reply to Tim Hunt

Re: Place Variables on an Image in Question text

by Godfrey Sovis -

Unfortunately, when I view the question in the quiz, it is all messed up. 

The method you suggested

(.....each one wrapped in <span style="position:relative; left:XXpx; top:YYpx">...</span> tags.....) 

has more control over placing the variables, though I had to find the exact place by trial & error. It is now stable.

Thanks again.



In reply to Tim Hunt

Re: Place Variables on an Image in Variable Numeric

by Godfrey Sovis -

Hi Sir Tim,

Below is the HTML I used to place the variables on an image in Variable Numeric Question text, using your suggestion.

-----------------------------------------------------------------

<table style="background-image: url('http://www.learnfree.man-fiyo.com/draftfile.php/5/user/draft/983286581/Tree2b.PNG'); height: 323px; width: 355px;" border="0">

<tbody>

<tr>

<td>

<p><span style="position: relative; left: 55px; top: 182px;">a</span> </p>

<p><span style="position: relative; left: 214px; top: 62px;">b</span> </p>

<p><span style="position: relative; left: 219px; top: 213px;">c</span> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

</td>

</tr>

</tbody>

</table>

<p><br />Value of s is_____</p>

----------------------------------------------------------------

First, I place "TinyMCE text editor" above Atto editor to make it the default in "Plugins". Then I used "Drag and Drop onto image"question type and place the image there to get the exact coordinates. Then I inserted a 1x1 table and used the image as background.

Then I inserted HTML ("<span style="position: relative; left: 55px; top: 182px;">a</span>") after <tbody> 



Average of ratings: Useful (1)
In reply to Godfrey Sovis

Re: Place Variables on an Image in Question text

by Matthias Giger -
Picture of Particularly helpful Moodlers

For the task you have in mind, have you considered the GeoGebra plugin (assessment and question type are available).

In GeoGebra you can easily link graphics and text. You can randomize numbers and you can forward the results via a boolean variable to Moodle.

The disadvantages of that approach are:

  • You have to learn how to do a bit of code in GeoGebra.
  • The plugin might not be as readily available in the future as a core function.
Average of ratings: Useful (1)
In reply to Matthias Giger

Re: Place Variables on an Image in Question text

by Godfrey Sovis -

Hi Matthias, I totally agree with you.

Earlier, I used Geogebra to ópen an interactive "Cumulative Frequency curve" on a new window as an aid to answer some questions. Problem is, only Firefox opens the new window without much problem. Chrome takes a longtime, sometimes doesn't open at all. So, I didn't try it this time. Anyway, I will give it a try and see.

Thanks a lot for the suggestion.


In reply to Matthias Giger

Re: Geogebra qtype

by Godfrey Sovis -

Hi Matthias Giger,

I was very happy to see that Geogebra plugin is updated to Moodle 3.1.

Unfortunately, I could not find a sample question or tutorial to configure a question using geogebra qtype.

I struggled with no luck. Can you please help me or send me a sample question?

Thanks in advance.

Godfrey Sovis

In reply to Godfrey Sovis

Re: Geogebra qtype

by Matthias Giger -
Picture of Particularly helpful Moodlers

Dear Godfrey

You will find a GeoGebra file attached to this explanation.

Basically what you do: In GeoGebra you define a variable which is true, when the student has done what you want him to do.

(In the example number and input need to have the same value for the variable "correct" to be true.)

When you import the file into Moodle (GeoGebra question) Moodle will present you with a list of boolean variables (true/false) in the GeoGebra file.

Just set that value to 100% and Moodle will grade the work of the student.

(To write the GeoGebra file can be a bit tricky, so let me know if you need more information. I have written a small documentation about some of the problems I came across, but as it is in German I would need to translate it first.) I hope that this weekend, I will find some time to do it.

You can also just send me an example file and I will add all the necessary code to it.

In the provided file there are some elements you would probably want to set to invisible before you actually use it as a test. But in my experience those additions are very helpful when writing the GeoGebra file, because if something goes wrong, you get at least a hint what to look into.

In reply to Matthias Giger

Re: Geogebra qtype

by Godfrey Sovis -

Dear Matthias, I really don't know how to thank you. You have not only sent a sample geogebra file for me to use on Moodle, but also you have obliged to help me further to design my worksheets. Unfortunately, I am not well and had to stop all my work. I am so impatient until I get well to test your sample file and continue my work.

Thank you so very much! I will get back to you ASA I am back to normal.