General developer forum

New filter for displaying questions in any content

 
peter svec
New filter for displaying questions in any content
 

We are developing the filter which will display the question in any content. We follow the guidelines available on Using the question engine from module. We are in early phase of the development but the filter is working quite well.

We are able to inline the question in the book, so we can mix the study content mixed with the questions. 

The problem is with pictures and other multimedia. Pictures are served within the question context (/pluginfile.php/6327/question/questiontext/7850/1/45199/...) and so are not displayed in the book for example. (Sorry, the requested file could not be found)

Does anyone know about the solution of this problem? How can I add pictures and other multimedia in the way that they are not server through the pluginfile.php within the question context? For example direct link to filesystem repository.

Thanks for ideas

Peter



 
Average of ratings: Useful (4)
Tim at Lone Pine Koala Sanctuary
Re: New filter for displaying questions in any content
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developers

I have wanted to develop this for ages. Unfortunately, I keep failing to persuade people at the OU to give it priority.

The way to debug this is to right-click on the broken image, and choose 'Open in new tab'. I am assuming you already have Developer Debugging enabled.

You must server images through pluginfile.php. That is how file handing in Moodle is designed to work.

If it was me, I would display the whole question in an iframe. Then, the script that runs inside the iframe basically just has to be like question/preview.php.

There is a big issue about security. If you have a filter that given input like {{question:123}} will display the question with id 123, and if students can guess that question 123 is one of the ones in the final exam, then that is bad. I was thinking of some sort of security hash to restrict things.

Also, I was wondering if a way to do this was to instead make a plugin to let you embed a Moodle question anywhere using oEmbed. Then, you would not need to make a separate filter. You could just use an existing oEmbed filter.

 
Average of ratings: -
peter svec
Re: New filter for displaying questions in any content
 

I waited for development of this for ages smile I cannot wait more, so I decided to write it. This is why the questions are separated from the quiz, isn't it?

The problem was in the lib/question.lib

$dir = core_component::get_component_directory($module);

        if (!file_exists("$dir/lib.php")) {

            send_file_not_found();

        }

I don't have /filter/inlinequestions/lib.php  So I created one with the 

function filter_inlinequestions_question_pluginfile($course, $context, $component$filearea, $qubaid, $slot, $args, $forcedownload, $fileoptions) and now it works well.

I understand the security issue, I can limit the filter use only for book module for now.

 
Average of ratings: Useful (1)
Tim at Lone Pine Koala Sanctuary
Re: New filter for displaying questions in any content
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developers

Sorry I did not make it clear in my previous post: I think it is great that someone has time to work on this smile

 
Average of ratings: -
peter svec
Re: New filter for displaying questions in any content
 

Thank you. Maybe I was not clear also. I appreciate the work which is done by core developers. I just didn't understand why this issue wasn't the priority (maybe there are strong reasons, e.g. security). 

From the didactic point of view, using inline questions can raise the quality of study material. This is why the lesson module have questions. It is pity, that Lessons' questions have no link to Question bank (and all the different types of questions including new drag and drop ones).

I hope, I will have enough time during the summer to enhance this module. I'm thinking about the course migration. Questions will have different ID on another Moodle sad

 
Average of ratings: Useful (1)
Picture of Marcus Green
Re: New filter for displaying questions in any content
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Tim did a bunch of work a while ago to separate the question engine from the Quiz. One of the early fruits of this was the Question Practice module that was developed as part of the Google Summer of Code. The Moodle Association is having an intense discussion of incorporating standard quiz questions in the Lesson module at the moment (there have been multiple posts in the last 24 hours).

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: New filter for displaying questions in any content
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developers

I would like to think that as the person who designed and built the question engine, I might have something to contrbute to that discussion, even though I have not (yet) chosen to join the Moodle Association.

Indeed, I gave what I hoped was a helpful response to Joseph's post in the Lesson forum, but that has not even received an acknowledgement.

Can I reiterate, I am happy to help discuss this and work out the best plan, but if the conversations take place in private, I can't.

 
Average of ratings: -
Picture of Marcus Green
Re: New filter for displaying questions in any content
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Perhaps you designed it so well you are hardly needed (I jest), join up you won't regret it, its a £50 bargain.  

 
Average of ratings: -
Picture of Nadav Kavalerchik
Re: New filter for displaying questions in any content
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup TestersGroup Translators

Hi Tim, sorry it took me ages to get back to you (and now the group) about this. as you asked me about it a few weeks ago when we met on the the UK MOOT. (I was probably not taking my pills on that day, as I see no other excuse sad for taking soooo long to reply. really really sorry)

And now...

Here is a link to some work I did on this issue a while ago:

https://tracker.moodle.org/browse/CONTRIB-5688

 
Average of ratings: -
Picture of Nadav Kavalerchik
Re: New filter for displaying questions in any content
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup TestersGroup Translators

And another attempt (a little bit different code approach) to solve this issue, which I think broke on some API change from version 2.5+

but still, could be interesting to look at (attaching)

and, was based on some work done by Alex Smith as part of the Serving Mathematics project (http://maths.york.ac.uk/serving_maths)

 
Average of ratings: -
Picture of Jon Bolton
Re: New filter for displaying questions in any content
Group Particularly helpful MoodlersGroup Testers

Hi Peter - would you be willing to share the code for the question filter?

 
Average of ratings: -
Picture of Richard Jones
Re: New filter for displaying questions in any content
 

Hi Jon

I'm a little bit hesitant because I've not done any serious Moodle dev outside theming before now.  However, there is a simple piece of filter code on my github (richardjonesnz) that allows a teacher to insert code that displays a question in a popup using the preview.php page.

I have also got an Atto button that only the teacher can use to insert a hashed question id would be a workable approach.  That's also there, based on Justin Hunt's Atto template which I barely understand.

I'm not sure how to create the hash though as it looks complex to hash within YUI and recover it in the PHP filter.  At my level anyway.

I'm now working on passing that to a copy of preview.php which has a couple of lines to de-obfuscate the id.

Anyway, if developers have advice I will try to follow it.


 
Average of ratings: Useful (1)