CSC/ECE 517 Fall 2022 - E2278. Improve assessment360 controller: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Initial template commit)
 
m (Input from previous year project)
Line 1: Line 1:
==Background==
This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.
Most of the projects and assignments in CSC517 and on Expertiza are peer-reviewed, and these peer-reviews are graded by the teaching staff. When the staff grade reviews, they are viewed in the review-grader interface. The staff can assign the score and provide feedback using the textboxes provided in the right columns of the table. The staff are also allowed to read the reviews in the summary view.


There appears to be certain sections of the main review-grader page as well as the summary page that are not working correctly or there is a desire for them to be updated. These issues have to do with calculation of a student's score / average score, the visual representation of the scores, efficient usage of space within the view, and a need for rows of the table(s) to be numbered. We go into further depth about the issues later in this document.
== Peer Review Information ==


==The Project==
For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below:
Certain aspects of the UI and minor score calculation logic of the review grader system in Expertiza need to be enhanced/refactored. These issues are not major and mainly have to do with UI, and therefore should not require the development of new unit tests. Below is a detailed description of actionable issues that will be addressed in this work.


===The Main Review-Grader Page===
URL: http://152.7.99.75:8080
[[File:Expertiza_review_report.PNG|1200px|]]
====Issue Description====
#This project eventually morphed into a bug-fixing and beautification project. There were some serious inconsistencies, bugs, and syntax issues with the beta branch review grader section. These were found and solved to the best of our ability.
#Fix the “Score awarded/average score” column so that it is populated with the correct numbers. It is supposed to report the score by the current student reviewer in the first round, the average score by all reviewers in the first round, and ditto for the second round. If the number of rounds ≠ 2, then the number of scores should be adjusted appropriately.
## There is a bug having to do with "Avg. score" not being calculated sometimes, like when the team that was reviewed should definitely have an average score to be displayed, even if the current student reviewer did not complete the review. This bug will have to be examined further.
#Number the rows of the table (e.g., “2. Student 8370”) so it is easy to count the lines.  This will help assign each TA (and the instructor) an equal number of reviews to grade.


====Design Strategy====
Instructor login:  
# The "Scores" issue. Unfortunately, this task was more complicated than we originally believed. The team was advised to try to find out as much as possible about the bug, and fix it if possible, but it involves many different classes within Expertiza.
## The variable @avg is computed in the file app/models/answer.rb, and is initially set to nil if an assessment is not present. The variable @avg is also set to a placeholder "----" in the file app/helpers/review_mapping_help.rb. If "@avg_and_ranges[team_id][round][metric]" is not nil, the "@avg" will be set to the average scores. The "@avg_and_ranges" is set to the result returned by method compute_avg_and_ranges_hash in method "review_response_map" in file "app/helpers/report_formatter_helper.rb". The method "compute_avg_and_ranges_hash" is defined in file "app/models/on_the_fly_calc.rb".
## The "Score awarded/average score" column in the table is actually composed of two rendered partials: views/reports/_team_score.html.erb and views/reports/_team_score_score_awarded.html.erb. Within these partials, the method get_awarded_review_score is called, which is defined in the /helpers/review_mapping_helper.rb helper file (line 138). It is within this helper file that the @avg instance variable is also defined. It appears as though the previous team spent some time tracking down the source of the bug in the presentation of the "Avg. score" in the table, but were unable to fix it.
## The @avg instance variable is defined in the method get_review_volume, found in line 152 in /helpers/review_mapping_helper.rb - however, in the beta branch, the method that is called within views/reports/_team_score.html.erb and views/reports/_team_score_score_awarded.html.erb is called get_review_metrics. It appears this error is not present in the master branch of Expertiza.
## Another issue with the scores was that a "nil" value was showing - this issue was simply due to a forgotten check that needed to be added into the app/views/reports/_team_score.html.erb.
#In the _review_report.html.erb file, Line 61, we need to replace the 'each' method with 'each_with_index' to make sure that all rows are indexed. In line 69 add a line to display the index number and make sure that the value of the variable must be index+1, since the values are zero indexed


====Design Pattern====
Username: '''instructor6'''
This project mainly focuses on the UI, so no specific GoF design pattern is particularly being considered. Comments will be added where deemed necessary to further illuminate the functionality of the code. If needed, (if new methods/classes/views are added) this will be updated to reflect those changes.


===The Summary Page===
Password: '''password'''
[[File:Summary_page.PNG|1200px|]]
====Issue Description====
#Checkbox items take up far too much space.  Remove duplicated header lines and show just columns of checkboxes to the right of the “questions.”  Also, it is unnecessary to prefix each by “[Question]”.
#Adjust column width intelligently.  The “Reviewee” and “Score” columns are much wider than necessary.  The “Comments” column is also too wide for easy reading.  So consider how the page might be reorganized to take better advantage of the available space.  One option might be to show the comments vertically, astride each other, rather than horizontally, above and below each other.  Mock up your proposal and discuss it with your mentor.
#Get rid of “Review: Round1”.  It should be, “Review Round 1”


====Design Strategy====
Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: http://152.7.99.75:8080/assessment360/index?course_id=184
# To get rid of the duplicated header lines, we will modify view_review_scores_popup.html.erb either by implementing comments vertically, astride each other or by displaying the header columns only once. To tackle the problem of Checkbox items taking up too much space we plan to implement the following mock up."[Question]" would be deleted.
The course ID here is an example, you can add the course ID of your choice.


''Original :''
[[File:E2219 Navigation.jpeg|800px]]


[[File:Og_checkbox.PNG|1200px|]]
Please note that due to VCL constraints, the page will take few mins to load and render the data. Please wait for the page to '''load completely''' before starting the peer review.  


[[File:Og_checkbox1.PNG|1200px|]]
== Introduction ==


''Mock_up:''
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.
The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified.


[[File:Mock_up.PNG|1200px|]]
== Issues and Description of Fixes ==
In our work on improving this feature, we have handled the following issues and made the following improvements:


# Concerning column width, we will play around the preset width in /app/views/popup/view_review_scores_popup.html.erb, the previous team went with 10% for "Reviewee", 5% for "Score" and it looks reasonable.
=== Refactoring ===
# "Review Round" header is located at /app/models/review_response_map.rb, and can be easily modified by adding white space.


====Files to be Viewed/Modified====
The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews.  
Below is a rough list of files that we estimate this particular action item will involve:
#/app/views/popup/view_review_scores_popup.html.erb
#/app/models/review_response_map.rb
#/app/assets/stylesheets/grades.scss


==Test Plan==
The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment.  
Most of the changes in this project are UI focused. Due to this, most of the testing was done via manual functionality testing. However, because of the changes in review_mapping_helper.rb, we did have to make changes to the review_mapping_helper_spec.rb file in order to reflect this. The code diff is shown below, and the process for manual testing is also displayed.
In addition to correcting this, we also simplified the process by refactoring the code (please see the next section for the code).


[[File: Review_mapping_helper_spec_diff.png|1200px]]
The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.


According to Expertiza Bot, our code test coverage increased by 3.6%.
=== UI changes ===
The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course.
We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.


=== Variable Names, Cosmetic Issues, Comments ===


In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly.
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.


Just for reference-
== Fix details and Code Explanation ==
The processes for testing accessing the review reports:


====Testing Review Grader View====
=== Files Changed ===
#Login using an instructor account, such as: instructor6 / password
The following files were altered and edited in the course of our work on this feature:
#Go to "Manage >> Assignments" and choose one assignment with reviews, i.e., "Program 1", and click on "View Reports".
Assessment360_Controller.rb (under app/controller)
#There will be a dropdown selector to choose which report to view - select "Review report" from the dropdown, and click "View".
This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular, easier to understand and also to incorporate DRY.  
#Check to make sure that the "Avg. score" for reviewed assignments is being shown correctly.
#Check if column widths are appropriate. Make sure the text "Score awarded / Avg. score" instead reads "Score / Avg. score".
#Verify the bar graph display of scores.


Index.html.erb (under app/views/assessment360)
The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.


==Modifications==
=== Issue Fix Details ===


===The Main Review-Grader Page===
1) '''app/controllers/assessment360_controller.rb'''
====Files Modified====
Below is a rough list of files that we estimate this particular action item will involve:


#/app/helpers/review_mapping_helper.rb
[[File:E2219 assessment360 controller 1.png|800px]]
#/app/views/reports/_review_report.html.erb
#/app/views/reports/_team_score.html.erb


====Review Mapping Helper====
[[File:E2219 assessment360 controller 2.png|800px]]
The review mapping helper is a module that is used extensively throughout the peer review system in Expertiza to perform a number of things (perhaps too many) including calculating scores, finding team colours, preparing grade data visuals, and other useful computations. In this project, we wanted to fix the inconsistencies between the beta and master branch with specific regard to the get_review_volume() and get_review_metrics() method. These performed the same computation, yet get_review_metrics was called but not defined in the beta branch. This was fixed, and the code diff is presented below. The comments were added later, and a separate picture is shown below.
[[File:Get_review_metrics.png|1200px|]]


