Sweet, do you intend on making this open-source?
Maybe one day... To be honest, the code is rather messy at the moment, and I don't release code that's messy
I'm interested in how you derived scaled study scores for those that aren't listed on the Scaling Report (e.g. 33, 27, etc.)
I guess it linearly. Not the best, but works alright for an approximation
Here's that bit of the code (at this point, $subject_ids is an array of all the subject IDs chosen, and $scores is an associative array with all the raw study scores):
// Get the data on the subjects.
$result = mysql_query('
SELECT ID_SUBJECT, name, raw_20, raw_25, raw_30, raw_35, raw_40, raw_45, raw_50
FROM subjects
WHERE ID_SUBJECT IN (' . implode(', ', $subject_ids) . ')') or die('Could not perform query: ' . mysql_error());
// Loop through all subjects.
while ($row = mysql_fetch_assoc($result))
{
$id = $row['ID_SUBJECT'];
$score = $scores[$id];
// Huh?
// !!! Needs more validation here.
if ($score > 50)
$score = 50;
// Scores lower than 20 are treated somewhat differently.
if ($score < 20)
{
$lower = 0;
$upper = 25;
$step = 25;
// Hack? :P
$row['raw_0'] = 0;
}
else
{
// Score rounded down to the nearest 5 (eg. 32 --> 30).
$lower = $score - ($score % 5);
// And rounded up to the nearest 5 (eg. 32 --> 35). But don't exceed 50.
$upper = ($lower + 5) > 50 ? 50 : $lower + 5;
// "Step" (probably better called "run", or x2 - x1)
$step = 5;
}
// Gradient of the line connecting points (lower, lower_scaled) and (upper, upper_scaled).
$gradient = (($row['raw_' . $upper] - $row['raw_' . $lower]) / $step);
// Difference between "lower" score and the actual score.
$inc = ($score - $lower);
// Estimate the scaled score by getting the "lower" scaled score and adding
// the gradient times the difference to it. Imagine this as a linear graph
// with $gradient as the gradient, and the "lower" score as the Y-intercept.
$scaled_score = $row['raw_' . $lower] + ($gradient * $inc);
Edit: I use tabs for indentation. Why'd phpBB have to be screwy and replace them with spaces? I hate you too, phpBB! :evil: