openlab-at-city-tech / webworkqa

WeBWorK integration for WordPress and BuddyPress
GNU General Public License v2.0
4 stars 2 forks source link

interpret linebreaks #82

Closed moui72 closed 7 years ago

moui72 commented 7 years ago

when asking a question or making a reply, linebreaks are ignored outright

it might be nice to allow some for formatting purposes

boonebgorges commented 7 years ago

This should now be fixed.

moui72 commented 7 years ago

No go. See http://openlabdev.org/webwork-playground/#:problemId=local/ShiftingParabolas/shift-down.pg:questionId=11370 and screenshot below

image

Entered text included many linebreaks in both fields at various intertextual places

Do I need to bust my cache harder? Here's the script my browser is loading (I assume this is the relevant one)

http://openlabdev.org/webwork-playground/wp-content/plugins/webwork/assets/js/webwork-scaffold.js?ver=4.8-1.7.11

boonebgorges commented 7 years ago

Can you please share the exact text that you have entered, along with info about your OS/browser? It's possible that the issue is linebreak encoding, for which I may need more generous regular expressions. https://github.com/livinglab/webwork-for-wordpress/commit/1bdf3d614456712ed8b4cce8a4dd8d0913e051fe

The application JS is not the file that you've linked, though if you are seeing other improvements then I assume that an old cache is not the issue. (The issue is on the server anyway.)

moui72 commented 7 years ago

Tested on macOS 10.12.5 (Sierra) with Chrome 59.0.3071.115 (Official Build) (64-bit)

Text:

I am responding to this thing

with

linebreaks!

image

The ¬ represents a new line character (\n)

image

image

moui72 commented 7 years ago

I just updated chrome to 60.0.3112.78 (Official Build) (64-bit) with no change in behavior

boonebgorges commented 7 years ago

Thank you for the details. Like so many other parts of this application, there are about a hundred text encoding steps that happen between WW and the server and WP and the browser. I've just put something in place on webwork-playground that addresses this specific post - can you play with it a bit and see if it matches what you'd expect?

moui72 commented 7 years ago

seems to be working in the ask a question and the reply field, but not in the "what i've tried" field

text entered in all three fields

I am responding to this thing

with

linebreaks!

result linebreaks-what-ive-tried

boonebgorges commented 7 years ago

Whoops, I missed tried. This should now be resolved.

moui72 commented 7 years ago

the tried issue is still working, but I think it's display only: when I edit a question with linebreaks in the tried field, they are still there. notably, the question field will have \n stripped out and replaced by <br /> but tried still has \n

also, i wonder if it is worth the effort to reverse the effect for editing, so that users see line breaks instead of <br /> ?

i can post screenshots later on, right now i dont have time sorry

moui72 commented 7 years ago

A few corrections to the above, and screenshots: if I edit a question/reply immediately after posting it, the \n characters are not replaced by <br /> but after a page refresh, they are.

tried always has \n (they are no longer stripped out) but never displays as line break or <br />

Demonstrating tried behavior

Display webwork playground just another city tech openlab site 1

Immediate edit and edit after reload webwork playground just another city tech openlab site 4

Demonstrating question/reply behavior with page refresh

Display webwork playground just another city tech openlab site 5

Immediate edit webwork playground just another city tech openlab site 3

Edit after reload webwork playground just another city tech openlab site

boonebgorges commented 7 years ago

This issue is truly awful. I've done some work to try addressing the various problems:

One side-effect is that text for some problems now appears to have more linebreaks than previously. See eg http://openlabdev.org/webwork-playground/#:problemId=local/CoordinatePlaneTrig/six-trig-point-q1.pg:questionId=11454. In truth, this is a more accurate representation of the markup as it's received from WW, though it does take up more vertical space than it seems like it ought to. I don't think there's much more we can do to "fix" this without retooling the WW-WP connection.

moui72 commented 7 years ago

it's looking good now, sorry it's such a pain =\ I appreciate your commit message for 075442b 😆

moui72 commented 7 years ago

@bree-z would you have a minute to verify that there are no lingering issues?

bree-z commented 7 years ago

@moui72 yep, also on the list for tomorrow.

bree-z commented 7 years ago

This looks OK to me in Firefox, but not Chrome. Linebreaks appear in Firefox for both questions and replies. In Chrome they don't appear for either. I'm using OSX 10.12.5, Firefox 54 and Chrome 60.0.3112.90.

See, for example:

http://openlabdev.org/webwork-playground/#:problemId=local/CoordinatePlaneTrig/six-trig-point-q1.pg:questionId=11468

In Chrome

linebreaks_askquestionchrome

After submitting:

linebreaks_questionresponse_chrome

Same question in Firefox:

linebreaks_firefox

boonebgorges commented 7 years ago

@bree-z Thanks for the screenshots. It's looking OK to me, though I'm not near a Mac to check if that's the issue. Could you please triple-check that your cache is clean? shift-refresh

bree-z commented 7 years ago

So sorry @boonebgorges ! I thought I'd cleared my cache, but maybe that was Firefox...or something else. (Too many browsers and windows and tabs for one week.)

It looks good now! I think we can close this.

boonebgorges commented 7 years ago

Phew - I did not want to think about this issue anymore :-D

bree-z commented 7 years ago

This looked like a rough one!

moui72 commented 7 years ago

Yay! Thanks Bree

On Fri, Aug 11, 2017, 4:09 PM bree-z notifications@github.com wrote:

This looked like a rough one!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/livinglab/webwork-for-wordpress/issues/82#issuecomment-321907460, or mute the thread https://github.com/notifications/unsubscribe-auth/ADtKPGgnfikwE44Z3E2gvLA5pcFdEqvUks5sXLUIgaJpZM4Lvz6S .