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

Automatic substitution of string "To" in chat conversations.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.2, 2.2.2
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Chat
    • Environment:
      Linux and Windows
    • Testing Instructions:
      Hide

      Test pre-requisites

      • A chat activity
      • Two users logged in simultaneously

      Test steps

      1. Open the chat with user A
      2. Open the chat in accessible mode with user B
      3. Have them talk in the chat and make sure it works
      4. Make sure sending messages from one to another works
      5. Make sure the command `/me fixes bug` works as expected
      6. Make sure the command `beep all` works as expected
      7. Review the minor docs edits to http://docs.moodle.org/23/en/Chat_sessions with mention of these special commands
      Show
      Test pre-requisites A chat activity Two users logged in simultaneously Test steps Open the chat with user A Open the chat in accessible mode with user B Have them talk in the chat and make sure it works Make sure sending messages from one to another works Make sure the command `/me fixes bug` works as expected Make sure the command `beep all` works as expected Review the minor docs edits to http://docs.moodle.org/23/en/Chat_sessions with mention of these special commands
    • Workaround:
      Hide

      The file in question is moodle/mod/chat/lib.php.
      The relevant code is duplicated in lines 844 and 1013 (this duplication should be avoided too).
      I think it would be better to test fot the same pattern that is used inside the elseif statement.

      Instead of

          } elseif (substr($text, 0, 2) == 'To') {
              $special = true;
              $result->type = 'dialogue';
              $pattern = '#To[[:space:]](.*):(.*)#';
              preg_match($pattern, trim($text), $matches);
              $special = true;
              $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.
      			$matches[1].'</i>: '.$matches[2];
          }

      Replace for something like

      //variable $patternTo='#To[[:space:]](.*):(.*)#' must be defined earlier
          } elseif (preg_match($patternTo, $text)) {
              $special = true;
              $result->type = 'dialogue';
              preg_match($patternTo, trim($text), $matches);
              $special = true;
              $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.
      			$matches[1].'</i>: '.$matches[2];
          }

      Show
      The file in question is moodle/mod/chat/lib.php. The relevant code is duplicated in lines 844 and 1013 (this duplication should be avoided too). I think it would be better to test fot the same pattern that is used inside the elseif statement. Instead of } elseif (substr($text, 0, 2) == 'To') { $special = true; $result->type = 'dialogue'; $pattern = '#To[[:space:]](.*):(.*)#'; preg_match($pattern, trim($text), $matches); $special = true; $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'. $matches[1].'</i>: '.$matches[2]; } Replace for something like //variable $patternTo='#To[[:space:]](.*):(.*)#' must be defined earlier } elseif (preg_match($patternTo, $text)) { $special = true; $result->type = 'dialogue'; preg_match($patternTo, trim($text), $matches); $special = true; $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'. $matches[1].'</i>: '.$matches[2]; }
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-30405-master

      Description

      The string "To" is automatically replaced by a block of code to send identified messages.
      However this is not a natural behaviour and brings problemas when someone begin a sentence with words like Tomorrow, Today, ...

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    10/Sep/12