Comments:
[[File:E2219 assessment360 controller 3.png|800px]]


[[File:review_metrics_comments.png|600px]]
[[File:E2219 assessment360 controller 4.png|800px]]


====Review Report View====
'''Code changes'''
The addition of indices to each of the reviews for this assignment was a simple fix. Replacing each with each_with_index and printing to HTML solves the issue.
[[File:Index_review_report_html.png|1200px]]


====Team Score====
1. In all_student_all_reviews function, the DB calls are by creating init_data function.
This is a partial HTML that is rendered within the Review Grader view. Changes were made to it to reflect that changes made to get_review_metrics, and the diff is shown below.
[[File:Team_score_html.png|1200px]]


===The Summary Page ===
2. The init_data function, removes DB calls inside nested for-loops (look for old code, below) which makes db call for every iteration, the code has been refactored in such a way that it preloads the required data using assignments.includes([:participants]) (look for new code, below). This way, instead of making multiple db calls across diff functions, we load the required data and thereby reduce the processing time.
====Files Modified====
Below is a rough list of files that we estimate this particular action item will involve:


# app/views/popup/view_review_scores_popup.html.erb
3. The major change, which we've incorporated here is moving the functions which weren't used in other modules into private. Moving excess functions to private, helps keep the controller more CRUD-like and differentiates to the developer which functions are used by the controller to work, and which ones are the functions of the controller.
#app/assets/stylesheets/grades.scss
#app/models/review_response_map.rb


====New Look Summary Page====
[[File: New_summary_page.PNG|1200px]]


====Issues Fixed====
'''Old Code (with complex for loops and more db calls)'''


*We decided to fix all of our issues with summary page like columns taking too much width, header texts like "Reviewee" and "Score" repeated unnecessarily by reorganizing the page to take better advantage of the available space. We placed the questions vertically, astride each other, rather than horizontally.
@course_participants.each do |cp|
*"Scores" and "comments" column were merged together for aesthetic reasons and to improve readability. The scores are displayed with a colorful background indicating its value.
      # for each assignment
''Before Modification''
      # [aggregrate_review_grades_per_stu, review_count_per_stu] --> [0, 0]
                                                                                         
      %w[teammate meta].each { |type| instance_variable_set("@#{type}_review_info_per_stu", [0, 0]) }
[[File: Scores_comments_old.PNG|600px]]
      students_teamed = StudentTask.teamed_students(cp.user)
      @teamed_count[cp.id] = students_teamed[course.id].try(:size).to_i
      @assignments.each do |assignment|
        @meta_review[cp.id] = {} unless @meta_review.key?(cp.id)
        @teammate_review[cp.id] = {} unless @teammate_review.key?(cp.id)
        assignment_participant = assignment.participants.find_by(user_id: cp.user_id)
        next if assignment_participant.nil?
        teammate_reviews = assignment_participant.teammate_reviews
        meta_reviews = assignment_participant.metareviews
        calc_overall_review_info(assignment,
                                cp,
                                teammate_reviews,
                                @teammate_review,
                                @overall_teammate_review_grades,
                                @overall_teammate_review_count,
                                @teammate_review_info_per_stu)
        calc_overall_review_info(assignment,
                                cp,
                                meta_reviews,
                                @meta_review,
                                @overall_meta_review_grades,
                                @overall_meta_review_count,
                                @meta_review_info_per_stu)
      end


''After Modification''


[[File: Scores_comments_new.PNG|600px]]
'''Refactored Code (with limited iteration and db calls)'''
*“Review: Round1” was changed to “Review : Round1”. Also the title "Review scores: student5061" was changed to "Review scores by student5061" as its more indicative as a title.
    @assignments.each do |assignment|
''Before Modification''
      assignment.participants.each do |assignment_participant|
                                                                                         
        reviews[assignment_participant.user_id] = {} unless reviews.key?(assignment_participant.user_id)
[[File: Header_old.PNG|300px]]
        assignment_reviews = assignment_participant.public_send(reviews_type) if assignment_participant.respond_to? reviews_type
        # If a student has not taken an assignment or if they have not received any grade for the same,
        # assign it as nil(not returning anything). This helps in easier calculation of overall grade
        score = calc_avg_score(assignment_reviews)
        reviews[assignment_participant.user_id][assignment.id] = score unless score.nil?
      end
    end


''After Modification''


[[File: Header_new.PNG|300px]]
2) '''app/views/assessment360/index.html.erb'''


[[File: Review_round.PNG|1200px]]
[[File:E2219 indexhtmlerb 1.png|800px]]
 
[[File:E2219 indexhtmlerb 2.png|800px]]
 
[[File:E2219 indexhtmlerb 3.png|800px]]
 
1. We've created a new file called ''index.html.erb''. This file contains all the logic for the frontend of this module.
 
2. Major change that has been made is the addition of checkboxes. This way, users can filter the data that they view and view the data efficiently.
 
3. This page loads all the assignment data, and their metadata like - meta reviews, teammate reviews, peer score, topic and instructor grade. The table also contains Aggregate score and Total grade.
 
4. The checkboxes have been programmed in a way that whenever a checkbox is disabled, the corresponding column gets removed and the colspan rendering gets adjusted. Along with that, when all assignment parameters are unchecked, the assignment columns disappear completely. Same applies for aggregate score and Total Instructor Grade.
 
 
 
3) '''config/routes.rb'''
 
[[File:E2219 routes 1.png|800px]]
 
Removed old route to this page and pointed it to the newly created index page.
 
 
You can check all the issues fixed here - https://github.com/expertiza/expertiza/pull/2337
 
== Test Plan==
 
=== Automated Testing using RSPEC ===
Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.
 
1. After refactoring, most of our new test cases focus on functions which are the core of the controller - covering important aspects like who accesses the page, checking permissions for the page, how the page behaves on edge cases etc.
 
2. Using RSpec, the test cases cover various scenarios and tests each scenario in depth.
Eg, for access control, we check the access for all roles for a user comprehensively to ensure that only people with permissions can view the page.
 
3. Since most of the work in this module is computations in the back and rendering data in the frontend, we've ensured that the computations happen in their specific order and enough test cases are present for edge cases.
 
4. For backend computations, we've covered lot of edge cases like no participants to a course, when there are no reviews made by a participant, when assignment doesn't exists, insure existence_of being called before executing index page etc.
 
5. For frontend, we've covered cases like formatting of the data in the page, null dataset, score being int, float, null, displaying percentages when data is int, float, null etc.
 
Even though we've moved most of the code into private functions, the core functionalities of the controller are refactored and appropriate test cases are written to ensure high coverage.
 
Please run the following command to execute the tests:
 
rspec spec/controllers/assessment360_controller_spec.rb
 
=== Testing from UI ===
The following steps needs to be performed to test this code from UI:
 
1. Log in as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.
 
2. Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)
 
3. Alternatively, you can log in and go to this URL: http://152.7.99.75:8080/assessment360/index?course_id=184
 
4. You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza.
 
5. Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.
 
=== Code Coverage ===
 
[[File:E2219_codecov.png|800px]]
 
== Scope for future improvement ==
 
The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.
 
The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache.
 
Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.
 
'''''course_student_grade_summary''''' function inside the assessment360_controller.rb contains few unnecessary db calls which can be refactored further to increase the efficiency and reduce the processing time of the module.

Revision as of 01:33, 15 November 2022

This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.

Peer Review Information

For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below:

URL: http://152.7.99.75:8080

Instructor login:

Username: instructor6

Password: password

Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: http://152.7.99.75:8080/assessment360/index?course_id=184 The course ID here is an example, you can add the course ID of your choice.

Please note that due to VCL constraints, the page will take few mins to load and render the data. Please wait for the page to load completely before starting the peer review.

Introduction

The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages. The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified.

Issues and Description of Fixes

In our work on improving this feature, we have handled the following issues and made the following improvements:

Refactoring

The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews.

The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment. In addition to correcting this, we also simplified the process by refactoring the code (please see the next section for the code).

The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.

UI changes

The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course. We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.

Variable Names, Cosmetic Issues, Comments

In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly. Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.

Fix details and Code Explanation

Files Changed

The following files were altered and edited in the course of our work on this feature: Assessment360_Controller.rb (under app/controller) This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular, easier to understand and also to incorporate DRY.

Index.html.erb (under app/views/assessment360) The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.

Issue Fix Details

1) app/controllers/assessment360_controller.rb

Code changes

1. In all_student_all_reviews function, the DB calls are by creating init_data function.

2. The init_data function, removes DB calls inside nested for-loops (look for old code, below) which makes db call for every iteration, the code has been refactored in such a way that it preloads the required data using assignments.includes([:participants]) (look for new code, below). This way, instead of making multiple db calls across diff functions, we load the required data and thereby reduce the processing time.

3. The major change, which we've incorporated here is moving the functions which weren't used in other modules into private. Moving excess functions to private, helps keep the controller more CRUD-like and differentiates to the developer which functions are used by the controller to work, and which ones are the functions of the controller.


Old Code (with complex for loops and more db calls)

@course_participants.each do |cp|
     # for each assignment
     # [aggregrate_review_grades_per_stu, review_count_per_stu] --> [0, 0]
     %w[teammate meta].each { |type| instance_variable_set("@#{type}_review_info_per_stu", [0, 0]) }
     students_teamed = StudentTask.teamed_students(cp.user)
     @teamed_count[cp.id] = students_teamed[course.id].try(:size).to_i
     @assignments.each do |assignment|
       @meta_review[cp.id] = {} unless @meta_review.key?(cp.id)
       @teammate_review[cp.id] = {} unless @teammate_review.key?(cp.id)
       assignment_participant = assignment.participants.find_by(user_id: cp.user_id)
       next if assignment_participant.nil?
       teammate_reviews = assignment_participant.teammate_reviews
       meta_reviews = assignment_participant.metareviews
       calc_overall_review_info(assignment,
                                cp,
                                teammate_reviews,
                                @teammate_review,
                                @overall_teammate_review_grades,
                                @overall_teammate_review_count,
                                @teammate_review_info_per_stu)
       calc_overall_review_info(assignment,
                                cp,
                                meta_reviews,
                                @meta_review,
                                @overall_meta_review_grades,
                                @overall_meta_review_count,
                                @meta_review_info_per_stu)
     end


Refactored Code (with limited iteration and db calls)

   @assignments.each do |assignment|
     assignment.participants.each do |assignment_participant|
       reviews[assignment_participant.user_id] = {} unless reviews.key?(assignment_participant.user_id)
       assignment_reviews = assignment_participant.public_send(reviews_type) if assignment_participant.respond_to? reviews_type
       # If a student has not taken an assignment or if they have not received any grade for the same,
       # assign it as nil(not returning anything). This helps in easier calculation of overall grade
       score = calc_avg_score(assignment_reviews)
       reviews[assignment_participant.user_id][assignment.id] = score unless score.nil?
     end
   end


2) app/views/assessment360/index.html.erb

1. We've created a new file called index.html.erb. This file contains all the logic for the frontend of this module.

2. Major change that has been made is the addition of checkboxes. This way, users can filter the data that they view and view the data efficiently.

3. This page loads all the assignment data, and their metadata like - meta reviews, teammate reviews, peer score, topic and instructor grade. The table also contains Aggregate score and Total grade.

4. The checkboxes have been programmed in a way that whenever a checkbox is disabled, the corresponding column gets removed and the colspan rendering gets adjusted. Along with that, when all assignment parameters are unchecked, the assignment columns disappear completely. Same applies for aggregate score and Total Instructor Grade.


3) config/routes.rb

Removed old route to this page and pointed it to the newly created index page.


You can check all the issues fixed here - https://github.com/expertiza/expertiza/pull/2337

Test Plan

Automated Testing using RSPEC

Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.

1. After refactoring, most of our new test cases focus on functions which are the core of the controller - covering important aspects like who accesses the page, checking permissions for the page, how the page behaves on edge cases etc.

2. Using RSpec, the test cases cover various scenarios and tests each scenario in depth. Eg, for access control, we check the access for all roles for a user comprehensively to ensure that only people with permissions can view the page.

3. Since most of the work in this module is computations in the back and rendering data in the frontend, we've ensured that the computations happen in their specific order and enough test cases are present for edge cases.

4. For backend computations, we've covered lot of edge cases like no participants to a course, when there are no reviews made by a participant, when assignment doesn't exists, insure existence_of being called before executing index page etc.

5. For frontend, we've covered cases like formatting of the data in the page, null dataset, score being int, float, null, displaying percentages when data is int, float, null etc.

Even though we've moved most of the code into private functions, the core functionalities of the controller are refactored and appropriate test cases are written to ensure high coverage.

Please run the following command to execute the tests:

rspec spec/controllers/assessment360_controller_spec.rb

Testing from UI

The following steps needs to be performed to test this code from UI:

1. Log in as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.

2. Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)

3. Alternatively, you can log in and go to this URL: http://152.7.99.75:8080/assessment360/index?course_id=184

4. You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza.

5. Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.

Code Coverage

Scope for future improvement

The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.

The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache.

Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.

course_student_grade_summary function inside the assessment360_controller.rb contains few unnecessary db calls which can be refactored further to increase the efficiency and reduce the processing time of the module.