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

Automatic substitution of string "To" in chat conversations.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.2.5, 2.3.2
    • 2.1.2, 2.2.2
    • Chat
    • Linux and Windows
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • MDL-30405-master
    • 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]; }
    • 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

      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, ...

            fred Frédéric Massart
            efdelgado Emanuel Delgado
            Rajesh Taneja Rajesh Taneja
            Dan Poltawski Dan Poltawski
            Andrew Davis Andrew Davis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.