Using web service/ajax to mark free-text answers

Using web service/ajax to mark free-text answers

by Damion Young -
Number of replies: 7
I'm looking for some advice from those who know more about Quiz on the best way to approach developing a new question plug-in. I'm working with someone in computational linguistics to create a question type that will mark formative questions to which the answer is a phrase or a sentence or two of free text. As a first step, marking logic will be held on the server so I don't need to worry about the authoring side of things (yet), apart from the question prompt, just the marking. We'll use some sort of UUID to tell the server which question to mark e.g I'll post:


{  
   "q_id":1234567890,
    "answer":"The first thing to do is to investigate hemispheric lateralisation",
}

 

to which I'd get a response something like:


{
  "answer": "The first thing to do is to investigate hemispheric lateralisation",
  "justification": [
    "investigate hemispheric lateralisation "
  ],
  "mark": 1,
  "q_id": 1234567890
}


Given my complete lack of knowledge of Moodle and YUI (although I am a PHP/JQuery/Angular 2 developer), I'd be very grateful for any steers on how best to approach this. 

Long-term, I'm hoping to be able to author the questions in Moodle as well. The marking syntax would be stored as text but I wouldn't want to expose users to this so would create some sort of authoring interface which would graphically represent the marking logic as far as possible and would again be calling third-party services to suggest synonyms, etc.

I see that there is an Opaque question type which would work if I was prepared to write my own question rendering engine but I'm keen to keep as much as possible within Moodle - is this mad? 

Is anyone aware of any question plugins that have attempted to delegate only marking to a third-party service? 

Am I going to have to get to grips with YUI or is there some way I can use JQuery to make requests and and handle responses?

Thanks

Damion


Average of ratings: -
In reply to Damion Young

Re: Using web service/ajax to mark free-text answers

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

You can and probably should use JQuery. You can see an example of the separation of front end and parsing engine in the Stack and Coderunner question types.  Have you seen this question type?

https://moodle.org/plugins/qtype_pmatch

Average of ratings: Useful (2)
In reply to Marcus Green

Re: Using web service/ajax to mark free-text answers

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

Both STACK and CodeRunner use a web service call in the marking process.

My colleague Sally Jordan did quite a lot of work on automatic grading of free text responses a few years ago. you can find her papers at http://oro.open.ac.uk/view/person/sej3.html if you are interested.

Documentation for creating a new question type plugin is at https://docs.moodle.org/dev/Question_types

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

Re: Using web service/ajax to mark free-text answers

by Damion Young -

Thanks Tim. I'll have a peruse of Sally's papers - thanks again. I'll go and see if I can rework one of those question types to do what I need.

Thanks again


In reply to Marcus Green

Re: Using web service/ajax to mark free-text answers

by Damion Young -

Thanks Marcus - I was worried about JQuery because this: https://docs.moodle.org/dev/Question_types mentions YUI/module.js. I'll have a look at Stack and Coderunner. We may well use qtype_pmatch for questions requiring a shorter response but this new question type is aimed at longer answers - we're trying out a couple of approaches - one based on NLP the other on something to do with vectors....that I don't really understand!

Thanks again

In reply to Damion Young

Re: Using web service/ajax to mark free-text answers

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

Oops, that developer documentation page was quite out of date. I have done some edits. It could probably use more.

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

Re: Using web service/ajax to mark free-text answers

by Damion Young -

Thanks Tim - the CodeRunner code now makes a bit more sense!

In reply to Damion Young

Re: Using web service/ajax to mark free-text answers

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

My Gapfill question type used JQuery from the first release in 2012 and it has worked for me ever since. Part of my reasoning was that I had to teach young people Javascript at the time and JQuery was the obvious tool to adopt, so I didn't want to try to keep two systems in my head. 

Since then Yahoo have stopped developing YUI so JQuery has become an even more compelling choice, plus it is now the favoured choice for Moodle development.


I recommend extensive experimentation with creating and testing pmatch questions because it is a tricky area. It would be really good if you come back to this forum and tell us your experiences.

Average of ratings: Useful (1)