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

Name for imported cloze questions cleaned of all tags

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.3, 1.9, 2.0
    • 1.9.10, 2.0
    • Questions
    • None
    • MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • 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;
        }

      Attachments

        Activity

          People

            timhunt Tim Hunt
            mixik Daniel Miksik
            Nobody Nobody
            Safat Shahin, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              25/Oct/10