Calculated columns in gradebook

Calculated columns in gradebook

by Gustav W Delius -
Number of replies: 65

I have now implemented calculated columns in the gradebook. Here is the text from the corresponding help file:

Calculated columns

You can have additional columns in the gradebook whose entries are calculated from those in other columns according to a formula provided by you. The "Total" grade column is an example of this. The students will be able to see their grades from calculated columns alongside their other grades. They will also be shown the formula used.

To refer back to other columns in your formula you use the following notation:

A1, A2, ... The grades from activities 1, 2, ...
PA1, PA2, ... The percentage points for activities 1, 2, ...
C1, C2, ... The grades from previous calculated columns 1, 2, ...

If you need to refer to a whole range of grades you can use a shorthand notation, for example A2:4 stands for the list A2,A3,A4 and similarly for C and PA. You can also use all to denote the list of all activity grades (including grades from hidden activities).

You can combine the grades using:

+, -, *, /, (, ) with their usual arithmetical meanings
min(a,b,...) the minimum of a set of values
max(a,b,...) the maximum of a set of values
best(n,a,b,...) the sum of the best n values among a,b,...
round(a) the value of a rounded to the nearest integer
floor(a) the largest integer not larger than a
ceil(a) the smallest integer not smaller than a

An example: if the final grade should be on a scale of 0 to 10 and should be obtained as the best 4 of the first 7 assignments then you could use the formula

round(best(4,PA1:7)/40).

The calculated grades are floating point numbers. Only the first digit after the decimal point will be displayed but all digits are used for calculations.

You can choose any name for a calculated column. However if you choose the name Total then the corresponding entry in the student's grade table will be presented in bold face.

Note: The ordering of the activity columns in the grade book are determined by the ordering of the activities on the course page. Thus if you change the order on the course page then the labeling of the activity columns may change and you will have to change the formulas by hand.

The old Total column is now also just a calculated column. So you can change it or get rid of it if just summing up the grades makes no sense in your course. When you upgrade to the new version of the gradebook then initially a Total column is created automatically for each course so that existing users will see no difference (apart from a new link "Add a calculated column" and little [Edit] and [Del] links in the heading of the Totals column).

Clearly one could think of hundreds of ways to improve things (like allowing the order of columns to be changed) but I nevertheless hope that what is there is good enough to get into CVS. It certainly offers all that flexibility that we need at our Department.

The code is unclean in two respects: it uses explicit strings instead of the get_string function and it uses explicit CSS style instructions in the code rather than placing them in a style sheet. Perhaps someone else can clear up after me wink.

The code uses the new grade table in the form proposed by Martin, see http://moodle.org/mod/forum/discuss.php?d=3743, to hold the calculated columns. But it does not yet implement the grade_user table but continues to fetch the grades directly from the activity modules. This is ugly and inefficient and someone might want to volunteer to change that so that all activity modules write their grades directly into grade_user. See http://moodle.org/mod/forum/discuss.php?d=3725 for more related discussions.

The attached .zip file contains new versions of:

If you just drop these into the correct location in your moodle installation and visit the admin page then the database should be updated automatically and afterwards you should be able to use the new calculated columns.

Only the files grades.php and grade.php have changed substantially, for the others it was just a matter of adding something on to the end, so for those I have also included diff files that demonstrate this.

The above is the theory, let me know how it works in practice. smile

P.S.: the new grades.php rotates the table headers by 90 degrees to save space, see http://moodle.org/mod/forum/discuss.php?d=3201. This only happens in IE browsers. If you don't like your headings to be rotated then search for and remove all occurences of

writing-mode: tb-rl;
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Przemyslaw Stencel -
I just can't help saying: Wow!
Thanks, Gustav.
I can't wait to see it in cvs and play with it big grin
In reply to Przemyslaw Stencel

Re: Calculated columns in gradebook

by Gustav W Delius -

It would actually be a big help if you could play with it. You will probably be able to make useful observations of things that should be fixed.

All you have to do to start playing with it is to drop some files into your moodle installation as described above and the system will upgrade automatically. This upgrade is not messing with existing tables. Going back to your previous version just requires you to reinstate the old grades.php and grade.php.

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Martin Dougiamas -
Core developers სურათი Documentation writers სურათი Moodle HQ სურათი Particularly helpful Moodlers სურათი Plugin developers სურათი Testers სურათი
Nicely done, Gustav!! approve

I've not time to look it tonight, but I hope to get it into CVS in the next few days.  In the meantime, it would be great if others tried it out and help Gustav with some testing in different environments so that the CVS version can be relatively solid.
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Williams Castillo -
Hi Gustav...

You forgot to include or mention to change the version of /version.php to 2003112501...

It's incredible this "Open Source" thing... I can't stop wondering what it could make and what it could produce in a matter of hours...

Congrats!
Will
In reply to Williams Castillo

Re: Calculated columns in gradebook

by Williams Castillo -
Is there a any interface to create the columns??? I can't find it.. sad
In reply to Williams Castillo

Re: Calculated columns in gradebook

by Gustav W Delius -
There should be a link "Add a calculated column" directly above the grades table.
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Williams Castillo -
I used to say that I'm half blind.. I have been wrong all the time...

I'm completelly blind...

Thanks!
In reply to Williams Castillo

Re: Calculated columns in gradebook

by Gustav W Delius -
You are probably not blind cool. It would actually be useful to know where you looked for the link and couldn't find it because perhaps that would be the better place to put it.
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Williams Castillo -
I was looking for a button right beside the currently shown... smile

(I was close at least!!! hehehe)
In reply to Williams Castillo

Re: Calculated columns in gradebook

by Gustav W Delius -
Williams, it turned out that noone could find that link, so now I have changed it to a button in cvs:/contrib/gradebook.
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Williams Castillo -
That's makes me feel a bit better... smile cool

What I still can't get used to, is with the names of the functions... Sadly, you do not get enough feedback about it: An important topic IMHO...

Did you though in having the columns in lowercase, and use the uppercase to refer to the whole group of grades within an activity? For example:

max(a1,a2,..., an) to get the maximum value of the final grade of n activities (=max(all)).
max(A1) to get the maximum value obtained in the activity a1.
maxgrade(A1) to get the maximum possible value of the activity 1.
avg(a1,a2,...) average of the final grade of n activities (=avg(all)).
avg(A1) average obtained in the activity a1.
sum(A1) total obtained in the activity a1.

Perhaps it's nonsense, but they seems more intuitive to me (Uhmm... Am I repeating myself?)

Anyway... Great, great work.. Thanks!
Will


In reply to Williams Castillo

Re: Calculated columns in gradebook

by Gustav W Delius -

Hi Will, sorry for the late reply, I didn't see your post until now.

I like your suggestion of using capital letters and small letters. But I think it would be more natural to apply your principle to the function name rather than the column name. So for example avg(A1,A2) would be the average of the grades of a student in activities 1 and 2 whereas AVG(A1) would be the average over all students in activity 1. I am just a bit concerned that people would get confused very easily. And it is not so clear to me that anyone actually needs the average over all students in a calculated column.

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by W Page -

Hello!

I saw Williams Castillo's post in the following thread and thought I would try out "Calculated Columns".
Re: Countdown to 1.2 and beyond.
http://moodle.org/mod/forum/discuss.php?d=5158

I am running MOODLE mts-v1.2-012804.

THE PROBLEM I HAVE

Presently I get the following error message when I click on the "grades" link as an "Admin" or a "Student".
Fatal error: Cannot redeclare best() (previously declared in /homepages/22/d12345678/htdocs/moodle/course/lib.php:1615) in /homepages/22/d12345678/htdocs/moodle/course/gradeslib.php on line 5

WHAT I DID

I uploaded the following files (I indicated the original files and the present CVS Rev. of certain files,

moodle/course/grade.php (Rev. 1.2)
moodle/course/grades.php (Rev. 1.6)
moodle/course/gradeslib.php (Rev. 1.4)
moodle/course/lib.php (original post - Tues, 25 Nov 3, 8 AM)
moodle/lib/db/mysql.php (original post - Tues, 25 Nov 3, 8 AM)
moodle/lib/db/mysql.sql (original post - Tues, 25 Nov 3, 8 AM)
moodle/version.php (original post - Tues, 25 Nov 3, 8 AM)
moodle/lang/en/help/calculatedcolumns.html (Rev. 1.2)

I did not upload the "readme" file,  I did read it.
moodle/README.txt (Rev. 1.2)

The "README.txt" file was a bit confusing as it said to add the following code.  When I looked at the original "sql.php" file (Tues, 25 Nov 3, 8 AM) it appeared the code was already there.

2) append the following code to your lib/db/mysql.php file:
   
    if ($oldversion < 2003092901) {
        execute_sql(" CREATE TABLE `{$CFG->prefix}grade` (
            `id` int(10) NOT NULL auto_increment,
            `courseid` int(10) NOT NULL default '0',
            `coursemoduleid` int(10) default NULL,
            `scaleid` int(10) default NULL,
            `name` varchar(255) default NULL,
            `calculation` varchar(255) default NULL,
            `timemodified` int(10) NOT NULL default '0',
            PRIMARY KEY  (`id`)
          ) TYPE=MyISAM COMMENT='One record for each column in the gradebook'"
        );
       
        // Create a Total column for every course
        if ($courses = get_records_select("course", "category > 0")) {
            $grade->name = 'Total';
            $grade->calculation = 'sum(all)';
            $grade->timemodified = time();
            foreach ($courses as $course) {
                $grade->courseid = $course->id;
                insert_record("grade", $grade);
            }
        }
    }

