PDA

View Full Version : fmcompute and or .ini file question

drquijote
13-Jan-2010, 04:22 PM
I am using FormMail to grade and maintain scores
for quizzes submitted online.

all is well except I would like to change the score if students turn in
quizzes after the "latedate"

see http://www.271828.com/141/quiz13/

currently my .ini file runs a script and computes the "TotalScore"

I would like it to go one step further .. something like:

\$currenttime = strtotime("now");
\$latedate= xyz date; ///ie. something like \$duedate + 2 days...

if (\$currenttime > \$latedate){
TotalScore = max(TotalScore, 75);
}

but none of this works on the .ini file.. and I don't know how to properly fix it... I have purchased the fmcompute module...

any help would be greatly appreciated..

BTW if any teachers are reading this.. this set up has saved me TONS of time.. I can give a quiz each week, get it graded and returned and scores
compiled x300 students... all effortlessly...

russellr
14-Jan-2010, 12:37 AM
Hi,

The problem consists of these subproblems:
Collecting the submission date.
Collecting the "late" date.
Comparing the two dates.The Computation Module currently lacks date processing, but dates can be represented as numbers or as strings and compared that way.

To collect the submission date, derive a field on your HTML form:

<input type="hidden" name="derive_fields"
value="date_now=%fullyear%.%moy0%.%dom0%.%hour240%" />
So, 10am on Jan 14th 2010, will produce a "date_now" field of "2010011410".

This allows you to compare down to hour level. If you want to compare to minute, you can add the minutes too.

If you just want to compare to day level, leave out the hour (.%hour240%).

Next, in your computation, just create a local variable to contain the late date:

string late_date;

late_date = '2010011412'; /* this format is YYYYMMDDHH */
And, finally, import the date_now field and do your comparison:

import string date_now;

if (date_now > late_date) {
/* the logic you want to execute when the submission is late */
}
Depending on how worried you are about hacking students, you can do various checks on the "date_now" value to ensure it's real. Or, you can derive in in the INI file in the "special_fields" section.

When you change your quiz, you just have to change the "late_date" value to the new value.