Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-17284 Add Olli's new quiz editing UI to Moodle 2.0
  3. MDL-17293

Problem in edit_single_category in question/category_class.php

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      The two lines

      $this->catform_rand->set_data($category);
      $this->catform_rand->display();

      Should not be present. To see why, go to Question Bank management -> Categories tab -> Click on the edit icon next to a category.

      You end up on a page with two forms, when only the top one should be present.

      By the way, the purpose of the code

      if (1 == $DB->count_records_sql("SELECT count
      FROM

      {question_categories} c1,
      {question_categories}

      c2
      WHERE c2.id = ?
      AND c1.contextid = c2.contextid", array($currentcat)))

      { $mform->hardFreeze('parent'); }

      Well, the SQL is counting the number of other categories belonging to the same context as this one. If there is only one, then it is trying to stop you changing the parent (so you can't remove the default category from any context.) However, that should not apply when you are creating a new context. (That applies to the standard create category form too.) Can you either fix this, or create a new issues assigned to me.

      //TODO: Tim: is this questionable? to add a hidden field right from a get parameter?
      $mform->addElement('hidden', 'addonpage', optional_param("addonpage_form", 0, PARAM_SEQUENCE), 'id="rform_qpage"');

      Yes, that is questionable. You should do the optional_param call on the page that loads the form, and pass the data in via the call to set_data. Hmm that is tricky, because the call to set_data is in the initialize method. It might be better to call set_data in display_randomquestion_user_interface(), and pass $addonpage as an argument to that.

        Attachments

          Activity

            People

            Assignee:
            pilpi Olli Savolainen
            Reporter:
            timhunt Tim Hunt
            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:
              24/Nov/10