Error reading from database

Error reading from database

by abdelaziz facoiti -
Number of replies: 5

Hello  guys ,

I'm new here , I hope everyone is in good health during this pandemic

I'm facing this Error , and this is what the debugging show : 

Debug info: Table 'moodle.mdl_competency_usercomp' doesn't exist
SELECT COUNT('x') FROM mdl_competency_usercomp uc
JOIN mdl_competency c
ON c.id = uc.competencyid
JOIN mdl_user u
ON u.id = uc.userid
WHERE (uc.status = ?
OR (uc.status = ? AND uc.reviewerid = ?))
AND u.deleted = 0
[array (
0 => 1,
1 => 2,
2 => '2',
)]
Error code: dmlreadexception
Stack trace:
  • line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1227 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1624 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1697 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1907 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 1414 of /competency/classes/api.php: call to moodle_database->count_records_sql()
  • line 79 of /blocks/lp/classes/output/summary.php: call to core_competency\api::list_user_competencies_to_review()
  • line 71 of /blocks/lp/block_lp.php: call to block_lp\output\summary->__construct()
  • line 336 of /blocks/moodleblock.class.php: call to block_lp->get_content()
  • line 230 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 1181 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1233 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 643 of /lib/outputrenderers.php: call to block_manager->ensure_content_created()
  • line 218 of /theme/adaptable/layout/includes/header.php: call to core_renderer->standard_head_html()
  • line 30 of /theme/adaptable/layout/dashboard.php: call to require_once()
  • line 1374 of /lib/outputrenderers.php: call to include()
  • line 1304 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 164 of /my/index.php: call to core_renderer->header()

Average of ratings: -
In reply to abdelaziz facoiti

Re: Error reading from database

by Евгений Мамаев -
Picture of Plugin developers
Can you please check if table moodle.mdl_competency_usercomp exists in your database?
In reply to Евгений Мамаев

Re: Error reading from database

by abdelaziz facoiti -
Hello , thanks for the reply
it doesn't exist and Moodle was working fine before.
In reply to abdelaziz facoiti

Re: Error reading from database

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
What's your Moodle version and when did this start - if it's not always done it what changed?

What do you have to do to get this error to appear?
In reply to Howard Miller

Re: Error reading from database

by abdelaziz facoiti -
Hello , thanks for the reply
I have 3.9dev (Build: 20200312)
and this appears when I try to log in to admin or any other user tried to log in.
latest thing I recall before this happening is an exam test that a teacher did.
In reply to abdelaziz facoiti

Re: Error reading from database

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

3.9dev was a development version and should not be used for a production site. You should plan to update the site to the latest release, 3.9.4. Updating from an unsupported development version may have unexpected problems so I'd recommend doing a test update first.

But mdl_competency_usercomp was added in Moodle 3.1 so it should definitely be present. You could create the table using the definition below but that doesn't explain how you've ended up with non-production code with a missing table.

CREATE TABLE `mdl_competency_usercomp` (
  `id` bigint(10) NOT NULL AUTO_INCREMENT,
  `userid` bigint(10) NOT NULL,
  `competencyid` bigint(10) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT 0,
  `reviewerid` bigint(10) DEFAULT NULL,
  `proficiency` tinyint(2) DEFAULT NULL,
  `grade` bigint(10) DEFAULT NULL,
  `timecreated` bigint(10) NOT NULL,
  `timemodified` bigint(10) DEFAULT NULL,
  `usermodified` bigint(10) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mdl_compuser_usecom_uix` (`userid`,`competencyid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  ROW_FORMAT=COMPRESSED COMMENT='User competencies';