JSME question type - problems with imported questions

JSME question type - problems with imported questions

by María José Blanes -
Number of replies: 6

Hi,

I'm using Moodle 2.8.5 ($release  = '2.8.5+ (Build: 20150421)';) and JME plugin 2.11 ($plugin->release   = '2.11 for Moodle 2.6+';).

I can create new jsme questions without problem.

I've restored a course from Moodle 2.7 containing questions created with the "old" jme plugin.

When I access the preview from the question bank I get messages like:


Notice: Undefined property: stdClass::$jmeoptions in /aplica/moodle/www/moodle/question/type/questiontypebase.php on line 865

Notice: Undefined property: stdClass::$width in /aplica/moodle/www/moodle/question/type/questiontypebase.php on line 865

Notice: Undefined property: stdClass::$height in /aplica/moodle/www/moodle/question/type/questiontypebase.php on line 865


And other times I get:

Detectado un error de codificación, debe ser corregido por un programador: The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course.

Más información sobre este error

Debug info: Stack trace when the theme was set up: <ul style="text-align: left" data-rel="backtrace"><li>line 1648 of /lib/setuplib.php: call to moodle_page->initialise_theme_and_output()</li><li>line 774 of /question/type/questiontypebase.php: call to bootstrap_renderer->__call()</li><li>line 774 of /question/type/questiontypebase.php: call to bootstrap_renderer->notification()</li><li>line 831 of /lib/questionlib.php: call to question_type->get_question_options()</li><li>line 865 of /lib/questionlib.php: call to _tidy_question()</li><li>line 516 of /question/engine/bank.php: call to get_question_options()</li><li>line 328 of /cache/classes/loaders.php: call to question_finder->load_for_cache()</li><li>line 1454 of /cache/classes/loaders.php: call to cache->get()</li><li>line 479 of /question/engine/bank.php: call to cache_application->get()</li><li>line 255 of /question/engine/bank.php: call to question_finder->load_question_data()</li><li>line 274 of /question/engine/bank.php: call to question_bank::load_question_data()</li><li>line 46 of /question/preview.php: call to question_bank::load_question()</li></ul>
Error code: codingerror
Stack trace:
  • line 1832 of /lib/pagelib.php: coding_exception thrown
  • line 914 of /lib/pagelib.php: call to moodle_page->ensure_theme_not_set()
  • line 2964 of /lib/moodlelib.php: call to moodle_page->set_course()
  • line 56 of /question/preview.php: call to require_login()
Output buffer: <div class="alert alert-error">Failed to load question options from the table qtype_jme_options for questionid 97</div> Notice: Undefined property: stdClass::$jmeoptions in /aplica/moodle/www/moodle/question/type/questiontypebase.php on line 865 Notice: Undefined property: stdClass::$width in /aplica/moodle/www/moodle/question/type/questiontypebase.php on line 865 Notice: Undefined property: stdClass::$height in /aplica/moodle/www/moodle/question/type/questiontypebase.php on line 865


When I click on edit the question, I get:

Failed to load question options from the table qtype_jme_options for questionid 96
Notice: Undefined property: stdClass::$answers in /aplica/moodle/www/moodle/question/type/edit_question_form.php on line 328



On the one hand, it seems that the correct answers are not loaded and in the other hand it seems that there are no entries in the qtype_jme_options table for the imported questions.

Any idea what is happening?

Thanks!

Average of ratings: -
In reply to María José Blanes

Re: JSME question type - problems with imported questions

by Jean-Michel Védrine -

Thanks Maria José for the report.

Could you  send to me a backup from 2.7 that contains questions that fail to restore ?

In reply to Jean-Michel Védrine

Re: JSME question type - problems with imported questions

by María José Blanes -

Thanks for your quickly response.

I send to you a link of the backup of the course containing only the question bank in order to reduce the file size:

https://dl.dropboxusercontent.com/u/14358767/copia_de_seguridad-moodle2-course-1182-qu%C3%ADmica_26510-20150504-1654-nu.mbz


In the question bank you will find two categories named "JAVA" containing the JME questions.


In reply to María José Blanes

Re: JSME question type - problems with imported questions

by Jean-Michel Védrine -

Hello Maria José,

Thanks for the sample file. The fix was easy as I just had to adapt some Tim's code smile.

I just released version 2.12 (see https://moodle.org/plugins/pluginversions.php?plugin=qtype_jme) that should fix this problem. It will also repair existing broken questions.

Again thanks for reporting the problem.


In reply to Jean-Michel Védrine

Re: JSME question type - problems with imported questions

by María José Blanes -

Hello Jean-Michel,

thanks a lot for your help.

The new version seems to work fine in mysql but I have a "little" problem with a Oracle database.

I think the problem is that, in the "mdl_qtype_jme_options" table, the column "jmeoptions" can't be null, and Oracle understands the double quotes as a null.


Debug info: ORA-01400: no se puede realizar una inserción NULL en ("MOODLEADM1516"."M_QTYPE_JME_OPTIONS"."JMEOPTIONS")

INSERT INTO m_qtype_jme_options (questionid, jmeoptions, width, height)
SELECT q.id, '', 360, 315
FROM m_question q
WHERE q.qtype = 'jme'
AND NOT EXISTS (
SELECT 'x'
FROM m_qtype_jme_options qeo
WHERE qeo.questionid = q.id)
[array (
)]
Error code: dmlwriteexception
Stack trace:
  • line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 271 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()
  • line 1029 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
  • line 121 of /question/type/jme/db/upgrade.php: call to oci_native_moodle_database->execute()
  • line 537 of /lib/upgradelib.php: call to xmldb_qtype_jme_upgrade()
  • line 1626 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 434 of /admin/index.php: call to upgrade_noncore()


I hope it wont be hard to find a solution and you can help me.


Regards,

María


In reply to María José Blanes

Re: JSME question type - problems with imported questions

by Jean-Michel Védrine -

Hello Maria,

I test my work with mysql and Postgesql but I am unable to do any test with Oracle. And I know nearly nothing about Oracle my only experience was about 30 years ago !

I know Oracle is very special for handling of empty strings/nulls, and that in fact when the content of a field is an empty string it's the same as if it was null so the first thing to try is to change the jmeoptions field in the qtype_jme_options table from NOTNULL="true" to NOTNULL="false" (but I don't known how to do that with Oracle, maybe there is some Oracle utility like phpMyAdmin for MySql or PgAdmin for Postgesql)

But I am fearing this will uncover some other problems because when the content of this field is retrieved from the database it will not be an empty string, it will be null.

Maybe Tim or someone else know what I could do to make my code compatible with Oracle ?


In reply to Jean-Michel Védrine

Re: JSME question type - problems with imported questions

by María José Blanes -

Ok,

I don't know so much about databases. smile

I asked a mate in charge of database management that allows null values in that column in our test environment.

As soon as I can, I'll do some tests to check the operation and the possible side effects.

Please, let me know if you obtain help to make your code compatible with Oracle.

Thanks for your help.

Regards,

María