Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-13399

Database having visible field in more then 1 table now

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Labels:
      None
    • Environment:
      windows 2003, MS SQL, IIS
    • Database:
      Microsoft SQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      I just installed my moodle 1.9 beta and found there are some programming error in it. One of the obous is the course and course_categories table both contains visiable but the selecting sql in the program was not specified accordingly, resulting so, courses will not be listed.

      If anyone of you discovered solution to this, please let me know, in the meanwhile, I hardcoded the php file

      Try this...

      install moodle -> configure 1 teacher(editing)
      then configure 1 course
      Logout
      login using teacher -> click on the course

      you will not see the week by week or issue by issue planner

      display your errors and you will see what i meant

      Again....
      Then logout
      the list of courses should show in the front page
      click on the course, moodle will ask you to login
      then you login and you will see another error.

      -------------
      The error message as below:-

      [Microsoft][ODBC SQL Server Driver][SQL Server]Ambiguous column name 'visible'.

      SELECT c.id,c.sortorder,c.shortname,c.idnumber,c.category,c.fullname,c.teacher,c.teachers,c.student,c.students,c.guest,c.startdate,c.visible,c.newsitems,c.cost,c.enrol,c.groupmode,c.groupmodeforce, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, cc.path AS categorypath FROM mdl_course c JOIN mdl_course_categories cc ON c.category=cc.id JOIN mdl_context ctx ON (c.id=ctx.instanceid AND ctx.contextlevel=50) LEFT OUTER JOIN mdl_role_assignments ra ON (ra.contextid=ctx.id AND ra.userid=9) LEFT OUTER JOIN mdl_role_capabilities rc ON (rc.contextid=ctx.id AND (rc.capability='moodle/course:view' )) WHERE ra.id IS NOT NULL OR rc.id IS NOT NULL ORDER BY visible DESC, fullname ASC
      line 686 of lib\dmllib.php: call to debugging()
      line 1002 of lib\accesslib.php: call to get_recordset_sql()
      line 913 of lib\datalib.php: call to get_user_courses_bycap()
      line 41 of blocks\course_list\block_course_list.php: call to get_my_courses()
      line 737 of blocks\moodleblock.class.php: call to block_course_list->get_content()
      line 745 of blocks\moodleblock.class.php: call to block_list->is_empty()
      line 338 of lib\blocklib.php: call to block_list->_print_block()
      line 82 of course\format\topics\format.php: call to blocks_print_group()
      line 206 of course\view.php: call to require()

      Fatal error: Call to a member function FetchRow() on a non-object in D:\moodle\moodle\lib\dmllib.php on line 814
      PHP Fatal error: Call to a member function FetchRow() on a non-object in D:\moodle\moodle\lib\dmllib.php on line 814

      --------------
      Changes that I have to make to are:-

      function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NULL, $doanything=false,$limit=0) {
      to
      function get_my_courses($userid, $sort='c.visible DESC,c.sortorder ASC', $fields=NULL, $doanything=false,$limit=0) {

      and

      if (!empty($sort))

      { $orderby = "ORDER BY $sort"; }

      to

      if (!empty($sort))

      { $orderby = "ORDER BY c.$sort"; }

      and add in

      if ($sort == 'visible DESC, fullname ASC')

      { $sort = 'c.visible DESC, fullname ASC'; }

      in between

      // Non-cached - get accessinfo
      if ($userid === $USER->id && isset($USER->access)) { $accessinfo = $USER->access; } else { $accessinfo = get_user_access_sitewide($userid); }

      +++++++++++++++++++++++++++++++++++++++++
      Added the following IF here
      ++++++++++++++++++++++++++++++++++++++++
      if ($sort == 'visible DESC, fullname ASC') { $sort = 'c.visible DESC, fullname ASC'; }

      +++++++++++++++++++++++++++++++++++++++++

      $courses = get_user_courses_bycap($userid, 'moodle/course:view', $accessinfo,
      $doanything, $sort, $fields,
      $limit);

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              skodak Petr Skoda
              Reporter:
              lowjiunjack Low Jiun Jack
              Participants:
              Component watchers:
              Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08