# Embed questions filter

Filters ::: filter_embedquestion
Maintained by Tim Hunt, Mahmoud Kassaei, Chris Nelson
A Moodle text filter plugin that displays interactive questions from the question bank embedded in the page.
Latest release:
970 sites
47 fans
Current versions available: 3

This filter allows questions from the question bank to be embedded anywhere that users can input HTML. This can be used in various ways. It can be a way to make learning materials more interactive. For example you may wish to embed an interactive question in a Book, or a Page, or even a Label. Or perhaps a student asks in a forum about some tricky grammar concept, and you have a question that illustrates your reply, well now you can include that question in your reply, so the student can immediately test their understanding.

It is designed to be used with the associated Atto editor plugin which makes it easier to set up the embedding.

Installing the Embedded questions progress report is also recommended. This lets staff and students track what progress has been made at all the embedded questions in a course.

Questions can only be embedded if they have an idnumber set, and where the category the question is in has an idnumber. This is for two reasons: first, to make it harder to accidentally embed questions from your end-of-course exam; and second, because this is how the filter uniquely identifies the question to show.

Note: Essay is not an interactive question.

This plugin was created by the Open University, UK.

### Sets

This plugin is part of set Embed questions.

### Contributors

Mahmoud Kassaei: Developer
Chris Nelson: Product owner
John Beedell: Developer

• Wed, Jul 21, 2021, 8:29 PM
@Laura DiFiore: That is the eventual plan (for the OU, we want to award engagement badges etc.) - it's just getting down to that section of our priority list.

The results are currently posted to the activity and/or course progress report and that can be exported, so the data is there, it's just not hooked in to the Gradebook at the moment.

Of course, if anyone has the knowledge and enthusiasm to contribute that feature, we wouldn't complain! Both of our developers are on leave at the moment, but I will ask if they have any ideas about what you could do once they return.
• Thu, Jul 22, 2021, 4:47 PM
@chris Nelson That's exciting news, I look forward to the eventual plan coming to fruition! It would be so amazing to be able to post questions anywhere *and* have them reflected in the grades, even more awesome if they showed accumulated "points" in an activity from the embedded questions, would work to "gamify" an activity even more :D

I think I found where the embedded question scores are stored in the mdl_question_attempts table, but I just get absolutely lost when I look at the php code of the embedded questions and/or embedded questions progress report plugins. The last time I played around with php coding was way back in the old php 3.0 days (and even back then, I never used php for anything beyond elementary scripting, simple stuff like including text files in html pages or simple contact/email form processing) ... it's pretty much a completely foreign language to me now and everything in Moodle is so interconnected, I feel like every time I made even a small change that should be entirely harmless, I break everything! LOL

It seems like it should be a relatively straightforward thing to take the saved attempts and when a student completes an activity, update their grade to include their embedded question scores but like I said, Moodle is so interconnected ... makes my head spin!

I'll keep reading the code and the even more convoluted (to me lol) developer documentation and maybe it'll eventually start to make sense to me ... hehe, maybe I can come up with some sort of hodgepodge temporary workaround!

Thanks so much for your encouraging response!
• Fri, Sep 3, 2021, 4:05 PM
Hi all,
I wondered if it is alredy possible / will be possible to access the result of the question (was it answered correct or not) to automatically choose the next site in a lesson. Right now my work around is embedding the question in a true/false question page and ask if the item was solved or not. So this is an additional click the student has to do.

So far this is the approach that comes closest to the old goal to make any question type available in lessons I found so far. Great thing!
• Fri, Sep 3, 2021, 4:14 PM
Hi @Simon,

We'd like to make grades available from embedded questions to the Gradebook etc., and it's on the 'to do' list. It's just having the capacity to reach that area of our to-do list!

Of course, we're be super-happy if the community contributed such an enhancement, although it'd worth discussing the technical approach with Tim Hunt first.

In your particular use-case, Lesson would also need an enhancement to work with the embedded question scoring, so that'd be a bit more involved.
• Mon, Sep 6, 2021, 11:01 PM
Well, using this as a work-aroud to the fact that the Lesson activity does not support all the quesiton types in the question bank is a pretty nasty work-around. Really, the lesson activity should be updated to use the question bank - MDL-18954 - but people have been wishing that for decades, and it never happens - but I don't think this should drive changes in the embedded questions filter.
• Sat, Oct 30, 2021, 10:18 AM
Hi Team - fantastic and elegant plugin, but we have hit a snag using it with Wiris questions. Wiris questions by themselves work fine, but not when embedded. They initially display, but after pressing [Check] or Fill with correct an error message is displayed. Other (non-Wiris) question types work when embedded, including in the same place (Moodle Book). I've pasted the debug info below, but are not really sure where to start. Any advice would be appreciated.

Thanks,
Andrew (Massey University, New Zealand)

Your previous attempt at a question here has stopped working. If you click continue, it will be removed and a new attempt created.

×Debug info: moodle_exception: Question ids mismatch in [dirroot]/lib/setuplib.php:498
Stack trace:
#0 [dirroot]/filter/embedquestion/classes/attempt.php(199): print_error('questionidmisma...', 'question')
#1 [dirroot]/filter/embedquestion/classes/attempt.php(153): filter_embedquestion\attempt->setup_usage_info(Object(question_usage_by_activity), 1)
#2 [dirroot]/filter/embedquestion/showquestion.php(74): filter_embedquestion\attempt->find_or_create_attempt()
#3 {main}
Error code: corruptattempt
×Stack trace:
line 498 of /lib/setuplib.php: moodle_exception thrown
line 87 of /filter/embedquestion/showquestion.php: call to print_error()

Wiris:
https://moodle.org/plugins/browse.php?list=set&id=66
• Sun, Oct 31, 2021, 12:04 AM
If other question types are working, this sounds like a but with the WIRIS question types, not with this filter. Have you reported this to them?
• Sun, Oct 31, 2021, 2:14 AM
Hi Tim, Yes I have. I was hoping your insight into the embed plugin might be able to guide the Wiris team to a solution. Regards.
• Mon, Nov 22, 2021, 2:13 PM
Just closing the loop Tim. Our support partner (Catalyst IT) have developed a fix which has been accepted by Wiris. The wiris plugin does not set the "idnumber" value on the questiontype object which resulted in the error.
• Sun, Feb 6, 2022, 6:28 AM
I installed this plugin and have successfully embedded an essay question to the content page of a lesson activity, but from the student view, there is no submit button so the student can submit the text written. I want to use the embed questions filter because essay questions added from the content bank (for quizzes) have the option for general feedback text (whereas the lesson activity's essay question does not). Is the embed questions filter not able to be used properly in the lessons activity?
• Mon, Feb 7, 2022, 4:51 PM
Hi @Sarah Poulin,
Embedded question is designed to be used with interactive questions. Essay is non-interactive, requiring a human marker. We have had "Exclude Essay from being selectable" and "Invent interactive Essay question behaviour" neck-and-neck in our development list for a while now, but have not had the capacity to complete either feature

If you want interactive short-text response, there's ShortAnswer, although we at the OU prefer PatternMatch (https://moodle.org/plugins/qtype_pmatch).
• Fri, May 20, 2022, 8:24 PM
Hello Tim,
first of all thank you so much for developping and maintining this plugin that is making 100% of our 700 exercices work. We are huge fan of your work. We just went through 4.0 update, and our trainee came with a long face and a question that no one here could answer :
Does the wonderfull agregated statistics in the question bank count the attempt made through embeded questions ?
Balthazar.
• Fri, May 20, 2022, 9:50 PM
I am afraid that it does not. The embedded question filter has never computed statistis. The display in the question bank only aggregates what statistics exist - which at the moment means only the quiz.

In future, it might be possible to develop a new feature where the embedded question filter computes statistics, however someone would have to do that an it is not currently on our roadmap. Also, while some statistics could be calculated, such as facility index and standard deviation, others pose a problem. For example Discrimination index etc, depend on comparing the score for this question against the score for all the other questions in the same quiz - and each embedded question stands alone. It is not clear what could stand in the place of that concept to lead to meaningful numbers. There is a challenge for someone.

If anyone wants to try to develop something here, I think it could either be added to the existing report (https://moodle.org/plugins/report_embedquestion) or someone could make a new report_embedequestionstats. I think either option could work. However, given the amount of stuff on our todo list, I fear that waiting for us to develop something is probably not a good idea. However, if someone does try, then I should be able to offer advice and help get it released.
• Wed, May 25, 2022, 5:14 PM
Hello Tim,
thank you for your quick reply, altough we've been going through lots of ups and downs since.
First of all, we thought about quiting embed question and get back to quizz, even though we loved this plugin. But we went to see the report_embed question, and it seems that not only, it is abosolytely enough to roughly see which question are bugging, but it also gives the student the possibility to return to a book, and see their previous attempts <3
We will try, with oiur capacity (none of us is developper), to provide the community a .excel file that allow to treat the datas exported from the embed question filter.

However, going through the language settings of the plugin, i noticed that it was possible to access certain fields of the question with commands such as {$a->name}. My new question is : would it be possible to "hack" embed question to allow unauthentified users to "see" without interacting the question of the quizz ? I tought about modifying the error message "guest are not allowed to see this question" by an "{$a->question}" for instance.

Thanks you so much for everything !
Balthazar
• Wed, May 25, 2022, 5:51 PM
A read-only display fo the questoin for guest users is something that probably could be implemented (you make that suggestion at https://github.com/moodleou/moodle-filter_embedquestion/issues so we don't forget about it). However, I don't think there is any way it could be done just with a quick and dirty hack. It would need to be implemnted properly. (And, I think it is not something we need at the Open University, so I doubt we would have time to work on it ourselves, but this is open source, so if someone else develops in with good code, we will integrate it with thanks.)