Word count is no longer there?

Word count is no longer there?

by Syamsul Anwar -
Number of replies: 12
Hello all!

My students had been writing their online journals using the Journal module under Moodle 1.4. With the recent upgrade to 1.5, all new journal activities were done using the Assignment module (of "Online Text" type)

However, I notice 2 differences about word count using Assignment (online text) module, as compared to Journal module:

1) Word count is no longer calculated  when students submit their entries, so there is no easy way for them to check whether they've met the requirement for minimum number of words (it was calculated and stated for Journal)

2) When I click on the Activity Reports for students in the course, I no longer see see the word count next to each Assignment (number of words were stated next to each Journal entry).

Could anyone advise whether the word count feature is simply not yet implemented for Assignment, or whether there are some settings I need to modify? If the former, I'll have to switch back to Journal for my journal-writing activities.

Thanks in advance!




Average of ratings: -
In reply to Syamsul Anwar

Re: Word count is no longer there?

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 forgot to carry this feature across in the move, so it counts as a bug. Thanks for raising it, I'll get it fixed ASAP (and if someone wants to send me patches to implement this then it'll be even quicker!)
In reply to Martin Dougiamas

Re: Word count is no longer there?

by Joan Codina Filba -
I hope to be able to send you very soon the patch together with the utility to set a desired maximum number of words . I hope in the next two days to be able to install it in our site so you can test it. But before sending the solution we could wait for the discussion about it, Josep Maria Fontana did a post for that, look at his answer here.
In reply to Joan Codina Filba

Re: Word count is no longer there?

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
patch is here, will it make it into 1.5.1??

Index: assignment.class.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/assignment/type/online/assignment.class.php,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 assignment.class.php
--- assignment.class.php	6 Jul 2005 09:51:37 -0000	1.5.2.2
+++ assignment.class.php	6 Jul 2005 13:13:23 -0000
@@ -29,9 +29,12 @@
 
         if ($data = data_submitted()) {      // No incoming data?
             if ($this->update_submission($data)) {
-                notify(get_string('submissionsaved', 'assignment'));
+                //redirect to get updated submission date and word count
+                redirect('view.php?id='.$this->cm->id.'&saved=1');
             }
-        }       
+        } else if (!empty($_GET['saved'])) {
+            notify(get_string('submissionsaved', 'assignment'));
+        }
 
         print_simple_box_start('center', '70%', '', '', 'generalbox', 'online');
         $submission = $this->get_submission();
@@ -59,6 +62,36 @@
         $this->view_footer();
     }
 
+    /*
+     * Display the assignment dates
+     */
+    function view_dates() {
+        global $USER;
+
+        if (!$this->assignment->timeavailable && !$this->assignment->timedue) {
+            return;
+        }
+
+        print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
+        echo '<table>';
+        if ($this->assignment->timeavailable) {
+            echo '<tr><td class="c0">'.get_string('availabledate','assignment').':</td>';
+            echo '    <td class="c1">'.userdate($this->assignment->timeavailable).'</td></tr>';
+        }
+        if ($this->assignment->timedue) {
+            echo '<tr><td class="c0">'.get_string('duedate','assignment').':</td>';
+            echo '    <td class="c1">'.userdate($this->assignment->timedue).'</td></tr>';
+        }
+        $submission = $this->get_submission($USER->id);
+        if ($submission) {
+            echo '<tr><td class="c0">'.get_string('lastedited').':</td>';
+            echo '    <td class="c1">'.userdate($submission->timemodified);
+            echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')</td></tr>';
+        }
+        echo '</table>';
+        print_simple_box_end();
+    }
+
     function view_edit_form($submission = NULL) {
         global $CFG;
 
@@ -162,7 +195,7 @@
         $output = '<div class="files">'.
                   '<img align="middle" src="'.$CFG->pixpath.'/f/html.gif" height="16" width="16" alt="html" />'.
                   link_to_popup_window ('/mod/assignment/type/online/file.php?id='.$this->cm->id.'&amp;userid='.
-                  $submission->userid, 'file'.$userid, shorten_text(strip_tags(format_text($submission->data1,$submission->data2)), 15), 450, 580, 
+                  $submission->userid, 'file'.$userid, shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15), 450, 580, 
                   get_string('submission', 'assignment'), 'none', true).
                   '</div>';
 
Index: file.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/assignment/type/online/file.php,v
retrieving revision 1.1
diff -u -r1.1 file.php
--- file.php	18 Apr 2005 09:29:08 -0000	1.1
+++ file.php	6 Jul 2005 13:13:23 -0000
@@ -38,6 +38,19 @@
 
     if ($submission = $assignmentinstance->get_submission($userid)) {
         print_header(fullname($user,true).': '.$assignment->name);
+
+        print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
+        echo '<table>';
+        if ($assignment->timedue) {
+            echo '<tr><td class="c0">'.get_string('duedate','assignment').':</td>';
+            echo '    <td class="c1">'.userdate($assignment->timedue).'</td></tr>';
+        }
+        echo '<tr><td class="c0">'.get_string('lastedited').':</td>';
+        echo '    <td class="c1">'.userdate($submission->timemodified);
+        echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')</td></tr>';
+        echo '</table>';
+        print_simple_box_end();
+
         print_simple_box(format_text($submission->data1, $submission->data2), 'center', '100%');
         close_window_button();
         print_footer('none');

In reply to Petr Skoda

Re: Word count is no longer there?

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
Looks good, I think, just from a visual scan.  Go for it!
In reply to Martin Dougiamas

Re: Word count is no longer there?

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
It is in CVS wink
In reply to Petr Skoda

Re: Word count is no longer there?

by Syamsul Anwar -
Just wondering if it's in the just-released Moodle 1.5.1 update? Thanks!
In reply to Syamsul Anwar

Re: Word count is no longer there?

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Should be, did not have time to check it myself.
I already fixed some bugs in assignments after the release, so maybe you should update again in about 3 days.
In reply to Petr Skoda

Re: Word count is no longer there?

by Syamsul Anwar -
Thanks, I'll update to the 1.5.1 stable branch later this weekend. Hopefully the word count will be there smile
In reply to Syamsul Anwar

Re: Word count is no longer there?

by Josep M. Fontana -
Syamsul, you might be interested in reading the following post in the developers forum:

http://moodle.org/mod/forum/discuss.php?d=26899
In reply to Josep M. Fontana

Re: Word count is no longer there?

by Syamsul Anwar -
Thanks, Martin. Alas, looks like I'll have to revert to the Journal module in the meantime. sad Do post when the bug's fixed ok? smile

Josep, thanks for the post. I think the "live" word counter would especially be a very nice addition and I think students would love it too. I hope your ideas for the module get implemented soon!




In reply to Syamsul Anwar

Re: Word count is no longer there?

by Joan Codina Filba -
As I told I was working on the word counter, but, I started with showing the word count everywhere.
I hope to have the counter on friday, as i need to test it properly and program it for both editors, html and plain text.
Now I merged my code with the one of cvs and I got duplicate counters in two or three places.. double job.
I show the screens of what I did and I hope for for fryday to be able to give an URL where to test it.

In reply to Joan Codina Filba

Re: Word count is no longer there?

by Joan Codina Filba -
Here you can test it:
http://parles.upf.es/TEST
user teacher password teacher
Changes done
* the assignment allows a "maximum words" parameter that warns the student when submiting a longer text, but does not impede to do so.
* word counts are everywhere....(student activity report, list of submitted assigments...)
* the grade shows the text to avoid an extra click
* the html editor counts words allways in any situation.
* if not activated the texttbox only counts words when writting the assignment.

Now wordcounts apear twice in some screens as I merged my code from the one in CVS where the code of Petr has been commited

I hope you like it

Joan Codina
Josep M. Fontana