Gradebook with calculated columns in Moodle 1.3?

Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -
Number of replies: 37

There is some code in cvs:/contrib/gradebook/ which provides calculated columns in the gradebook. These calculated columns give you a lot of flexibility in how you calculate grades from the scores of the individual assignments and quizzes. It would be good if this code could be included in Moodle 1.3. This would require some testing and improving of the code. Any volunteers?

The gradebook has been discussed in a rather long previous thread, see http://moodle.org/mod/forum/discuss.php?d=3784.

The instructions for the calculated columns are:

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) and Pall to denote the list of all percentage grades for all activities. Note that A(1+2) will not work, it has to be A2.

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 average of the best n values among a,b,... If n is not an integer then it is rounded to the nearest integer first.
sum(a,b,...) the sum of the values 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
step(a) the step function returns 1 if a is positive and 0 otherwise
step(a,b,...)) counts how many of its arguments are non-zero.

You can also use the following student-independent variables:

N The total number of activity columns (including hidden ones). Thus if the last activity column is A6 then N=6. But note that you can NOT refer to A6 as AN.
MA1, MA2, ... The maximum possible grades in activities 1, 2,...
HA1, HA2, ... The highest achieved grades in activities 1, 2,...
AA1, AA2, ... The average of the grades achieved in activities 1, 2,...

An example: if the final grade should be on a scale of 0 to 10 and should be obtained as the best 2/3 of all assignments then you could use the formula

round(best(2*N/3,Pall)/10).

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.

Average of ratings: -

Re: Gradebook with calculated columns in Moodle 1.3?

by W Page -

Hi Gustav!

I would be glad to be a tester. smile smile smile

I know there is some code for Calculated Columns in the CVS but for some reason, I am having a big problem getting all the proper code for the script from there.

As you can see from my post on the previous thread, I even had a database installation problem which would not go away.  I am so frustrated and intimidated by CVS I usually wait to see if the developer posts a ZIP file or look for it on the Add-on/Module page.

One thing that would be nice to see is the ability to demonstrate learning periods (semesters, trimesters, etc more easily).  I dunno, maybe there is a way to do this but I do not understand or know how to do it.

WP1

Re: Gradebook with calculated columns in Moodle 1.3?

by Ger Tielemans -

I have at least one real teacher who wants to test it: he is using the current gradebook as no one else.


We struggle with the same period problem: having a lot of activities in one course.
You get very big gradebook-tables, gives you a bad overview when you want to see it on the screen. 

  • Having an option to hide the scores of previous periods could help.
  • We now consider to solve it by creating a course for each period. (four in a year)

Re: Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -

I have merged the new grades.php from Moodle 1.2 into the old grades.php with the calculated columns and committed it to CVS.

Dear WP1, posting zip files always has the disadvantage that they get out of date and then people get confused. I will send you one privately if you let me know your email address (hidden in your profile).

Re: Gradebook with calculated columns in Moodle 1.3?

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Gustav,

Your calculated columns are fantastic!! cool

Great job, ciao smile

PD: Some quickly thoughts (quickly thoughts):

- The "average" and "best" rows situation: perhaps at the bottom...
- As moving activities is a problem: Can formulas be modified on the fly to adjust them to the new position of every activity or can be found another fixed-identifier for each column in order to avoid this issue.
- Exporting formulas (instead of values) to excel could be an interesting option?
- To have a list of common formulas (susceptible to be applied usually), ready to be inserted with one click could be an option?
- An option to edit formulas in a "graphical" form (I really think that actual syntax rules are quite simple, but...).

Only ideas....sorry smile

Re: Gradebook with calculated columns in Moodle 1.3?

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Another idea, sorry again wink

- Could it be possible to include some comments per student and per student/column?

Ciao smile

Re: Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -

Per student comment in the gradebook is a good idea. Per student/column comments should be handled by the relevant modules.

So who is going to write this?

Re: Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -

Hi Eloy,

those are very good ideas.

In particular having a fixed identifier for the grade columns would be useful. So internally the formulas should probably refer to the coursemodule id rather than the column name. This may require a rewrite (which wouldn't be a bad thing anyway).

Re: Gradebook with calculated columns in Moodle 1.3?

by Marc Dastous -

Gustav, thank you so much for the merge.  I downloaded the CVS and everything works great!!

Now, I want to use the calculate column to reflect a straight average of all the assignments (21) for each student.  In Excel the formula would be =sum(A1:A21)/21, but that is not working.  How would I enter the formula in the Add a Calculated Column field for this scenario?

Thank you in advance for your help!!

Marc

Re: Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -

There should be no = sign in the formula. Just use sum(A1:A21)/21. A simpler alternative would be sum(all)/N which will work no matter how many assignments there are.

Whoever will produce the new version of the gradebook might strip of the = sign automatically for people who are used to putting it in.

Re: Gradebook with calculated columns in Moodle 1.3?

by Marc Dastous -

I still get an error that says ":cannot add calculated column".  Any idea why that might be the case?  When I click continue it takes me back to the site homepage.

Marc

Re: Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -
I can only guess. Perhaps your grade table is not set up correctly. Did you follow the instructions in the Readme.txt file regarding the creation of the table?

Re: Gradebook with calculated columns in Moodle 1.3?

by Marc Dastous -

Great I got that to work.  However, I now have the red word ERROR at the top lef tof my admin page.  How would I remove that?

I realized, after the last post, that sum(all)/N would also include the fields with no grades.  So actually I want a formula that will only use fields that have a grade in them (ie sum(all)/N where N=the number of assignments with a grade.)

Any ideas?

Marc

Re: Gradebook with calculated columns in Moodle 1.3?

by W Page -

Hi Gustav,

My e-mail program rejected the zip.  I am not clear why.  Would you please send it again or better yet just e-mail a link to me to download it.

Thanks again in advance.

WP1

Re: Gradebook with calculated columns in Moodle 1.3?

by Les Lusk -
The "cannot add calculated column" error (which I also had and in my case) was caused by the table not being created.  It seems I followed all of the instructions except changing the version date within the weblib script (so even though it was there - it never ran).  Once I changed that date everything worked like a charm.  Thanks for all your work...

Re: Gradebook with calculated columns in Moodle 1.3?

by Zbigniew Fiedorowicz -
It would be a good idea if there was some provision for a new category of grades, "external grades".  It is a rather glaring omission in a CMS to have no good way of importing examination grades.  To be sure there is a workaround, which we currently use, to put such grades into an offline assignment, and to edit the language pack to change "assignment" to "assessment".  However this would be very confusing for sites which also use assignments.

If someone starts work on improving the Moodle gradebook to include such an extension, I will contribute our code for uploading grades from a csv file to this effort.

Re: Gradebook with calculated columns in Moodle 1.3?

by Ray Kingdon -
Having said how fine caculated columns were working, one of my students came back today with something that looks like a bug sad.

I've got three calculated columns which correspond to the three parts of the course. The overall mark for the course is calculated with the formula (C2+C3+C4)/3. (C1 is the total column). In my Grades page as teacher the numbers look fine. My student today had a overal mark of 75.7. However on their Grades page the mark is 48.8%. The three component marks (C2, C3 and C4) are the same in both views - my view and the student's view. It's just the "Average" that's wrong. Of course it's that final mark that's worrying her.

Weird or What?

Re: Gradebook with calculated columns in Moodle 1.3?

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Zbigniw,

thinking about your "external" or "manual" grades, I can imagine two methods to include that functionality into Moodle. Each one has their positive and negative implications but we could discuss them a bit:

1.-Include the "external" grades as part of the "grade system". It implies having a "central" table (at least) to store n grades per course/student. Then the "gradebook" should be modified to show/use/do calculations with this new table. Perhaps the calculations syntax should be changed to distinguish this type of columns, export to text/excel should be modified...

2.-Include the "external" grades as a completely new module. Its function should be a simple interface to type and import grades. Then the *current* gradebook implementation could use it without differences at all. In the other side, some changes should be done (when displaying courses) to avoid showing this activity to students. This initially simple module could become more and more complex in the future with new additions (using it to allow students to grade themselves, to others, include notes...).

I don't want to comment my preference now wink, first a bit of brainstorming about both methods will be welcome...

Ciao (coming back in two days) smile

Re: Gradebook with calculated columns in Moodle 1.3?

by Marc Dastous -

I've run into this problem which I believe is a bug, but you be the judge...

I have deleted all calculated columns from my courses.  However, for some reason new calculated columns magically appear.  I love the way the assignments are vertical in the "Teacher" view, but I don't want the calculated columns.  How can I make this happen.

See the attached zip for an example.

Marc

Re: Gradebook with calculated columns in Moodle 1.3?

by Gustav W Delius -
The "Total" column that existed in the old gradebook has been replaced by a calculated column in the new gradebook because people may want to calculate the total differently or want to use a different name for it. Apparently there is some code in the gradebook that automatically creates a "Total" column when there is none. It seems that in your case this code has gone wong and is creating new "Total" columns even though there already is one. Do you think it should be possible to not have any calculated column? Doesn't everyone want to have at least a "Total" column?

Re: Gradebook with calculated columns in Moodle 1.3?

by Marc Dastous -

True,

Personally, I do want the total column, but just onewink  I would like to also have the Calculated column as well, but not until it is functioning properly. 

I am not a PHP programmer, so delving into the code to determine the confilct is not an option for me.  My goal for this summer is to take a coupple of PHP classes to at elast get some better understanding.

Thank you Gustav for helping me clarify my request.

Marc

Re: Gradebook with calculated columns in Moodle 1.3?

by Jason Cole -
I have a graduate student working on reworking and extending the gradebook. I'll point her to this conversation. As soon as I get her project proposal I'll post it for comment.

Any other ideas and suggestions for your dream gradebook?

Re: Gradebook with calculated columns in Moodle 1.3?

by W Page -
Hi Jason,

I think the following would be useful additions/adjustments to Gustav's wonderful script,
  1. The ability to separate out grading periods like semesters, trimesters, quarters, sub-semesters etc with beginning and ending dates.
  2. The ability to calculate grades within each grading period.
  3. The ability to calculate a final grade from a calculation from the grading periods.  For example,
    1. First Sub-Semester Grade worth 25% toward final grade
    2. Second Sub-Semester Grade worth 20% toward final grade
    3. Third Sub-Semester Grade worth 55% toward final grade
  4. The ability to add a grade for offline work
  5. The abilty to add extra credit to work
  6. The ability to give a percentage value to each assignment on and off line.
All I can think of for now. smile

Thank you and your graduate student (I hope she is getting extra credit or a thesis out of this work. big grin) for attempting this.

WP1

Re: Gradebook with calculated columns in Moodle 1.3?

by Przemyslaw Stencel -
If I were dreaming, I would dream (on top of all the ideas mentioned elsewhere in this thread) of a paged gradebook.

Currently, some gradebooks can get veeeeeryyyyy long (horizontally). Natural breaking points could be course topics, that is, grades for activities from each topic would be on a separate page. However, the question is: where should calculated columns go? So, it might be better to make the cutting point after each 10 or 15 grades (value specified by teacher?)

And I think paging should not work in a gradebook with fewer than 10 grades - no need for it.

Cheers,
Przemek

Re: Gradebook with calculated columns in Moodle 1.3?

by W Page -
Hi Przemyslaw,

I forgot about that one.  I agree with you.

WP1

Re: Gradebook with calculated columns in Moodle 1.3?

by Paul Mazza -
I've experienced the same thing with regards to student values not calculating correctly.

Were you able to resolve this issue?

Re: Gradebook with calculated columns in Moodle 1.3?

by Ger Tielemans -
On a testmachine I implemented in the teacher admin menu grades I and grades II, the first one is the old grades, the second one is your nice gradebook. (I followed then some advise from the forum: how to keep these separate) Let the teacher decide which of the two systems he will use..

Re: Gradebook with calculated columns in Moodle 1.3?

by Paul Mazza -
Note of correction:

I had been using an earlier version of the gradebook along with Moodle 1.2.

Once I downloaded the newest files (grade.php, grades.php, gradeslib.php), all was fine.

Paul III

Re: Gradebook with calculated columns in Moodle 1.3?

by Paul Mazza -
I have noticed an odd situation wrt the student's grade.php results.

If you hide an assignment, the teacher's calculated columns will be correct. However, the student's calculated columns will either be incorrect or display Error.

I've researched this briefly and noticed that the arrays $grades and $maxgrades are complete in the teacher view and, thus the column names are valid (i.e. A1, A2, etc). But, in the student view, the hidden assignment(s) are not included in the arrays and, therefore, the column names do not match up as expected. This results in incorrect values, or "Error" messages due to attempted divide-by-zero.

I will continue to look for an acceptable solution (besides simply unhiding the assignments).

If a solution already exists, please let me know.

Thanks,

Pau lIII

Re: Gradebook with calculated columns in Moodle 1.3?

by Paul Mazza -
Here is a modified grade.php file that corrects the problem with hidden assignments.

Please be sure to rename your old script just in case the new one blows up.

Paul III

Re: Gradebook with calculated columns in Moodle 1.3?

by D.I. von Briesen -
I'm really confused.
Is this in v. 1.3 or not? I've got a month old install of 13 beta and dont' see anything...
d.i.

Red ERROR and multiple Total columns

by Jill Kaminski -

I think I've come up with the solution for both of these problems.

In the readme file on CVS, it says to "append" some code to the mysql.php file. Here's what the bottom of the file looks like before you do this:

        ....
        }
    }

    return $result;
}

?>

Most programmers would (correctly) put the code before the "return $result;". I say "most", because I'm a programmer, but I still screwed this up today. Most non-programmers would think that "append" means "append", and put it either right before or right after the ?> (I incorrectly put it right before, knowing that it needed the end tag).

If you paste the code right before the return line, AND you change the version in this file and in version.php, and you visit the Admin page, you'll get several complaints about recreating the database. But it will work! No more ERROR and no more new Total column everytime you go to the Admin page.

Also, being a dorky programmer, I wanted to be able to use the modulus operator in my formulas. Here is the line I changed to allow %.

// Sum may contain the following characters:
$check = strtr($check, '0123456789+-*/%(),:N', "                    ");

I added a % within the single quotes, and an extra space within the double quotes.

smile

Re: Red ERROR and multiple Total columns

by W Page -
Hi Jill!

You should not have gotten the error message with the zip address I gave you (Was it you I gave it to? I cannot remember) Anyway, I will try the code/hack you provided for %. If it works, that is a nice hack of a hack.

WP1

Re: Red ERROR and multiple Total columns

by Marc Dastous -

Thank you so much Jill, I no longer get the extra column every time.  However, I would still like to know how to only calculate using columns that have grades in them, or that have values.

For example, 1000 points possible, 10 assignments for the entire class, student finishes assignment #1 with 100, grade should be 100.0, not 10. 

Has anyone figured out how to only use the columns that have a grade?

Marc

Re: Red ERROR and multiple Total columns

by Jill Kaminski -

I think that the sum of all 10 assignments will give you 100 in this case, Marc. Blank scores (that don't have grades or values in them yet) calculate as zeros.

Re: Red ERROR and multiple Total columns

by Jill Kaminski -
I used the CVS code, not the ZIP code. It seemed more "official". But yeah, that was me.