Could not insert record in database table

Could not insert record in database table

by Tom B -
Number of replies: 10
When using Quizport to a) add a qedoc URL and when b) trying to upload/insert a HotPotatoes quiz I get the error message
"Could not insert record in database table: quizport_units"
What is that, how do I fix it


Average of ratings: -
In reply to Tom B

Re: Could not insert record in database table

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Tom,
If you go to Site administration -> Modules -> activities -> QuizPort, what version number is written for QuizPOrt?

At the end of the following thread, is advice about how to get more info about why the quizport_units record cannot be added. Please try that and let us know what you find out.

thanks
Gordon

In reply to Gordon Bateson

Re: Could not insert record in database table

by Tom B -
Hi,

I can't find a Quizport # in Moodle, but I downloaded the zip file yesterday and it is
quizport-module.0.9.x.zip

I added the line of code, now I get:

Hi Tom. The quizport_units record could not be added:
Column 'allowresume' cannot be null


In reply to Tom B

Re: Could not insert record in database table

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Thanks Tom,
please could tell me your versions of PHP, MySQL and Moodle?

Using your favorite database administration tool (phpMyAdmin?) please could you tell me the "allowresume" field in the "quizport_units" table has a default value set?

thanks
Gordon
In reply to Gordon Bateson

Re: Could not insert record in database table

by Tom B -
Hi,

> please could tell me your versions
MySQL database 5.0.67
PHP 4.4.9
Moodle 1.9.5+ (Build: 20090617)


> the "allowresume" field in the "quizport_units" table
Field.........Type.......Null.....Default.....Comments
allowresume ..tinyint(2).No.......1...................

output of table attached as CSV


Thanks,
Tom



In reply to Tom B

Re: Could not insert record in database table

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Tom,
that's great info. Thanks a lot.

I am surprised that MySQL complains about a field being null when it also knows that the default is 1. On other sites I have worked on which use MySQL 5.0.51 it is not a problem.

I will try a few more tests and update the QuizPort module to always fill in the not null fields. Please give me a day or so to work on it. I will let you know when the new download is ready.

cheers
Gordon
In reply to Gordon Bateson

Re: Could not insert record in database table

by Tom B -
Yes, please notify me. And thanks for all your work. I'm excited that Glossary should work with this. That will help a lot.


In reply to Tom B

Re: Could not insert record in database table

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Tom,
please could you download the attached replacement for "mod/quizport/lib.php". I think it will fix the missing default values for the quizport_unit record.

You may still get errors when adding other records, so please send feedback as to how you get on. Once you have confirmed it works, I will add the modification to the main module.

thanks
Gordon

P.S. Please note that this download is meant just for Tom and others who are having a similar problem and wish to work with me to fix it. Everybody else need take no action smile
In reply to Gordon Bateson

Re: Could not insert record in database table

by Tom B -
Definite progress, it uploaded, I answered the Qs, click Check Answers, got 100%, clicked OK

but then I am presented with
http://www.bestenglish123.com/moodle/mod/quizport/attempt.php

SELECT qqa.id AS qqa_id,qqa.quizid AS qqa_quizid,qqa.userid AS qqa_userid,qqa.unumber AS qqa_unumber,qqa.qnumber AS qqa_qnumber,qqa.status AS qqa_status,qqa.penalties AS qqa_penalties,qqa.score AS qqa_score,qqa.duration AS qqa_duration,qqa.starttime AS qqa_starttime,qqa.endtime AS ...

full contents displayed.

Maybe there is an easy fix for this.

file attached

Also the Results show the Quiz as not being completed
Attempt Grade Status Duration Last access
1 0 Abandoned Thu, 18 Jun 2009, 06:28 PM
2 0 Abandoned Thu, 18 Jun 2009, 06:29 PM
3 0 Abandoned Thu, 18 Jun 2009, 06:35 PM
4 0 In progress Thu, 18 Jun 2009, 06:35 PM

In reply to Tom B

Re: Could not insert record in database table

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
hi Tom,
your server is behaving like no other I have come across, so I must confess that at that moment I am mystified thoughtful

Could I possibly come and have a look firsthand? Please contact me by private email: gordon at-sign kanazawa hyphen gu dot ac dot jp.

thanks
Gordon
In reply to Gordon Bateson

Re: Could not insert record in database table

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Dear Tom,
thanks for giving me access to your server and allowing me to investigate the cause of the strange behavior of QuizPort.

In an nutshell, there were a several lines of PHP code in QuizPort that were not compatible with PHP4, which your server is using.
  • a couple of uses of html_entity_decode() which caused an alarming number of "cannot yet handle MBCS" messages
  • several instances of the results of a function being assigned by reference:
    e.g. $object = &$this->get_object()
  • a few lines which treat results of object methods as objects
    e.g. $PAGE->get_requires()->yui_lib('yahoo')->asap();
All of the above are valid in PHP5, but not valid in PHP4

I have now fixed all the above problems and QuizPort is working on your server. Yay!

Of course, if you come across further problems, please don't hesitate to let me know.

best regards
Gordon