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

Problem with quiz attempt saving -- issues warning of bad arguments to implode()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: None
    • Component/s: Quiz
    • Labels:
      None
    • Environment:
      FreeBSD
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_13_STABLE

      Description

      Saving a quiz attempt issues a warning. I'm using PHP5 which has stricter error checking, so I'm assuming that's why no one else has passed this along. The underlying problem should still be fixed, however. The problem line of code is in the quiz_save_attempt() function in mod/quiz/lib.php at line 1811. When there is only a single string in $question->answer, $question->answer is not an array and, thus, the implode fails because the arguments are the wrong datatype. The case where $question->answer is a single value (i.e. only one answer) should be checked for. My code fix is as follows:

      if (!empty($question->answer)) {

      if ( ! is_array($question->answer) )

      { $response->answer = $question->answer; }

      else

      { $response->answer = implode(,,$question->answer); }

      } else

      { $response->answer = ; }

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            dougiamas Martin Dougiamas added a comment -

            From Howard Miller (howard.miller at udcf.gla.ac.uk) Wednesday, 30 June 2004, 08:40 PM:

            fixed in CVS

            Show
            dougiamas Martin Dougiamas added a comment - From Howard Miller (howard.miller at udcf.gla.ac.uk) Wednesday, 30 June 2004, 08:40 PM: fixed in CVS
            Hide
            mblake Michael Blake added a comment -

            assign to a valid user

            Show
            mblake Michael Blake added a comment - assign to a valid user

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: