Question Authors' Forum

Error when creating questions with a new custom question type

 
Picture of James Bryan
Error when creating questions with a new custom question type
by James Bryan - Saturday, 20 January 2018, 3:18 AM
 

Hi Everyone, 

I have been using the C# question type as provided here: http://coderunner.org.nz/mod/forum/discuss.php?d=79

using the steps to create a question type here: http://coderunner.org.nz/mod/book/view.php?id=193&chapterid=749


However, I am running into the issue where I can save the new question type and have it displayed in the question types dropdown, however, if I go to create a new question with the custom question type I get the error: 

"Error loading prototype: Error fetching prototype. qtype_coderunner/Prototype DEMO_C_VIA_PYTHON is unavailable in this context, or does not exist."

The original question I created the question type for, works perfectly, however I can not create any more questions using the question type.

If any more information is required, please ask.

Thank you.

Regards

James

Picture of Martin Zwerschke
Re: Error when creating questions with a new custom question type
by Martin Zwerschke - Saturday, 20 January 2018, 6:22 AM
 

I had this issue as well but it was only a matter of renaming the prototype.

It somehow depended on the right timing of renaming and using the prototype.

I got this working after some trying but can not remember the steps I followed to solve that naming conflict.

Picture of Richard Lobb
Re: Error when creating questions with a new custom question type
by Richard Lobb - Saturday, 20 January 2018, 10:26 AM
 

This sounds like it might the bug that I became aware of earlier this week via another forum posting: you can create question types with names containing any characters you like but when you try to use them, non-alphanumeric characters are filtered out of the requested type name. This results in "Error fetching prototype." 

So perhaps try a type name like 'csharp_function' rather than 'c#_function'?

The fix I have in my development system is to constrain question types to be alphanumeric when you first create the prototype, but I'm starting to wonder if I shouldn't instead allow arbitrary white-space trimmed strings. 

Richard

Picture of James Bryan
Re: Error when creating questions with a new custom question type
by James Bryan - Saturday, 20 January 2018, 2:09 PM
 
This was indeed the issue.


Thank you