Moodle
  1. Moodle
  2. MDL-8600

SQL Error with Postgres 7.4.16 - Results in SCORM entry page not being show and no API adapter available to the SCO.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.7.1, 1.8
    • Fix Version/s: 1.8, 1.9
    • Component/s: SCORM
    • Labels:
      None
    • Environment:
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Rank:
      24460

      Description

      Symptoms:

      When launching a freshly added SCORM 2004 package it will go straight to the SCORM Player (showing the contents of the first SCO), it does not go to the SCORM Entry page where it lists the table of content and the options such as Browse, Review, Enter Course...

      The first time you run the SCORM package it appears to work pretty normally, but if you complete the SCORM and go back to Review it you will receive messages from the SCO that it cannot find the API Adapter (SCO Generated Messages), this is because it is not there.

      If you then go to Admin/Server/Debugging and set the level to developer you will receive the following messages.

      ERROR: zero-length delimited identifier at or near """" at character 57
      SELECT * FROM mdl_scorm_scoes WHERE scorm=1 AND launch""

      ERROR: invalid input syntax for type bigint: ""
      SELECT scorm FROM mdl_scorm_scoes WHERE id = ''

      ERROR: syntax error at or near "AND" at character 63
      SELECT * FROM mdl_scorm_scoes_track WHERE userid=2 AND scoid= AND attempt=1 ORDER BY element ASC

      The first message is the important one, the other errors are created as a result of the first error.

      The problem is that Postgres doesn't like the double quotes for (launch<>""), changing the double quote for escaped single quotes appears to solve the problem (launch<>\'\')

      I think this is also ok for MySQL but I haven't had chance to check.

      Below is a snippet from the modified locallib.php file which corrects the problem.

      file: moodle/mod/scorm/locallib.php
      function scorm_simple_play($scorm,$user) {
      $result = false;
      $scoes = get_records_select('scorm_scoes','scorm='.$scorm->id.' AND launch<>\'\'');
      if (count($scoes) == 1) {
      if ($scorm->skipview >= 1) {
      $sco = current($scoes);
      if (scorm_get_tracks($sco->id,$user->id) === false)

      { header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id); $result = true; }

      else if ($scorm->skipview == 2)

      { header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id); $result = true; }

      }
      }
      return $result;
      }

      This appears to still be a problem in 1.8 in the stable branch at least, but I haven't checked this in detail.

      One the database error was resolved with the code change mentioned the SCORM packages then behaved correctly, the user would be presented with the SCORM Entry page where they could chose to Browse, Review, Enter the course.

        Activity

        Hide
        Martin Dougiamas added a comment -

        Hi, Max, can you please confirm this and check it in?

        Show
        Martin Dougiamas added a comment - Hi, Max, can you please confirm this and check it in?
        Hide
        Maximino Pecero Sánchez added a comment -

        We have checked this and it is still a problem in 1.8 version. After using this code change, the first and the second error messages would disappear, but we are still receiving the third one. When we are trying to get the records from mdl_scorm_scoes_track we have no value for the scoid field in the query.

        Show
        Maximino Pecero Sánchez added a comment - We have checked this and it is still a problem in 1.8 version. After using this code change, the first and the second error messages would disappear, but we are still receiving the third one. When we are trying to get the records from mdl_scorm_scoes_track we have no value for the scoid field in the query.
        Hide
        Maximino Pecero Sánchez added a comment -

        We checked the problem you told us about and we fix the first and the second error messages with the code you gave us. We found out that the third message was being received because the scoid was missed in player.php. We already fixed that and now when you pressed the "Enter course button" everything works correctly for PostgreSQL.

        Show
        Maximino Pecero Sánchez added a comment - We checked the problem you told us about and we fix the first and the second error messages with the code you gave us. We found out that the third message was being received because the scoid was missed in player.php. We already fixed that and now when you pressed the "Enter course button" everything works correctly for PostgreSQL.
        Hide
        Paul Lewis added a comment -

        Thanks Maximino, that's great.

        Show
        Paul Lewis added a comment - Thanks Maximino, that's great.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: