CSC/ECE 517 Spring 2018 E1812: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:


The get_weighted_score checks the round which the assignment questionnaire has been used and calls the compute_weighted_score method to finish the calculation. As for the symbol, if the questionnaire has never been used, the compute_weight_score just takes the symbol of the questionnaire; if the questionnaire has been used, the symbol is the symbol of the questionnaire plus the round. The compute_weighted_score method takes the symbol and the score to complete the final calculation. The method uses the raw average scores times the weight of the questionnaire and divides by 100.0. If the raw average is nil, it returns zero.
The get_weighted_score checks the round which the assignment questionnaire has been used and calls the compute_weighted_score method to finish the calculation. As for the symbol, if the questionnaire has never been used, the compute_weight_score just takes the symbol of the questionnaire; if the questionnaire has been used, the symbol is the symbol of the questionnaire plus the round. The compute_weighted_score method takes the symbol and the score to complete the final calculation. The method uses the raw average scores times the weight of the questionnaire and divides by 100.0. If the raw average is nil, it returns zero.
The compute_reviews_hash method returns the hash of reviewers. First, the method will check whether the assignment varies rubrics by round and deal with the two cases separately. This procedure is also shared by the compute_avg_and_ranges_hash and scores methods because the difference between those two situations is critical. The class method varying_rubrics_by_round? of the assignment is essential. It searches for assignment_questionnaires which has been used in 2 rounds with for the current assignment. If no assignment questionnaire meets the conditions, it returns false.
The compute_reviews_hash method returns the hash of reviewers. First, the method will check whether the assignment varies rubrics by round and deal with the two cases separately. This procedure is also shared by the compute_avg_and_ranges_hash and scores methods because the difference between those two situations is critical. The class method varying_rubrics_by_round? of the assignment is essential. It searches for assignment_questionnaires which have been used in 2 rounds with for the current assignment. If no assignment questionnaire meets the conditions, it returns false.


For both cases, the hash of reviewers are generated with private methods and the raw score is rounded. If the assignment varies rubrics by round, every round will be included.
For both cases, the hash of reviewers are generated with private methods and the raw score is rounded. If the assignment varies rubrics by round, every round will be included.
The compute_avg_and_ranges_hash method calculates the average scores, the range of scores and their corresponding hashes. Using the built-in method review_questionnaire_id, it collects review questions and finds questions. The compute_scores method of answer model is called to calculate the maximum, minimum and average of scores. Similar to the get_weighted_score method, if the assignment varies rubrics by round, every round is included.


===Testing plan===
===Testing plan===
Testing.
Testing.
Objects were created using structures left in the factory file when needed. An example of this is  let(:questionnaire) { create(:questionnaire, id: 1)}.
Objects were created using structures left in the factory file when needed. An example of this is  let(:questionnaire) { create(:questionnaire, id: 1)}.
After developing different objects by this method, the objects gets used in test cases to either avoid the implementation of the methods specified in the model or make it return a value which can be used to test if conditions.
After developing different objects by this method, the objects get used in test cases to either avoid the implementation of the methods specified in the model or make it return a value which can be used to test if conditions.


The varying_rubrics_by_round? method has been called on self for each method except compute_total_score. Through the pattern of varying_rubrics_by_round? being used as as a if statement, test cases has been made for the behaviors if it returns true and false.
The varying_rubrics_by_round? has been called on self for each method except compute_total_score. Through the pattern of varying_rubrics_by_round? being used as an if statement, test cases have been made for the behaviors if it returns true and false.


For the compute_reviews_hash method located in the model,varying_rubrics_by_round? method called on an Assignment object will return true when multiple review phases with different review rubrics exists. Creating test examples which return true and false for the method call varying_rubrics_by_round? let the right behavior be tested. When it returns true scores_varying_rubrics behavior would have been accepted, while when return false scores_non_varying_rubrics behavior will occur.
For the compute_reviews_hash method located in the model,varying_rubrics_by_round? method called on an Assignment object will return true when multiple review phases with different review rubrics exist. Creating test examples which return true and false for the method call varying_rubrics_by_round? let the right behavior be tested. When it returns true scores_varying_rubrics behavior would have been accepted, while when return false scores_non_varying_rubrics behavior will occur.


===Links===
===Links===

Revision as of 00:38, 27 March 2018

Description

The project aims to write a unit test for on_the_fly_calc.rb. This model file provides a module for assignments to calculate different kinds of scores when loading the views. However, there was no corresponding unit test and the coverage was only 15.45% after running all test cases.

Tasks to be completed

The OnTheFlyCal module provides 4 publish methods for assignments: compute_total_score, compute_reviews_hash, compute_avg_and_ranges_hash and scores. We need to test all those methods. Privately methods are tested when testing public methods instead of tested directly.

Description of the the module

The compute_total_score method is to compute the total score of a given assignment. The method collects all questionnaires of the assignment and calls the get_weighted_score method of Questionnaire Class to calculate the total score.

The get_weighted_score checks the round which the assignment questionnaire has been used and calls the compute_weighted_score method to finish the calculation. As for the symbol, if the questionnaire has never been used, the compute_weight_score just takes the symbol of the questionnaire; if the questionnaire has been used, the symbol is the symbol of the questionnaire plus the round. The compute_weighted_score method takes the symbol and the score to complete the final calculation. The method uses the raw average scores times the weight of the questionnaire and divides by 100.0. If the raw average is nil, it returns zero. The compute_reviews_hash method returns the hash of reviewers. First, the method will check whether the assignment varies rubrics by round and deal with the two cases separately. This procedure is also shared by the compute_avg_and_ranges_hash and scores methods because the difference between those two situations is critical. The class method varying_rubrics_by_round? of the assignment is essential. It searches for assignment_questionnaires which have been used in 2 rounds with for the current assignment. If no assignment questionnaire meets the conditions, it returns false.

For both cases, the hash of reviewers are generated with private methods and the raw score is rounded. If the assignment varies rubrics by round, every round will be included.

The compute_avg_and_ranges_hash method calculates the average scores, the range of scores and their corresponding hashes. Using the built-in method review_questionnaire_id, it collects review questions and finds questions. The compute_scores method of answer model is called to calculate the maximum, minimum and average of scores. Similar to the get_weighted_score method, if the assignment varies rubrics by round, every round is included.


Testing plan

Testing. Objects were created using structures left in the factory file when needed. An example of this is let(:questionnaire) { create(:questionnaire, id: 1)}. After developing different objects by this method, the objects get used in test cases to either avoid the implementation of the methods specified in the model or make it return a value which can be used to test if conditions.

The varying_rubrics_by_round? has been called on self for each method except compute_total_score. Through the pattern of varying_rubrics_by_round? being used as an if statement, test cases have been made for the behaviors if it returns true and false.

For the compute_reviews_hash method located in the model,varying_rubrics_by_round? method called on an Assignment object will return true when multiple review phases with different review rubrics exist. Creating test examples which return true and false for the method call varying_rubrics_by_round? let the right behavior be tested. When it returns true scores_varying_rubrics behavior would have been accepted, while when return false scores_non_varying_rubrics behavior will occur.

Links

Links

Acknowledgement

Acknowledgment