Embed questions filter

Filters ::: filter_embedquestion
Maintained by Tim at Lone Pine Koala SanctuaryTim Hunt, John Beedell, at the OU (Perry building)Mahmoud Kassaei
A Moodle text filter plugin that displays questions from the question bank embedded in the page.
Latest release:
881 sites
43 fans

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 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 qustion 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 lest 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.

This plugin was created by the Open University, UK.


This plugin is part of set Embed questions.


Screenshot #0
Screenshot #1
Screenshot #2


Tim at Lone Pine Koala Sanctuary
Tim Hunt (Lead maintainer)
John Beedell: Developer
at the OU (Perry building)
Mahmoud Kassaei: Developer
Chris Nelson: Product owner
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Fri, Jan 15, 2021, 1:19 AM
    Does the filter work on global categories in the question bank or only the categories in the current course?
  • Tim at Lone Pine Koala Sanctuary
    Fri, Jan 15, 2021, 1:25 AM
    Only the current course.
  • Thu, Feb 11, 2021, 10:23 AM
    Hi Mr. Tim,
    if its only work for current course categories so we can not import the embed questions to another course,right?
    because when im trying to import to another course the multiple choice is missing.
  • Mohamed Hilmi
    Fri, Feb 26, 2021, 2:16 AM
    I have a problem with the embedquestion plugin, it is well installed with its update, and every time I save, a message appears as: class'backup_report_embedquestion_plugin 'not found
    I would like to know how to solve this problem which prevents me from saving my work.
    thank you
    Mr HILMI
  • Tim at Lone Pine Koala Sanctuary
    Fri, Feb 26, 2021, 2:20 AM
    What version of Moodle are you on? I guess an old one. Go into the report/embedquestion folder, and delete the 'backup' folder there.
  • Wed, Jul 21, 2021, 10:58 AM
    Love this plugin! I *really, really* needed the ability to post questions on the same page as a lesson in the Lesson module, and this was the perfect solution. Took me a while to realize, however, that scores earned through embedded questions do not post into the gradebook.

    Is there any plan for embedded questions to save the grade into the gradebook? If not, any chance you could point me in the right direction on how I could adapt this to save embedded question scores in the gradebook? I've looked at the source code but my php knowledge is rudimentary at best ... I got lost pretty quickly!

    Thanks so much for all that you do!
  • 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! smile 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.
  • Tim at Lone Pine Koala Sanctuary
    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.

    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.

    More information about this error

    ×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()

  • Tim at Lone Pine Koala Sanctuary
    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.
1 2 3 4 5
Please login to post comments