CSC/ECE 517 Fall 2016 E1682: Improve score calculation
E1682. Improve score calculation
LocalDBCalc:
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”)
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized)
Implementation
Parent Class:ScoreCalc
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called.
Database design
A table local_db_scores will be created as:
create_table "local_db_scores",force::cascade do|t|
"local_db_scores" will have the following scores
t.integer "id", limit: 24 | id | Primary Key, Auto generated | |
t.string "Type", limit: 255 | Type | Type of score: either final or intermediate | |
t.integer "Score", limit: 24 | Score | Total score calculated based on each response to each criterion | |
t.integer "Round", limit:24 | Round | The completed round number | |
t.integer "Reference_id" , limit:45 | Reference_id | Acts as the foreign Key |
Sub class 1: on_the_fly_calc
An object of on_the_fly_calc is called when the deadline_type is not "review of review" which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:
def compute_total_scores(scores)
total=0
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}
total
end
The value in variable "total" needs to be stored in local_db_scores under "Score" and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.
Sub class 2: LocalDB_calc
An object of LocalDB_calc is called when the deadline_type is "review of review" which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:
def compute_total_scores(scores)
total=0
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}
total
end
The value in variable "total" needs to be stored in local_db_scores under "Score" and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.