Editor settings + spellchecking

Editor settings + spellchecking

by Janne Mikkonen -
Number of replies: 51
I've just added editor settings and spellchecking (thanks to Marc Alier) into CVS.
It needs testing and I really would appreciate if someone could check the english language (mine is not so good).

Affected files:
  • new folder /moodle/lib/speller
  • /moodle/lib/weblib.php
  • /moodle/lib/defaults.php
  • /moodle/lib/javascript.php
  • /moodle/admin/editor.php
  • /moodle/admin/editor.html
  • /moodle/admin/index.php
  • /moodle/admin/configure.php
  • /moodle/lang/en/moodle.php
  • I possibly forget something wink

- Janne -

Average of ratings: -
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Gustav W Delius -

Great! Thanks! approve

You may like to test the code with debug on. There are loads of messages which make the configuration page unusable for example.

Can you give a bit of explanation on how to set up the spellchecker. I already installed aspell on my Windows server. What do I need to do next?

And finally: the HTML editor has disappeared, everything is plain textboxes. Javascript error is:  Expected identifier, string or number

In reply to Gustav W Delius

Re: Editor settings + spellchecking

by Gustav W Delius -

I found the answer to my question about how to enable aspell myself. One has to set $CFG->aspellpath in config.php. Why not move this to the editor configuration screen as well?

And by the way, if you want to leave it in config.php, there are equal signs missing in your modified config-dist.php.

In reply to Gustav W Delius

Re: Editor settings + spellchecking

by Janne Mikkonen -
The reason why $CFG->aspellpath is not in configuration screen that I wasn't sure if  I included it in to this post and you should have aspell installed before you can use it. There were one checking point missing in print_editor_config and now it should be there.

I was also making a code for spelling button for those who do not use HTML editor.
print_speller_button -function prints out the button (can be used before or after textarea) and you can add print_speller_code -function in if/else clause where use_html_editor -function is usually used:

if ($usehtmleditor) {
        use_html_editor("message");
} else {
    if(!empty($CFG->aspellpath)) {
       print_speller_code();
    }
}


I don't know does it make any sence...
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Gustav W Delius -
Thanks, everything is working well now. No more javascript errors, no more warnings in debug mode. I am not quite sure what you are saying with respect to having the aspell setup on the configuration screen rather than in config.php. Are you saying it is a good idea or a bad idea? One more wish: could you put the spell check button into one of the existing rows of buttons rather than into a third row all to itself? That would save screen space.
In reply to Gustav W Delius

Re: Editor settings + spellchecking

by Janne Mikkonen -
If it's possible, yes. If it's not possible do you reckon the code it self should be in the htmlarea.php instead of weblib.php?
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I've not looked at the code yet, but it makes sense to me in principle that any code to toggle or handle the spelling button should be in htmlarea.php ...
In reply to Martin Dougiamas

Re: Editor settings + spellchecking

by Janne Mikkonen -
Ok! I'll try to include it in htmlarea.php.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Chardelle Busch -
Picture of Core developers
Hi Janne, I wanted to mention that since you have been testing the spellchecker I have lost my toolbar in my html editor when posting. (See screenshot). I tried everything I can think of to get it back, and it works on other sites, just not on moodle.org. I'm using XP/Explorer. I have no text formatting either--but I've noticed that since then, others posts do have formatting, so its very strange--am I the only one? I had clicked on the spell check icon, nothing happened, but I did get an error on page message. Then, my text all went to html (without any toggling or anything on my part) before I clicked on the post button. I thought this might be a funny bug in the spellchecker. (I'm one of those who lost the editor body when adding an event to the new calendar--so this is probably just par for the course for MS). Chardelle
Attachment text.gif
In reply to Chardelle Busch

Re: Editor settings + spellchecking

by Janne Mikkonen -
Actually you're missing the whole editor wink
It's a bug in code and it's because of this:

config.fontname = {
"Arial":    'arial,helvetica,sans-serif',
"Courier New":    'courier new,courier,monospace',
"Georgia":    'georgia,times new roman,times,serif',
"Tahoma":    'tahoma,arial,helvetica,sans-serif',
"Times New Roman":    'times new roman,times,serif',
"Verdana":    'verdana,arial,helvetica,sans-serif',
"Impact":    'impact',
"Wingdings":    'wingdings', <- there is an comma that makes IE go nuts
};

I made a code for it to get rid of this last comma but it doesn't seem to work!? Have to check it out.

- Janne -
In reply to Gustav W Delius

Re: Editor settings + spellchecking

by Janne Mikkonen -
I'll have to check it through wink

Seems like PJ got rid of those conflict markers in /moodle/mod/forum/mod.html faster than I did. Thanks a lot Jon smile
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Please make sure spell-checking is all turned off by default ... I just noticed this new button on moodle.org and I haven't enabled anything.

Also, no new code in CVS please ... I'm trying to get close to a beta here ...
In reply to Martin Dougiamas

Re: Editor settings + spellchecking

by Janne Mikkonen -
Added one more check before config code is printed and it needs both $CFG->aspellpath and $CFG->editorspelling to be true.

No new code smile got it.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Jacob Romeyn -

Hi Janne

The HTML editor in the pre-beta version works fine in Mozilla Firefoxbig grin but there is no editor in IE 6.0sad

In reply to Jacob Romeyn

Re: Editor settings + spellchecking

by Janne Mikkonen -
Hi Jacob.

How fresh is your copy? Do you see editor in IE on this site?
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Jacob Romeyn -

I just installed it about one hour ago and also did an update. 

And, yes, the editor works on the moodle site.

Just to be sure I just installed the latest development program and still no editor in IE 6.0.

In reply to Jacob Romeyn

Re: Editor settings + spellchecking

by Janne Mikkonen -
I need you to look the page source (on IE's toolbar View -> Source, usually opens in notepad).
At the bottom of the page source you should see config.fontname with enumerated fonts.
If there is comma after last wingdings (like "Wingdings": 'wingdings', };) then IE doesn't load the editor.

Did you remember to clear your browser cache after updating. IE likes to use it's own cache despite what page header tells it to.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Jacob Romeyn -

Yes it is like this:

"Wingdings": 'wingdings',

but it is OK in the htmlarea.php

I cleared the cach but the comma remains when I look in the source.  How do I get rid of the comma?

In reply to Jacob Romeyn

Re: Editor settings + spellchecking

by Janne Mikkonen -
Do not edit htmlarea.php the problem is not in there.

Can you tell me what is you weblib.php's revision number?

Same question to Marc below.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

I have the weblib.php from last night's update; not CVS.  Is that the file I need to get in the CVS to fix this?

Marc

In reply to Marc Dastous

Re: Editor settings + spellchecking

by Janne Mikkonen -
Yes, that's it. The problem is in weblib.php's print_editor_config -function which is used to fire up the editor.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

What should the code look like?  The CVS version of weblib.php is 24 hours old, so do you have newer one than that?

What lines should I change?

Marc

In reply to Marc Dastous

Re: Editor settings + spellchecking

by Janne Mikkonen -
No That's the latest, use that ( Revision 1.280).
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

I am using it and it does not work. wink  So what now?

Marc

In reply to Marc Dastous

Re: Editor settings + spellchecking

by Janne Mikkonen -
Is your site online? Can I visit it?
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

Yes, http://classroom.socialstudies4u.com use, demo and user as the username and passwords.

Marc

In reply to Marc Dastous

Re: Editor settings + spellchecking

by Janne Mikkonen -
Thanks. Just visited it. Can you tell me what version of PHP your using? Is this on Windows or *nix -server?

ps. You can delete that account that I've made.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

PHP Version 4.3.8 is what my host uses.  BTW, there are quite a few more Moodle installations on this server and they are not having this problem; they are using a Moodle 1.4 dev from 2 weeks ago.

It is a UNIX server.

Marc

In reply to Marc Dastous

Re: Editor settings + spellchecking

by Janne Mikkonen -
Moodle 1.4dev uses the older code and do not have these new changes that I've made in the editor settings.

Argh! Big wheel is spinning but nothing happens tongueout.

Have you visit admin >> Editor settings? If not could you try this (very long shot):
Open the editor settings page, do not change anything just press the "save changes" -button. Clear IE's cache (all offline pages) and try if the editor shows up.

I'm trying to install a clean copy to see if I can dublicate this bug.

ps. Is there some sort of  PHP accelerator on your server?
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

That did it!!!!!  I visited the Editor settings and changed the font to Arial and now everything works fine. 

Thanks

Marc

In reply to Marc Dastous

Re: Editor settings + spellchecking

by Janne Mikkonen -
Ok, now we know there is something wrong in default settings!

Thank you Marc smile You helped a lot wink
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

I'm having a similar error with the comma! - note when you click save on the editor.php file - you get a brief flash of the page with the errors:

NOTICE: Undefined Variable: fontlist in e:\moodle\admin\editor.php on line 71
NOTICE: Undefined Variable: spelling in e:\moodle\admin\editor.php on line 84

When I click save on the editor page - it still doesn't solve the problem with the comma - I'm using Moodle 1.4Beta (downloaded about 30min ago.)

smile

Dan

In reply to Dan Marsden

Re: Editor settings + spellchecking

by Janne Mikkonen -
NOTICE: Undefined Variable: fontlist in e:\moodle\admin\editor.php on line 71
NOTICE: Undefined Variable: spelling in e:\moodle\admin\editor.php on line 84


These are already taken care off though they do not affect to that comma problem.

If you're using 1.4 Beta you shouldn't have this error?!? Did you get it from CVS or from download page?
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

I got it from the download page - our proxy won't let me use my CVS program at the moment! - which page has the fix - I'll browse the CVS via http & grab the files.....

- the weblib.php in my download is v 1.282

Dan

In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Hi Janne,

I've just downloaded a copy from cvs, & the above errors disapear, but the comma is still there..... is anyone else still having trouble with the cvs version?

Dan

In reply to Dan Marsden

Re: Editor settings + spellchecking

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

ok... the comma has gone, - reinstalled everything again... Must have been doing something strange.....

smile

Dan

In reply to Dan Marsden

Re: Editor settings + spellchecking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Browsers cache copies of things ... you probably just needed to reload the page with the shift key held down to force a refresh.
In reply to Dan Marsden

Re: Editor settings + spellchecking

by Janne Mikkonen -
Just woke up! I'm happy to hear that the problem has gone big grin
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

hmmm, after a full reinstall - I'm having trouble again. - I've been working on Daryls Blogging feature, the htmleditor appears & works on other areas of the site, however it still doesn't appear when posting a blog (there isn't a comma there anymore, but it seems another bug is causing the problem!)

I get the following Javascript errors when I open the post a blog page:

"A runtime error has occured, do you wish to debug?
Line 1316
Error:Unterminated string constant

then:
"A runtime error has occured, do you wish to debug?
Line: 14
Error: 'HTMLArea' is undefined

then:
"A runtime error has occured, do you wish to debug?
Error: Expected identifier, string or number

previously this also occured on all the other pages with htmleditors - now that the "comma" problem has been fixed, this no-longer occurs on all the other pages, yet it still occurs on the post a blog page.

I've also mentioned this in:
http://moodle.org/mod/forum/discuss.php?d=11424

any ideas?

thanks,

Dan

(I've tried clearing the browsers cache & doing a hard refresh, but this doesn't fix the problem either.)

In reply to Dan Marsden

Re: Editor settings + spellchecking

by Chardelle Busch -
Picture of Core developers

Hi Janne,

I just wanted to mention that on moodle.org, the editor "came back", but I just went to make a post at test.moodle.com and no editor there.  Force refresh has no effect, by the way. 

In reply to Chardelle Busch

Re: Editor settings + spellchecking

by Janne Mikkonen -
test.moodle.com site seem to use older version of moodle so the fix do not apply there yet.

Most likely this is because the admin of that site is a really busy man at this moment?
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Correct.  smile  Moodle.org gets updated more often than anything at the moment.
In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Marc Dastous -

Ok, my htmlarea.php does NOT have the "," after the wingdings.  However, the "," still appears in the View --> Source in IE 6.

Is there another place, besides the htmlarea.php, that the "," appears and has to be edited out?

BTW, it doesn't work in Opera 7, but it does work in Mozilla.

Marc

In reply to Janne Mikkonen

Re: Editor settings + spellchecking

by Tim Allen -

Hmm, I installed it on 1.4 Beta and everything went fine until I tested the spellcheck function in the editor, and it spell checks html code as well as text (see the screenshot).  This is a headache, expecially on heavily formatted text.  I'm using IE6.  sad

Have others experienced this?  What is wrong here, any ideas about fixing this?

Thanks in advance,  smile

Tim.

Attachment spllchk_htmlcodeprob.png
In reply to Tim Allen

Re: Editor settings + spellchecking

by Tim Allen -

Janne or anyone else, any comments about this?  wink  I would really like my students (ESL learners) to use this function, but don't want them to worry about spell-checking the underlying html code!

TIA,
Tim.

In reply to Tim Allen

Re: Editor settings + spellchecking

by Janne Mikkonen -
Well at the moment it's just working that way sad

The text in the editor must be converted to text string (which include html tags as well) before spellchecking can take place and after spelling is done the whole thing is placed back into the editor.

I have to check is there any way to create ignore list which would be usefull to skip xhtml tagging.
In reply to Tim Allen

Re: Editor settings + spellchecking

by Janne Mikkonen -
I just might've found a smooth road to somewhere wink

Just updated the main trunk with a fix that I think will fix this problem. The change is only in aspell options so it's safe to replace your current /lib/speller/servers-scripts/spellchecker.php with this newer one. I'll also put it in here as an attachment so you don't have to dig it up from cvs.

Let me know if it fixes the problem.

- Janne -

ps. Start a new thread wink this is getting quite long...........