Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's needed for adding new question types? #52

Open
NiallTracey opened this issue May 3, 2022 · 3 comments
Open

What's needed for adding new question types? #52

NiallTracey opened this issue May 3, 2022 · 3 comments

Comments

@NiallTracey
Copy link

Hi,

I was about to start work on a Python script to generate matching exercises for Canvas (having decoded the format by staring at the QTI export files I used to copy a quiz between modules) and thought that rather than doing it separately, it might be worth integrating it with text2qti.

Before I start staring at source code and trying to reverse engineer the logic (something my brain doesn't particularly like doing) I thought I'd just ask if anyone can give me a quick summary of all the steps I need to follow and all the bits of code I need to work with.

I'm a competent Python programmer, so I don't need much handholding, I'm just on the spectrum and always feel frustrated if I'm not sure I'm looking in the right place or that there isn't something somewhere else that I'll need to look at.

All I basically need is something like:
"The parsing is handled in xyz.py; you need to add a line in method abc that defines the regular expression, and a new method for parsing it here. You also need to create an object with x,y,z methods to create the output.

If I get the matching exercise to work, I'd likely follow up by implementing the fill in multiple gaps and multiple dropdown question types, as they're both things that I like to use, but right now they're a bit fiddly for me to generate. (My institution doesn't have New Quizzes enabled, so I wouldn't be able to do anything with Hotspot or Stimulus question types right now.)

Thanks.

@gpoore
Copy link
Owner

gpoore commented May 3, 2022

Adding support for more question types would be good! I have been very busy, so adding support for question types I don't use myself hasn't been possible.

The first thing to do for a new question type is decide on the syntax. The basic approach (at least so far) is that anything that is not indented at the start of a line marks elements of a question, and then anything that follows the start-of-line markers or is indented is content that is treated as Markdown or otherwise processed. So in

1.  What is 2+3?
a)  6
b)  1
*c) 5

The 1. and the letters aren't indented and mark the elements of the question, and everything after the markers is content.

I'd suggest opening an issue to discuss syntax for a new question type before starting on the programming. It would be good to keep syntax consistent with what already exists, and keep parsing as simple as possible.

The parsing happens in question.py. Regex patterns for question elements are defined at the beginning. Currently, a single Question class is used for all questions. There are methods that handle parsing for each question type's elements. At some point, it may make more sense to have a subclass for each specific question type. Most of the programming goes back to the beginning of COVID when I had to have something working within a few days, so there are probably a number of points where the overall design could be improved.

XML templates and associated logic are in xml_assessment.py.

Ideally, any question type should be able to be exported via Pandoc to create solutions etc. That is in export.py. Each question type has a few lines of logic for converting it into a Pandoc-compatible Markdown format.

You can probably get a good sense for how a lot of this works by searching for case-insensitive mctf (multiple-choice/true-false) in question.py, xml_assessment.py, and export.py. Or find the variable naming scheme for another question type, and do a search for that.

I'm happy to answer questions, but that sometimes may take a while. Work + life + perhaps too many open source projects is keeping me quite busy at present.

@NiallTracey
Copy link
Author

Perfect -- thanks.

I've added two new issues -- I figure multiple gaps and multiple dropdowns are similar enough that the two need to be considered in tandem.

Had a quick look at the source, and I'm starting to think more and more about how I could maybe hook directly into it to generate questions programmatically rather than always generating the text file as an intermediate step.

@erlebach
Copy link

@NiallTracey : any progress on your project? I just learned about text2qti, and I am having GPT-4 generated quizzes automatically for me in a format that is suitable for text2qti input. At the moment I am looking to have questions comprised of text and code snippets.
By the way, I found that you need a minimum of four indents for fenced code. I tried with more and that is fine. With less than four indents, there is an error. Seems like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants