updated score functionality.
it now calculates the score and stores the final result in the database.