You should replace the version number 2003092901 by the same updated version number that you used in step 1).

When I clicked on the "Admin" link I did not see the usual database information that I usually see when I install a module.

I reuploaded,
moodle/lib/db/mysql.php (original post - Tues, 25 Nov 3, 8 AM)
moodle/lib/db/mysql.sql (original post - Tues, 25 Nov 3, 8 AM)

I clicked on the "Admin" link again and just saw the word "Success" at the top left of the MOODLE "Admin" screen.

When I went back to the "Admin" screen to work on something else I saw the word "Error" in the top left of the MOODLE "Admin" screen.  This "Error" word now persists in that location.

If I click on "grades" I get the following which I noted above,
Fatal error: Cannot redeclare best() (previously declared in /homepages/22/d12345678/htdocs/moodle/course/lib.php:1615) in /homepages/22/d12345678/htdocs/moodle/course/gradeslib.php on line 5

Also as I noted above I get the same error message whether or not I sign in as the "Admin" or "Student".

What did I do wrong??

WP1

In reply to W Page

Re: Calculated columns in gradebook

by Zbigniew Fiedorowicz -

You didn't do anything wrong. It appears that there is a minor incompatibility between Gustav's gradebook hack and the current version of Moodle.  Just go through the file gradeslib.php and replace every occurence of the string

"best("

by something like

"gbest("

(without quotes of course).  You have to expect such things when you live on the bleeding edge

In reply to Zbigniew Fiedorowicz

Re: Calculated columns in gradebook

by W Page -

Hi!

Thank you for responding.

I get the same error on the grades page,
Fatal error: Cannot redeclare best() (previously declared in /homepages/30/d94988299/htdocs/moodle/course/lib.php:1619) in /homepages/22/d12345678/htdocs/moodle/course/gradeslib.php on line 5

Now line 1619 appears to be involved.  Previously it was line

Anymore suggestions would be helpful.  I use these errors as a training.  I don't mind being a bit "bleeding edge".

I made the changes in "gradeslib.php" at lines 5 and 6 respectively,

FROM

<?php  // $Id:

/// A few functions needed by grades.php and grade.php to produce grade tables

function best() {
// This implements best(n,A1,...,Am) which sums the n largest among A1 ... Am
    $args = func_get_args();
    $numargs = func_num_args();
    $num = round(array_shift($args));
    if ($num <= 0) {
        return 0;
    }
    sort($args, SORT_NUMERIC);
    $s = 0;
    for ($i = $numargs-1-$num; $i <= $numargs-2; $i++) {
        $s += $args[$i];
    }
    return $s/$num;
}

TO

<?php  // $Id:

/// A few functions needed by grades.php and grade.php to produce grade tables

function gbest() {
// This implements gbest(n,A1,...,Am) which sums the n largest among A1 ... Am
    $args = func_get_args();
    $numargs = func_num_args();
    $num = round(array_shift($args));
    if ($num <= 0) {
        return 0;
    }
    sort($args, SORT_NUMERIC);
    $s = 0;
    for ($i = $numargs-1-$num; $i <= $numargs-2; $i++) {
        $s += $args[$i];
    }
    return $s/$num;
}

In reply to W Page

Re: Calculated columns in gradebook

by Zbigniew Fiedorowicz -
You need to change every occurence of  'best(' in gradeslib.php to 'gbest('.  Please reread my previsous message.
In reply to W Page

Re: Calculated columns in gradebook

by Zbigniew Fiedorowicz -

There is something very strange about your Moodle installation. It looks like you have two different Moodle installations:

  1. /homepages/30/d94988299/htdocs/moodle
  2. /homepages/22/d12345678/htdocs/moodle/

and they somehow cross-reference each other.  Moreover, I checked the latest CVS and there is no best() function defined in moodle/course/lib.php on line 1619 (or any other line for that matter). It looks like you have installed various hacked versions of Moodle and they clash with each other.

In reply to Zbigniew Fiedorowicz

Re: Calculated columns in gradebook

by W Page -

Hi!

Thank you   angel.gif  for helping me with this problem.

You are sharp,  that was an error and should have been corrected,

Fatal error: Cannot redeclare best() (previously declared in /homepages/22/d12345678/htdocs/moodle/course/lib.php:1619) in /homepages/22/d12345678/htdocs/moodle/course/gradeslib.php on line 5

By the time I caught it you had already responded to my follow-up post.  I then forgot to make a correction in a subsequent post.

The best() function is in "course/gradeslib.php" not "course/lib.php"

I interpreted "gradeslib.php" to be a separate file inside the "course" directory.  Was I suppose to rename it "lib.php"??.

WP1

In reply to W Page

Re: Calculated columns in gradebook

by W Page -

Hi!

I am still trying to figure this thing out.  I noticed the following.

There seems to be a function which is almost identical in the "course/gradeslib.php" and the "lib.php".

---------------------------------------------------------------------------------

"gradeslib.php" on line 5
-----
/// A few functions needed by grades.php and grade.php to produce grade tables

function best() {
// This implements best(n,A1,...,Am) which sums the n largest among A1 ... Am
$args = func_get_args();
$numargs = func_num_args();
$num = round(array_shift($args));
if ($num <= 0) {
return 0;
}
sort($args, SORT_NUMERIC);
$s = 0;
for ($i = $numargs-1-$num; $i <= $numargs-2; $i++) {
$s += $args[$i];
}
return $s/$num;
}

================================================
"lib.php" on line 1617
-----------
/// Now come a few functions needed by grades.php and grade.php to produce grade tables

function best() {
// This implements best(n,A1,...,Am) which sums the n largest among A1 ... Am
$args = func_get_args();
$numargs = func_num_args();
$num = array_shift($args);
if ($num <= 0) {
return 0;
}
sort($args, SORT_NUMERIC);
$s = 0;
for ($i = $numargs-1-$num; $i <= $numargs-2; $i++) {
$s += $args[$i];
}
return $s;
}

---------------------------------------------------------------------------------

The only difference that I can see as to how these functions are written is at the following line near the end.

In "gradeslib.php" it is written,

}
return $s/
$num;
}

In "lib.php" it is written,

}
return $s;
}

The $num; is missing in the "lib.php" version.

I have attached the "gradeslib.php" file and the "lib.php" file in a zip to support what I am saying.

I cannot determine what I am to do with this information.  How do I debug the script??

WP1

In reply to W Page

Re: Calculated columns in gradebook

by W Page -

Still "messing" with this code,

I decided to remove each function in the "course/gradeslib.php" that the error message pointed out.  When I removed one function from the script another would display.  I removed all of the following from the "course/gradeslib.php" eventually,
function best()
function grades_step($a)
function step()
function sum()
function is_legal_formula($formula)
function prettify_formula($formula)
function sequence($matches)
function expand_formula($formula, $coffset)
function calculate_grade($formula, $grades, $maxgrades, $highestgrades, $averagegrades, $coffset)

All of these functions were already present in the "course/lib.php" file.  I did not compare any of the same functions between the files except for the best() function which I referred to in a previous post above.

I eventually got a page like the one attached.  Is this how it should look?

Were those the correct functions to remove?

Also when I clicked on the words "Scientific Method" I was taken to the "Shelf" module.  Was this suppose to happen?  You can see the shelf icon is also at the top of the column.

WP1

Attachment grades_page.jpg
In reply to W Page

Re: Calculated columns in gradebook

by W Page -

I have one last persistent problem with this script,

Although I have been able to get the "Grades Page" to display, I am not too sure about the database which goes along with it.

As I noted in a previous post, when I clicked on the "Admin" link I did not see the usual database information that I usually see when I install a module.

I reuploaded,
moodle/lib/db/mysql.php (original post - Tues, 25 Nov 3, 8 AM)
moodle/lib/db/
mysql.sql (original post - Tues, 25 Nov 3, 8 AM)

I clicked on the "Admin" link again and just saw the word "Success" at the top left of the MOODLE "Admin" screen.

When I went back to the "Admin" screen to work on something else I saw the word "Error" in the top left of the MOODLE "Admin" screen.  This "Error" word now persists in that location.

Anyone have any ideas as to how I can correct this problem?

Please see attached image

WP1

Attachment upper_left.jpg
In reply to W Page

Re: Calculated columns in gradebook

by Bruno Vernier -
I like the gradebook very much too smile

Here is how I integrated gradebook into moodle 1.2 dev:

1. I kept Martin's grade.php and grades.php and renamed Gustav's grade.php and grades.php to gradebook.php and gradesbook.php. (gradeslib did not need to be renamed)

2. I searched and replaced "best" with "gbest" in gradeslib

3. I searched and replaced "grades.php" with "gradesbook.php" in gradesbook.php

4. I added a link to gradesbook.php (for teachers) and gradebook.php (for students) in the skin (in my case, header.php)


it works smile but should be considered a temporary hack until someone properly rewrites the gradebook application smile
In reply to Bruno Vernier

Re: Calculated columns in gradebook

by W Page -

Thanks for your input Bruno.  I am going to install the latest version of MOODLE on another site and try the changes you suggest in your post.

Some problems perists with the present install.  I am using the experience I am having with "GradeBook" as a learning opportunity.

PROBLEM 1
You can see on the image in the previous post that the words "Scientific Method" is in the first column.  It is a hyperlink.  When I clicked on the link I was taken to another module called "Shelf. Infact you can see the "Shelf" icon at the top of the (on top of) "Scientific Method" hyperlink. 

PROBLEM 2
After uploading the files, when I clicked on the "Admin" link I did not see the usual database information that I usually see when I install a module.

I reuploaded,
moodle/lib/db/mysql.php (original post - Tues, 25 Nov 3, 8 AM)
moodle/lib/db/mysql.sql (original post - Tues, 25 Nov 3, 8 AM)

I clicked on the "Admin" link again and just saw the word "Success" at the top left of the MOODLE "Admin" screen.

When I went back to the "Admin" screen to work on something else I saw the word "Error" in the top left of the MOODLE "Admin" screen.  This "Error" word now persists in that location.

PROBLEM 3
When I clicked on the "Download in Excel" button I got the following errors with some machine "Jibberish" right after it,

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 241

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 242

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 243

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 244

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 245
ÐÏࡱá>þÿ þÿÿÿþÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
l É $strgrades=¼%r8X"1ÈÿArial1ÈÿArial1ÈÿArial1ÈÿArial1ÈÿArial1È
Arialàõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À àõÿ À à À à
À ÿâ8ÿÿÿÿÿÿÿÿÿÿÿÿÀÀÀÿ3fÿÿÌÌÿÿffÿfÌÌÌÿÿÿÿÿÿÿÿÌÿÌÿÿÌÿÌÿÿÌÿÿÌÌÿÿÌ3fÿ3ÌÌÌÿÌÿÿfff
3f3f33333f33333) $strgrades l É*+Á¡"dXXà?à? Given
nameSurname#Shelf: Scientific Method - StudentStudent 0 0 0
0 0 0 0 0 0)ð?(ð?'è?&è?> ¶ Root EntryÿÿÿÿÿÿÿÿþÿÿÿBook
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿþÿÿÿýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

When I clicked on the "Download in text" button I got the following errors with some data (with no delimiters) right after it,

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 284

Warning: Cannot add header information - headers already sent by (output started at /homepages/30/d94988299/htdocs/moodle/course/gradeslib.php:33) in /homepages/30/d94988299/htdocs/moodle/course/grades.php on line 285
Given name Surname Shelf: Scientific Method - Student Student 99 85 0 0 0 0 0 0 0 0 I commented out all the "error" lines in "grades.php"

I commented out all the "error" lines in "grades.php"

Now when I click "Download in Execel" only the jibberish remains and when I click on "Download in Text" only the data (with no delimiters) remain.

QUESTIONS

1.  Is there suppose to be some connection between the "GradeBook" and "Shelf" module?

2.  Is the display on the screen suppose to be downloaded or should a download window open with the option to open or save the data with either button?

3.  How to get rid of the "jibberish" which appears after the "Download in Execel" button is pushed?

4.  Is there a way to upload grades to the "GradeBook"?

5.  How to remove the "Error" message on the "Administration" Page?

6.  Does anyone know the list of the mathematical operators which can be used in the module to indicate -- add, subtract, multiply and divide.

WP1

In reply to W Page

Re: Calculated columns in gradebook

by W Page -

Hi!

In a recent communique from Bruno he very kindly pointed out there was a "HELP" button on the "Calulated Column" GradeBook page which answered the question I posted about the mathematical operators which could be used with the "Calulated Column" GradeBook.

I say he was kind in pointing it out to me because it was right in front of me Calculated columns  and I should have seen it.  He did not tell me to RTFM.

Anyway for those of you who are like me and need things on paper.  I have converted this help information into  "*.DOC" and "*.PDF" documents.  They are attached to this post as a ZIP file.

In reply to W Page

Re: Calculated columns in gradebook

by Marc Dastous -

Did you ever resolve this issue?  It doesn't seem to affect anything, but it is annoying.  I'd just like to know how to get rid of the Error.

Marc

In reply to Marc Dastous

Re: Calculated columns in gradebook

by W Page -

Hi!

No I never got rid of it.  Actually, I thought I was the only person to have the problem occur.  Gustav has begun another thread on the Calculated Columns,
Gradebook with calculated columns in Moodle 1.3?
http://moodle.org/mod/forum/discuss.php?d=6434

I suggest you post your question there so he will know that other folk also got that "Error".  I agree it does not appear to affect the function that much.

He has done some things to improve the code as well.

WP1

In reply to Williams Castillo

Re: Calculated columns in gradebook

by Gustav W Delius -

Ooops, I had said I would include version.php in the zip file and then forgot to do so. The new attached zip file now has all the files you need to drop into your moodle installation to get the new gradebook.

And while I am at it: I have fixed the first bug in mysql.php. Now the default Totals column should be created correctly for all courses during upgrade.

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Jill Kaminski -

I need to add this functionality, but since this is a rather old post, I wanted to make sure that this gradebook.zip is the latest and greatest. Can someone please confirm that?

Also, is this the version that W Page has working in version 1.3.1?

Thanks

In reply to Jill Kaminski

Re: Calculated columns in gradebook

by W Page -
Hi Jill,

Every now and then a  developer (like Gustav who created the "CalulatedColumns") will do a "little this" and a "
little that" with the script and send it to CVSNightly a new ZIP of the updated files is generated.  The ZIP address I posted will download that script .  Therefore, it should be the "latest & greatest" of that particular script.

You might also like to try out the following AddOn called "Evaluation AddOn" .  I do not have that installed into my Test Site as of yet.  I had a litle problem with it and I am awaiting to hear from the script's developer, but, it has a nice ReadMe file you should take a look at.

Evaluation_AddOn
Download
http://moodle.org/mod/forum/discuss.php?d=7260&parent=45416
Forum
http://moodle.org/mod/forum/discuss.php?d=7260&mode=2

Martin and some of the other MoodleMaster Programmers are working on some additional grading features which may be out soon.  . You may want to ask him about them.

WP1
In reply to W Page

Re: Calculated columns in gradebook

by Jill Kaminski -

Thanks!

I got the impression from the evaluation add-on thread that this is not as good a development effort as the calculated columns. No offense meant, but it's just my impression.

Is this true?

In reply to Jill Kaminski

Re: Calculated columns in gradebook

by W Page -
Hi Jill!

That is hard to say.  I look at "Evaluation AddOn" as a supplement to "Calulated Columns".  The best think is to DL it and try it out.  I have not heart from the developer of "Evaluation AddOn" as of yet. 

If you want, I will let you know when I install it and post it here.  You will have to keep your eye out for this thread since your e-mail is not listed.

WP1
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Jacob Romeyn -

Hi Gustav

I just installed all the files on my server and have the following comments:

1.  Looks very nice in Mozilla Firebird but not so good in IE6.

2. Calculated column adds fine but the calculated result remains 0, regardless of the formulas I put in.

In reply to Jacob Romeyn

Re: Calculated columns in gradebook

by Williams Castillo -
You should be doing something wrong.. It works perfectly (and beautiful) in my site...smile

Will
In reply to Williams Castillo

Re: Calculated columns in gradebook

by Jacob Romeyn -
In reply to Jacob Romeyn

Re: Calculated columns in gradebook

by Gustav W Delius -
The new grades.php rotates the table headers by 90 degrees to save space, see http://moodle.org/mod/forum/discuss.php?d=3201. This only happens in IE browsers. If you don't like your headings to be rotated then search for and remove all occurences of
writing-mode: tb-rl;

I actually quite like the table headers to be rotated. However it only looks good if you make the following two changes:

1) in cvs:/moodle/lib/weblib.php you change in line 1154 the valign from "top" to "bottom".

2) in your theme folder in styles.php you add extra attributes to the generaltableheader style so that it becomes

.generaltableheader {
    background-image: url(<?PHP echo "$themeurl"?>/gradient.jpg);
    background-repeat: repeat-x;
    background-color: #0E05B0;
}

In the above you have to chose the background-color to match the bottom of gradient.jpg.

In reply to Jacob Romeyn

Re: Calculated columns in gradebook

by Gustav W Delius -

1.  Looks very nice in Mozilla Firebird but not so good in IE6.

Is that because the table headings are rotated by 90 degrees?

2. Calculated column adds fine but the calculated result remains 0, regardless of the formulas I put in.

That is a big weakness in the current code: when there is an error in the formula the result no error message is given but the result is simply 0. Can you send me some of the formulas that didn't work?

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Jacob Romeyn -

2. Calculated column adds fine but the calculated result remains 0, regardless of the formulas I put in.

The formulas I tried where:

A1,A2,A3

A1:A10(A1:A10}      and all of these return 0

I also tried:

  30+26+25   the result is 81

(30+35+25)/10   and the result printed is 9

S the numbers work  but not the cell names A1 etc.

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Przemyslaw Stencel -
I'd love to, especially after all those enthusiastic comments in this thread. However, the server I'm using is an old machine which barely holds my production installation (1.1.1). I used to have a dev vesrion for testing on the same machine, but now Moodle 1.2 requires more server resources than I can spare, so the only testing I can do at the moment is in the Teacher Demo course. So until it makes its way to the cvs, I can only do window-shopping with Moodle's cutting-edge features sad
A new server has been ordered and I was promised it would be up and running by the end of the week.
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Martin Dougiamas -
Core developers სურათი Documentation writers სურათი Moodle HQ სურათი Particularly helpful Moodlers სურათი Plugin developers სურათი Testers სურათი
Can columns also just contain plain constants? ie like manual columns? wide eyes

And where did you find such a nice parser?  Or did you write it yourself?
In reply to Martin Dougiamas

Re: Calculated columns in gradebook

by Gustav W Delius -

No, I did not implement manual columns. That is an entirely separate project.

I am not actually parsing the formula. I am just checking that it only contains allowed things, then substitute in the grades, and then evaluate it using eval(). I think it is safe from hacker attacks, but perhaps someone else could confirm that.

In reply to Martin Dougiamas

Re: Calculated columns in gradebook

by Williams Castillo -
I don't know what you mean by plain constant.. But I've added "my" plain constants... smile... and it worked... I used a simple average forumula plus and fixed value: ((A1+A4+A6)/3)+3

It would be nice to have an average function implemented as well... Being the formula just evalued, it think it won't be a problem.

Gustav: Great work!

Will
In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Gustav W Delius -

Tony just made the suggestion:

Could the MaxGrades be totalled as well?

That is a good idea. There should be some extra variables that one can use in the formula:

MA1, MA2, .....  for the maximum grades in activities 1, 2,....

AA1, AA2, ....    for the average grade obtained in activities 1, 2, ....

This would be easy to implement. But before I do it I will wait if someone else has other similar requests (and perhaps a better naming scheme).

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Tony Ruggiero -

Copied from another thread:

Gustav:

I like it!!!

Would it be possible to add a piece of text (as a descriptor) after the formula:

A1+A2 "Points"

B1+B2 "Hours"

This would totally do what we need and I can save me having to rework the whole program just for attendance hours.

I will work on the framed representation of your work. I have an idea for that I will e-mail you with some ideas first and see if you agree.

Tony

In reply to Tony Ruggiero

Allowing comments in formulas for calculated columns

by Gustav W Delius -

That would be easy to implement but is it really needed? After all the column names can be anything and can express clearly that you are dealing with hours.

(Note that there are not currently any B columns, we only have A for activity and C for calculated).

In reply to Gustav W Delius

Re: Calculated columns in gradebook

by Williams Castillo -
and perhaps a better naming scheme

having just avg(A1) and sum(A1) and max(A1) doesn't work for you? It seems pretty intuitive to me...

Wow... This was the Hack of the Month! Cheers!
In reply to Williams Castillo

Re: Calculated columns in gradebook

by Gustav W Delius -

Well there is the following problem: in my logic A1 stands for the grade in an activity for that particular student. max(A1,A2) for example stands for the maximum of the grades in the two activities achieved by that particular student. So it would me very confusing if we also used the notation max(A1) to be the maximum across all students.

Perhaps we could use capital letters to denote the functions that use the grades of all students. Thus for example MAX(A1) would be the maximum that ANY student achieved in activity 1.

But that still leaves us with needing a name for the maximum allowed grade for the activity, which may or may not have been achieved by any of the students. And I proposed MA1 for that number.

In reply to Gustav W Delius

Latest version of gradebook

by Gustav W Delius -
Here is my latest version which now has all the features that we need here in York. New in this version are functions sum(a,b,...) (obviously summing its arguments) and step(a) (the step function that gives 1 if a>0 and 0 otherwise). There are also new student-independent variables N (number of activity grades) and MA1, MA2, ...(maximum possible grades). Also all and Pall (sorry for the ugly choice of notation) give a list of all the activity columns or of all their percentage points respectively. Finally total is a shorthand for sum(all). The only files that have changes since the last version are cvs:/moodle/course/lib.php and cvs:/moodle/lib/db/mysql.php .
In reply to Gustav W Delius

Re: Latest version of gradebook

by david hoare -

Thank you so much - this looks brilliant - except it's not working on my site... sad

I recieve "Could not add calculated column" to almost any attempt to add a column... bad formulas are spotted (eg. I get "The formula =a2 is not allowed"), but I can't seem to get valid formulae to work...?

Is there a version belowe which this won't work?

Thanks again - this is just what I have been looking for!

David Hoare

In reply to david hoare

Re: Latest version of gradebook

by Gustav W Delius -

There should be no equal sign in your formula. "=A2" is indeed not allowed.

We have been using this in a Moodle version from September. I don't know if it works in Moodle 1.1 but I would be surprised if it didn't.

By the way: I will be placing an extended version into cvs:/contrib/gradebook in a little while.

In reply to Gustav W Delius

Re: Latest version of gradebook

by david hoare -

Thanks!

Gustav, is there an issue with summin more than 10 activities... my formulae get 'edited' when I try to enter sum(A1:A19) for example, I get a column with sum(A1:5)... this also seems to happen (or at least something odd is happening) when I try sum(Mall) - - it only seems to be getting some of the columns...

Any thoughts?

Thanks again,
David Hoare

In reply to david hoare

Re: Latest version of gradebook

by Gustav W Delius -

The formula sum(A1:A19) automatically gets edited to sum(A1:19) which is the documented syntax (see help file that you get by clicking on the question mark icon next to the "Add a calculated column" button). Also there is no Mall.

In reply to Gustav W Delius

Re: Latest version of gradebook

by Les Lusk -
I just finished installing the beta 1.2 from CVS and decided to implement this feature as well during the update.  I copied the latest files from CVS.  The gradebook comes up but when I try to create a calculated column, after entering the name and formula I get a error that says "column can't be created".  Any ideas?
In reply to Gustav W Delius

Re: Latest version of gradebook

by Bruno Chiarini -
Gustav,

Thank you so much for writing this enhanced gradebook. In our University, particularly in the College of Engineering, it is common practice to assign weights to individual assigments and drop the lowest grade out of a set of assignments. My solution was to have my own gradebook in Excel.

Before I go ahead and update Moodle with your gradebook, I have a couple of questions:
  1. Any reason why it is not included as part of Moodle 1.2b or 1.2? Stability, perhaps?
  2. What about future Moodle versions?
Thank you,

Bruno.
In reply to Bruno Chiarini

Re: Latest version of gradebook

by Gustav W Delius -

The code for the gradebook was a quick hack made to meet our requirements at the University of York. It has worked here without any problems. The reason it was not included in Moodle 1.2 is that before anything is included in the main Moodle distribution it should meet the same high standards as the rest of the code. 

Two of Moodle's strengths are its intuitive user interface and its very clear and easily extensible code. In order to maintain this extremely high quality, it requires feedback from several testers and developers before a new feature is included.

If you have a use for the feature, I would encourage you to test the gradebook. Perhaps you should install a separate testing Moodle and test it out there before letting it loose on your students. But as I said: it works fine in a production environment here. Let us know your experiences.

In reply to Gustav W Delius

Re: Latest version of gradebook

by Ray Kingdon -
Gosh, what a long thread big grin Shows it's popular. I'm using calculated columns in my production 1.1 system and they work fine. They're now a "must have". Is the patch conpatible with 1.2?
In reply to Ray Kingdon

Re: Latest version of gradebook

by Gustav W Delius -

We are using it in 1.2 with no apparent problems.

You are right, maybe it is time to start a new thread.

In reply to Gustav W Delius

Re: Latest version of gradebook

by Eduardo Hernandez -
Hello Gustav,

I have access gradebook from CVS and try it under Moodle 1.5.3. While it told me that database was correctly updated, and I can see the Total column in every course, I can't find (or see) the "Add calculated column".

Am I doing something wrong?.

NOTE: I have also installed  Gradebook Plus from http://cdc.humboldt.edu/moodle/course/view.php?id=3&topic=1%20alt=Gradebook%20Plus
Eduardo
In reply to Ray Kingdon

Re: Latest version of gradebook

by W Page -

Hi Ray!

What version of Calculated Columns are you using.  I had a lot of problems installing the script.  Could you post a zipped copy of it (if you still have it).  I have very little succes with the CVS copy of it and it is not in the "Modules" download section of Moodle.

Thanks in advance,

WP1

In reply to W Page

Re: Latest version of gradebook

by Gustav W Delius -
O.k., what I should have said was that we were using the gradebook under 1.1 and then upgraded to 1.2 using CVS and the gradebook continued to work. Of course the upgrading may well have changed something in the files. So I don't know whether the original 1.1 files will work under 1.2. We really need someone to look into this. I'll start a new thread.
In reply to Gustav W Delius

Screwed up gradebook upgrade - reverted back to old

by David Brotman -

Okay, I admit I'm new at this moodle script and I tried as best as I could to install Gustav's gradebook upgrade but I ended up with an error message after logging in that said undefined function call from index.php - print_section_block(). Not knowing where that came from, I just reinstalled the old files and it works okay now. But, I would like to know what I might have done wrong. Here is a chronology of what I did.

1) Downloaded zip file in Gustav's first message. Unzipped files.

2) Noticed that version.php was not included in zip file.

3) Went to files linked from message at cvs. Downloaded most recent versions of all files, including version.php.

4) Copied to corresponding location on web server.

5) Went to admin to integrate upgrade.( Fine, no problems there)

6) Logged in and that's when I received error message.

Help, please!sad