Updating Calculated question gives Error: mdb->get_record() found more than one record!

Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Peter Halverson -
Number of replies: 7

Hello,

I recently migrated from the free iteach.org moodle server to a server on Hostgator.com

After this migration, I am getting this error, repeated dozens of times, every time I edit/update a calculated question:

Error: mdb->get_record() found more than one record!

    * line 1309 of /lib/dml/moodle_database.php: call to debugging()
    * line 1269 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
    * line 1249 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
    * line 1039 of /question/type/calculated/questiontype.php: call to moodle_database->get_record()
    * line 414 of /question/type/calculated/datasetitems_form.php: call to qtype_calculated->comment_on_datasetitems()
    * line 218 of /question/question.php: call to question_dataset_dependent_items_form->set_data()

The new system is Moodle 2.2.1 (Build: 20120109)

The old system was Moodle 2.0.3+ (Build: 20110623)

A few other comments:  The calculated questions seem to be fully functional, and the editing process seems to work.  But getting all these errors doesn't "feel" good.  Should I be worried?

Is there some way to make these errors go away?  Surgery on the moodle database?

I did have some problems with running out of memory during the restore process.  I had to restore my course in small "chunks".

Right now cron.php is not working.  Could this cause the trouble? (Seems unlikely to me.)

Thanks in advance,

Peter Halverson

Average of ratings: -
In reply to Peter Halverson

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Pierre Pichet -

Could you export some of those questions ( moodle xml ) and attach the resulting file here.

Pierre

In reply to Pierre Pichet

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Pierre Pichet -

the database call seems to be

        if (!empty($questionid) && $unit = $DB->get_record('question_numerical_units',
                array('question' => $questionid, 'multiplier' => 1.0))) {

If you are using MySQL as database and you have defined 2 units with the same multiplier 1.0 you will get more than 1 record.

This is a bug as it could legitimate to have two different units with 1.0 as multiplier.

I will search in the tracker and set a bug if necessary.

Pierre

In reply to Pierre Pichet

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Pierre Pichet -

Could you look at the table question_numerical_units to see if the records are unique to a given question id ?

Perhaps something went wrong in migrating ?

Pierre

 

In reply to Pierre Pichet

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Pierre Pichet -

I can reproduce in moodle demo site when setting two units with multiplier = 1 .

Error: mdb->get_record() found more than one record!

  • line 1309 of /lib/dml/moodle_database.php: call to debugging()
  • line 1269 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1249 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 1039 of /question/type/calculated/questiontype.php: call to moodle_database->get_record()
  • line 467 of /question/type/calculated/datasetitems_form.php: call to qtype_calculated->comment_on_datasetitems()
  • line 218 of /question/question.php: call to question_dataset_dependent_items_form->set_data()

 

So I will create a bug

In reply to Pierre Pichet

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

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

Pierre has now created MDL-31521.

In reply to Pierre Pichet

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Peter Halverson -

Hi again,

I think you have nailed the problem.  When I change the units that used to be

N 1      Newton 1      Newtons 1

to be

N 1      Newton 1.001      Newtons 1.002

the problem goes away.

Whew!  I feel much relieved.   I presume, this is not a life-threatening bug, and that my investment in Moodle is not at risk.

Thanks!!!!

Peter Halverson

In reply to Pierre Pichet

Re: Updating Calculated question gives Error: mdb->get_record() found more than one record!

by Peter Halverson -

Hello/Bounjour Pierre,

Yes...  I am attaching an xml file which contains two questions that cause the problem.

I do use units, and yes, they do have repeating magnitudes.  For example

Newton 1    N 1  Newtons 1

Many thanks for researching this.

Peter Halverson