Merge branch 'MDL-55225-master' of git://github.com/dpalou/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 9 Aug 2016 08:21:07 +0000 (09:21 +0100)
committerDan Poltawski <dan@moodle.com>
Tue, 9 Aug 2016 08:21:07 +0000 (09:21 +0100)
1  2 
mod/assign/externallib.php
mod/assign/tests/externallib_test.php

Simple merge
@@@ -1944,9 -1882,15 +1945,16 @@@ class mod_assign_external_testcase exte
          foreach ($result['lastattempt']['submission']['plugins'] as $plugin) {
              $submissionplugins[$plugin['type']] = $plugin;
          }
-         $this->assertEquals('Submission text', $submissionplugins['onlinetext']['editorfields'][0]['text']);
+         // Format expected online text.
+         $onlinetext = 'Submission text with a <a href="@@PLUGINFILE@@/intro.txt">link</a>';
+         list($expectedtext, $expectedformat) = external_format_text($onlinetext, FORMAT_HTML, $assign->get_context()->id,
+                 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $studentsubmission->id);
+         $this->assertEquals($expectedtext, $submissionplugins['onlinetext']['editorfields'][0]['text']);
+         $this->assertEquals($expectedformat, $submissionplugins['onlinetext']['editorfields'][0]['format']);
 -        $this->assertEquals('/t.txt', $submissionplugins['file']['fileareas'][0]['files'][0]['filepath']);
 +        $this->assertEquals('/', $submissionplugins['file']['fileareas'][0]['files'][0]['filepath']);
 +        $this->assertEquals('t.txt', $submissionplugins['file']['fileareas'][0]['files'][0]['filename']);
      }
  
      /**
          foreach ($result['previousattempts'][0]['submission']['plugins'] as $plugin) {
              $submissionplugins[$plugin['type']] = $plugin;
          }
-         $this->assertEquals('Submission text', $submissionplugins['onlinetext']['editorfields'][0]['text']);
 -
+         // Format expected online text.
+         $onlinetext = 'Submission text with a <a href="@@PLUGINFILE@@/intro.txt">link</a>';
+         list($expectedtext, $expectedformat) = external_format_text($onlinetext, FORMAT_HTML, $assign->get_context()->id,
+                 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $studentsubmission->id);
+         $this->assertEquals($expectedtext, $submissionplugins['onlinetext']['editorfields'][0]['text']);
+         $this->assertEquals($expectedformat, $submissionplugins['onlinetext']['editorfields'][0]['format']);
 -        $this->assertEquals('/t.txt', $submissionplugins['file']['fileareas'][0]['files'][0]['filepath']);
 +        $this->assertEquals('/', $submissionplugins['file']['fileareas'][0]['files'][0]['filepath']);
 +        $this->assertEquals('t.txt', $submissionplugins['file']['fileareas'][0]['files'][0]['filename']);
++
      }
  
      /**