Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-3641

MSSQL Database Read Error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: Block: AJAX Marking
    • Labels:
      None
    • Affected Branches:
      MOODLE_22_STABLE

      Description

      Block displays the following error:

      Error reading from database
      Debug info:
      SQLState: 42000
      Error Code: 402
      Message: [Microsoft][SQL Server Native Client 10.0][SQL Server]The data types ntext and varchar are incompatible in the equal to operator.
      SELECT countwrapperquery.id AS courseid, countwrapperquery.itemcount, countwrapperquery.timestamp, countwrapperquery.recentcount, countwrapperquery.mediumcount, countwrapperquery.overduecount, course.shortname AS name, course.fullname AS tooltip, countwrapperquery.display, countwrapperquery.groupsdisplay FROM (SELECT moduleunion.course AS id, COUNT(moduleunion.userid) AS itemcount, SUM(CASE WHEN (moduleunion.timestamp > 1336392719) THEN 1 ELSE 0 END) AS recentcount, SUM(CASE WHEN (moduleunion.timestamp < 1336392719 AND moduleunion.timestamp > 1335874319) THEN 1 ELSE 0 END) AS mediumcount, SUM(CASE WHEN moduleunion.timestamp < 1335874319 THEN 1 ELSE 0 END) AS overduecount, MAX(moduleunion.timestamp) AS timestamp, courseconfig.display, courseconfig.groupsdisplay FROM (SELECT sub.userid, sub.timemodified AS timestamp, course_modules.id AS coursemoduleid, moduletable.course, sub.id AS subid, 'assignment' AS modulename FROM mdl_assignment moduletable INNER JOIN mdl_assignment_submissions sub ON sub.assignment = moduletable.id INNER JOIN mdl_course_modules course_modules ON course_modules.instance = moduletable.id AND course_modules.module = 1 WHERE ( (sub.grade = -1 AND sub.submissioncomment = '') OR (moduletable.resubmit = 1 AND (sub.timemodified > sub.timemarked)) ) AND ( moduletable.assignmenttype != 'upload' OR (moduletable.assignmenttype = 'upload' AND sub.data2 = 'submitted')) UNION ALL SELECT sub.userid, sub.modified AS timestamp, course_modules.id AS coursemoduleid, moduletable.course, sub.id AS subid, 'forum' AS modulename FROM mdl_forum_posts sub LEFT JOIN mdl_rating r ON sub.id = r.itemid INNER JOIN mdl_forum_discussions discussions ON sub.discussion = discussions.id INNER JOIN mdl_forum moduletable ON discussions.forum = moduletable.id INNER JOIN mdl_course course ON discussions.course = course.id INNER JOIN mdl_course_modules course_modules ON course_modules.instance = moduletable.id AND course_modules.module = 7 WHERE sub.userid <> '6' AND moduletable.assessed > 0 AND ( ( ( r.userid <> '6' ) AND NOT EXISTS( SELECT 1 FROM mdl_role_assignments ra INNER JOIN mdl_context cx ON ra.contextid = cx.id INNER JOIN mdl_course_categories cat1 ON cx.instanceid = cat1.id LEFT JOIN mdl_course_categories cat2 ON cat1.parent = cat2.id LEFT JOIN mdl_course_categories cat3 ON cat2.parent = cat3.id WHERE(course.category = cat1.id OR course.category = cat2.id OR course.category = cat3.id) AND ra.userid = r.userid AND cx.contextlevel = 40 UNION SELECT 1 FROM mdl_role_assignments ra INNER JOIN mdl_context cx ON ra.contextid = cx.id WHERE cx.contextlevel = 50 AND ra.userid = r.userid AND cx.instanceid = course.id ) ) OR r.userid IS NULL) AND ( ( CONVERT(varchar, moduletable.type, 32) != 'eachuser') OR ( CONVERT(varchar, moduletable.type, 32) = 'eachuser' AND sub.id = discussions.firstpost)) AND ( (moduletable.assesstimestart = 0) OR (sub.created >= moduletable.assesstimestart) ) AND ( (moduletable.assesstimefinish = 0) OR (sub.created <= moduletable.assesstimefinish) ) UNION ALL SELECT quiz_attempts.userid, sub.timecreated AS timestamp, course_modules.id AS coursemoduleid, moduletable.course, sub.id AS subid, 'quiz' AS modulename FROM mdl_quiz moduletable INNER JOIN mdl_quiz_attempts quiz_attempts ON moduletable.id = quiz_attempts.quiz INNER JOIN mdl_question_attempts question_attempts ON question_attempts.questionusageid = quiz_attempts.uniqueid INNER JOIN mdl_question_attempt_steps sub ON question_attempts.id = sub.questionattemptid INNER JOIN mdl_question question ON question_attempts.questionid = question.id INNER JOIN mdl_course_modules course_modules ON course_modules.instance = moduletable.id AND course_modules.module = 14 WHERE quiz_attempts.timefinish > 0 AND quiz_attempts.preview = 0 AND CONVERT(varchar, question_attempts.behaviour, 32) = 'manualgraded' AND sub.state = 'needsgrading' AND NOT EXISTS( SELECT 1 FROM mdl_question_attempt_steps st WHERE st.state IN (N'gradedwrong',N'gradedpartial',N'gradedright',N'mangrwrong',N'mangrpartial',N'mangrright') AND st.questionattemptid = question_attempts.id) UNION ALL SELECT sub.authorid AS userid, sub.timemodified AS timestamp, course_modules.id AS coursemoduleid, moduletable.course, sub.id AS subid, 'workshop' AS modulename FROM mdl_workshop moduletable INNER JOIN mdl_workshop_submissions sub ON sub.workshopid = moduletable.id LEFT JOIN mdl_workshop_assessments a ON sub.id = a.submissionid INNER JOIN mdl_course_modules course_modules ON course_modules.instance = moduletable.id AND course_modules.module = 20 WHERE (a.reviewerid != '6' OR (a.reviewerid = '6' AND a.grade = -1)) AND moduletable.phase < 50 ) moduleunion INNER JOIN mdl_course_modules course_modules ON course_modules.id = moduleunion.coursemoduleid INNER JOIN mdl_course course ON course.id = course_modules.course LEFT JOIN mdl_block_ajax_marking cmconfig ON cmconfig.tablename = 'course_modules' AND cmconfig.instanceid = moduleunion.coursemoduleid AND cmconfig.userid = '6' LEFT JOIN mdl_block_ajax_marking courseconfig ON courseconfig.tablename = 'course' AND courseconfig.instanceid = moduleunion.course AND courseconfig.userid = '6' WHERE EXISTS ( SELECT NULL FROM mdl_enrol enrol INNER JOIN mdl_user_enrolments user_enrolments ON user_enrolments.enrolid = enrol.id WHERE enrol.enrol IN (N'manual',N'self',N'database',N'flatfile') AND enrol.courseid = moduleunion.course AND user_enrolments.userid != '6' AND user_enrolments.userid = moduleunion.userid) AND course_modules.module IN ('1','7','14','20') AND course.visible = 1 AND ( ( NOT EXISTS (SELECT NULL FROM mdl_groups_members groups_members INNER JOIN mdl_groups groups ON groups_members.groupid = groups.id WHERE groups_members.userid = moduleunion.userid AND groups.courseid = moduleunion.course) AND ( COALESCE(cmconfig.showorphans, courseconfig.showorphans, 1) = 1 ) ) OR ( EXISTS (SELECT NULL FROM mdl_groups_members groups_members INNER JOIN mdl_groups groups ON groups_members.groupid = groups.id INNER JOIN ( SELECT group_groups.id AS groupid, group_course_modules.id AS cmid, COALESCE(group_cmconfig_groups.display, group_courseconfig_groups.display, 1) AS display FROM mdl_course_modules group_course_modules INNER JOIN mdl_course group_course ON group_course.id = group_course_modules.course INNER JOIN mdl_groups group_groups ON group_groups.courseid = group_course_modules.course LEFT JOIN mdl_block_ajax_marking group_cmconfig ON group_course_modules.id = group_cmconfig.instanceid AND group_cmconfig.tablename = 'course_modules' LEFT JOIN mdl_block_ajax_marking_groups group_cmconfig_groups ON group_cmconfig_groups.configid = group_cmconfig.id AND group_cmconfig_groups.groupid = group_groups.id LEFT JOIN mdl_block_ajax_marking group_courseconfig ON group_courseconfig.instanceid = group_course_modules.course AND group_courseconfig.tablename = 'course' LEFT JOIN mdl_block_ajax_marking_groups group_courseconfig_groups ON group_courseconfig_groups.configid = group_courseconfig.id AND group_courseconfig_groups.groupid = group_groups.id WHERE group_course_modules.course IN ('2','4','6','8') AND (group_courseconfig.userid = '6' OR group_courseconfig.userid IS NULL) AND (group_cmconfig.userid = '6' OR group_cmconfig.userid IS NULL) AND ( ( (group_course.groupmodeforce = 1 AND group_course.groupmode != 1) OR (group_course.groupmodeforce = 0 AND group_course_modules.groupmode != 1) ) OR ( EXISTS ( SELECT 1 FROM mdl_groups_members teachermemberships WHERE teachermemberships.groupid = group_groups.id AND teachermemberships.userid = '6' ) ) )) existsvisibilitysubquery ON existsvisibilitysubquery.groupid = groups.id WHERE groups_members.userid = moduleunion.userid AND existsvisibilitysubquery.cmid = moduleunion.coursemoduleid AND groups.courseid = moduleunion.course AND existsvisibilitysubquery.display = 1) ) ) AND COALESCE(cmconfig.display, courseconfig.display, 1) = 1 AND moduleunion.course IN ('2','4','6','8') GROUP BY moduleunion.course, courseconfig.display, courseconfig.groupsdisplay ) countwrapperquery INNER JOIN mdl_course course ON countwrapperquery.id = course.id ORDER BY course.shortname ASC [array ( 0 => '6', 1 => '6', 2 => 'gradedwrong', 3 => 'gradedpartial', 4 => 'gradedright', 5 => 'mangrwrong', 6 => 'mangrpartial', 7 => 'mangrright', 8 => '6', 9 => '6', 10 => '6', 11 => '6', 12 => 'manual', 13 => 'self', 14 => 'database', 15 => 'flatfile', 16 => '6', 17 => '1', 18 => '7', 19 => '14', 20 => '20', 21 => 2, 22 => 4, 23 => 6, 24 => 8, 25 => '6', 26 => '6', 27 => '6', 28 => 2, 29 => 4, 30 => 6, 31 => 8, )]
      Stacktrace:

      • line 394 of \lib\dml\moodle_database.php: dml_read_exception thrown * line 252 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end() * line 368 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end() * line 773 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query() * line 807 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql() * line 669 of \blocks\ajax_marking\classes\query_base.class.php: call to sqlsrv_native_moodle_database->get_records_sql() * line 169 of \blocks\ajax_marking\classes\nodes_builder.class.php: call to block_ajax_marking_query_base->execute() * line 58 of \blocks\ajax_marking\actions\ajax_nodes.php: call to block_ajax_marking_nodes_builder::unmarked_nodes()

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: