-
Notifications
You must be signed in to change notification settings - Fork 39
Latest Code Logic for Submission Scoring
skyhit edited this page Dec 25, 2014
·
1 revision
private static int computeSubmissionPoints(Connection conn, long componentStateID, long currentTime, int pointVal, final long codingLength, int numSubmissions, boolean restrictPerCoderTime, long openTime, boolean isAdmin) throws SQLException, TestServicesException {
//s_trace.info("computeSubmissionPoints start");
try {
if (openTime > 0) {
double newPointVal = 0;
double elapsedTime = currentTime - openTime;
debug("Submit max points: " + pointVal);
if (restrictPerCoderTime && exceededCodingLength(conn, currentTime, codingLength, componentStateID) ) {
if (isAdmin) {
newPointVal = 1;
} else {
newPointVal = 0;
}
} else {
newPointVal = pointVal * (.3 + .7 / (10.0 * Math.pow(elapsedTime / (double) codingLength, 2.0) + 1));
}
newPointVal = Formatters.getDouble(newPointVal).doubleValue();
if (newPointVal > 0 && numSubmissions > 0) {
// Penalize them 10%
double maxPenalty = pointVal * 3 / 10;
maxPenalty = Formatters.getDouble(maxPenalty).doubleValue();
double newPenalizedPointValue = newPointVal - ((pointVal * 0.1) * numSubmissions);
newPenalizedPointValue = Formatters.getDouble(newPenalizedPointValue).doubleValue();
if (newPenalizedPointValue < maxPenalty) {
debug("Penalty less that 3/10 no more penalty");
newPointVal = maxPenalty;
} else {
debug("-----AFTER PENALTY, THAT IS REDUCED TO " + newPenalizedPointValue);
newPointVal = newPenalizedPointValue;
}
}
debug("-----THAT SUBMISSION TOOK " + (elapsedTime / 1000) + " SECONDS out of " + (codingLength / (60 * 1000)) + "mins");
debug("-----" + newPointVal + " POINTS EARNED FOR THAT SUBMISSION");
return (int) Math.round( newPointVal * 100 );
} else {
throw new TestServicesException("No open time found for componentStateID #" + componentStateID);
}
} finally {
// s_trace.info("computeSubmissionPoints end");
}
}