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

Backup of courses with questions fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.5
    • Fix Version/s: 1.9.6
    • Component/s: Questions
    • Labels:
      None
    • Environment:
      Solaris + Oracle
    • Database:
      Oracle
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      When creating a backup of a course the questions aren't included in the moodle.xml. When we activate the debug tool the followings error are showed:

      ERROR 1 - ORA-00918: column ambiguously defined
      To solve the problem it's necessary to revise the SQL sentence in the question/backuplib.php file (line 167) to add "q." before the id ordering field (as following):

      $questions = get_records_sql("SELECT q.* FROM {$CFG->prefix}backup_ids bk, {$CFG->prefix}question q ".
      "WHERE q.category= $category AND ".
      "bk.old_id=q.id AND ".
      "bk.backup_code = {$preferences->backup_unique_code} ".
      "ORDER BY parent ASC, q.id"); // <----- This is where it's necessary to change id for q.id

      ERROR2 - ORA-01400: cannot insert NULL into ("USU8"."MLBACKUP_IDS"."INFO")
      To solve this problem it's necessary to revise also another SQL sentence in the question/backuplib.php file (line 464) to add a space in the info value:
      $status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
      (backup_code, table_name, old_id, info)
      SELECT '$backup_unique_code', 'question', q.id, ' ' // <----- This is where it's necessary to change '' for ' '
      FROM {$CFG->prefix}question q, {$CFG->prefix}backup_ids bk
      WHERE q.category = bk.old_id AND bk.table_name = 'question_categories'
      AND " . sql_compare_text('bk.info') . " = '$info'
      AND bk.backup_code = '$backup_unique_code'", false);

      Could you include this improvement to the main branch to solve the question backup problem in the following versions?

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            sarjona Sara Arjona (@sarjona)
            Tester:
            Nobody
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              21/Oct/09