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

Name for imported cloze questions cleaned of all tags

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.3, 1.9, 2.0
    • Fix Version/s: 1.9.10, 2.0
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      We had several teachers importing long cloze questions with a lot of format-related information at the top of the file being imported. As the whole first line of the import file is now used for creating the name of the question, it happened quite often that the question bank page was almost illegible with question names bearing all the formatting info (and sometimes being veeery long).

      So we decided we want the question name
      1) to comprise only clean text (absolutely no tags),
      2) be long 45 characters at the maximum.

      Our current solution is this one (not final, just a proposal/inspiration):

      Index: question/format/multianswer/format.php
      ===================================================================
      — question/format/multianswer/format.php (revision 413)
      +++ question/format/multianswer/format.php (revision 481)
      @@ -29,6 +29,14 @@

      if (!empty($thequestion)) {

      • $thequestion->name = addslashes($lines[0]);
      • + $thequestion->name = html_to_text(addslashes(implode(' ',$lines)));
        + $thequestion->name = preg_replace('/

        {[^}

        ]*}/i','',$thequestion->name);
        + $thequestion->name = preg_replace('/^e/i','',$thequestion>name);
        +
        + if (trim($thequestion->name) == '')

        { + $thequestion->name = userdate(time()); // we need some name, so use the internal Moodle function userdate() + }

        + $thequestion->name = addslashes(substr($thequestion->name,0,45));
        $questions[] = $thequestion;
        }

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  25/Oct/10