Moodle

Text containing embedded newlines breaks quick grading

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9, 1.9.3, 1.9.4
  • Fix Version/s: None
  • Component/s: Assignment (2.2)
  • Labels:
    None
  • Environment:
    Tested on
    1) OpenOffice 2.4.0 and Firefox 3.0.5 on OpenSUSE
    2) MS Word 2003 and IE6.0 on Windows XP
    3) MS Word 2003 and Firefox 2.0 on Windows XP
  • Affected Branches:
    MOODLE_19_STABLE

Description

Tested on 1.9.4 (Build: 20090128), although this problem has existed since at least 1.9 + (Build: 20080425)

While entering comments and grades for assignments in quick grading mode, the child window attempts to update the parent window's content (before closing itself), so the teacher can continue grading without reloading the parent window.

In quick grading mode, a teacher may paste content from other sources (Word, OpenOffice, etc) into the rich text editor, which may contain newline characters. (Example document attached) The embedded newlines cause a Javascript syntax error, so the parent page does not update. The submitted grade and comment are actually received and entered into the database, as one would expect. The changes are just not reflected in the parent window.

Steps to reproduce:
1) Login as a teacher, create an assignment (offline, online text, single or advanced type)
2) View the attempts (via "No attempts have been made on this assignment") link
3) Turn on quick grading
4) Click the "grade" link next to any student
5) Copy the text from the attached word document, and paste it into the rich text editor.
6) Click "save changes"
Expected result: The parent window's "comment" field should update to reflect the comment, and the new grade.
Actual result: A javascript error occurs, and the parent window does not update the grade nor comment.
The JS error, from Firefox's error console is:
Javascript error, Error: unterminated string literal
Source File: http://xxx.yyy.zzz/moodle/mod/assignment/submissions.php
Line: 114

I wrote a hack workaround, which strips out the offending characters before writing the comment's text as the right-hand value of the javascript assignment (Around line 663 in mod/assignment/lib.php):
$submission->submissioncomment=preg_replace('/[\n\r]+/', ' ', $submission->submissioncomment, -1, $replaceCount);

I've attached the full patch of my change, but I'm sure there's a more elegant and appropriate place to solve this one.

This might be considered user error, since it's a problem with the contents of the comment. However, I've had multiple instructors at our institution run into this bug.

In at least one case, an instructor had graded over a dozen students' assignments (with lengthy comments composed in word, pasted to quick grading window), then clicked "Save all my feedback", which promptly replaced all of their lengthy comments with the blank comments (and "no grade" grades) which had originally displayed when he viewed the assignment.

Issue Links

Activity

Hide
Clinton Graham added a comment -

I would prefer to see the code construct the javascript line correctly with the line breaks, rather than strip them out. E.g.:

$submission->submissioncomment = preg_replace('/[\n\r]/', '\n', $submission->submissioncomment);

Show
Clinton Graham added a comment - I would prefer to see the code construct the javascript line correctly with the line breaks, rather than strip them out. E.g.: $submission->submissioncomment = preg_replace('/[\n\r]/', '\n', $submission->submissioncomment);
Hide
Clinton Graham added a comment -

Also, this line of code should be moved above the if($quickgrade) check to allow for the correct construction of the javascript in the else clause as well.

Show
Clinton Graham added a comment - Also, this line of code should be moved above the if($quickgrade) check to allow for the correct construction of the javascript in the else clause as well.
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Vote (2)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: