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

From Expertiza_Wiki
Jump to navigation Jump to search
(Add problem statement and planned work)
mNo edit summary
 
(38 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is the design document for Expertiza project E2278 Improve assessment360_controller.rb. This document describes the current implementation of the assessment360 controller and the expected design changes as part of this project which is primarily UI focused.
This is the design document for Expertiza project E2278 Improve assessment360_controller.rb. This document describes the existing implementation of the assessment360 controller and the updates made to it as part of this project which is primarily UI-focused.


== Introduction ==
== Introduction ==


[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on the [http://rubyonrails.org/ Ruby on Rails] framework.
Expertiza provides a functionality that allows instructors get a full or 360-degree overview of a course they teach that includes all students in the course, all assignments, and the scores of every student in each assignment, averages, and final scores as well. This feature is supported by the assessment360 controller.  
Expertiza provides functionality that allows instructors to get a full or 360-degree overview of a course they teach that includes all students in the course, all assignments, and the scores of every student in each assignment, averages, and final scores as well. This feature is supported by the assessment360 controller.  


==Problems statement & Planned work==
The assessment360 controller is mainly responsible for the following two views:


* In the assessment controller > all_students_all_reviews view, it shows a summary including both meta reviews and teammate reviews and this makes the UI a bit complicated. Thus, this needs to be updated in a way that, the user has an option to select a filter, to either see meta reviews or teammate reviews but not both at the same time. This will eventually simplify the UI and make it easier to read through.
1) all_students_all_reviews: This view displays all the meta reviews and the teammate reviews of students for all the programs they have worked on in that semester. Additionally it provides an aggregate of these review scores as well.


* Currently in the summary page, if the student hasn't attempted a quiz or they are yet to receive a grade, the view shows that row as '-'. Instead it is preferable to depict it as '0', this will aid in better calculation of total scores. One thing to ensure here is, while calculating average such values must not be considered since the student hasn't attempted it yet, and it would be inaccurate to consider that value while calculating the average for the same.
2) course_student_grade_summary: This view displays the summary of all the programs that students have worked on, its topic, peer score and instructor grade. This includes the total and average of these scores as well.


* Currently the assessment controller > course_student_grade_summary view is missing the columns for average peer review score and average instructor assigned score. Thus, the view should be updated to reflect these scores as well.
[[File: assessment_360_class_diagram.png|700px]]


* Currently both the pages all_students_all_reviews & course_student_grade_summary show all columns by default and the user has no control to hide/unhide these columns as per their needs. Thus, a checkbox list of columns must be provided for users to select/unselect from and allow users to only see the columns of their interest.
==Problem statement==


* DB access must be minimized, and this should be implemented with the use of bullet gem.
* In the assessment controller > all_students_all_reviews view, it shows columns even if all the data in those columns is nil. Additionally, the empty data is just shown as blank and thus leads to confusion.


* Basic refactoring changes need to be implemented, like updating the variable name @teamed_count and use a more appropriate variable name.
* Currently the assessment controller > course_student_grade_summary view is missing the columns for average peer review score. Additionally, the same issue of columns being shown even if all data is empty also exists.


* Currently both the pages all_students_all_reviews & course_student_grade_summary show all columns by default and the user has no control to hide/unhide these columns as per their needs.


== Issues and Description of Fixes ==
* Basic refactoring changes need to be implemented, like updating the variable name @teamed_count and using a more appropriate variable name.
In our work on improving this feature, we have handled the following issues and made the following improvements:


=== Refactoring ===
==Problems & Solutions==


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.
===assessment controller > all_students_all_reviews view===


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.
The current implementation of this view
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.
[[File: assessment_360_all_student_all_reviews.png|700px]]


=== UI changes ===
Following problems were identified in this view:
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 ===
* Empty rows just show as blank
* Column is visible even if no data is present
* No option to filter columns to allow users to only see particular columns


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.
====Solution====
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.


== Fix details and Code Explanation ==
Below, you can see the updates made to the view to fix the above identified problems:


=== Files Changed ===
[[File: assessment_360_current_all_students_all_reviews.png|700px]]
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)
* When the meta reviews checkbox is unchecked:
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 ===
[[File: assessment_360_hidden_all_students_all_reviews.png|700px]]


1) '''app/controllers/assessment360_controller.rb'''
====Code changes====


[[File:E2219 assessment360 controller 1.png|800px]]
GitHub Commit: https://github.com/expertiza/expertiza/pull/2490/commits/dc9a3ea8b88809c1c3bcb4a3e4b900d1a1eced53


[[File:E2219 assessment360 controller 2.png|800px]]
'''Controller code updates'''


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


[[File:E2219 assessment360 controller 4.png|800px]]
* In the controller we introduced the hashmaps meta_review_exists, teammate_review_exists, which store boolean values for particular assignments indicating if at least one data point exists for that particular column or not. These values are utilized in the UI, to determine whether or not these columns should be displayed or not.


'''Code changes'''
'''UI code updates'''


1. In all_student_all_reviews function, the DB calls are by creating init_data function.
[[File: assessment_360_all_students_all_reviews_html_code.png|700px]]


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.
* Checkboxes have been introduced here to allow users to hide/unhide the columns.


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.
* Here, the variables from controller are used to conditionally check whether or not a particular column must be displayed or not.


[[File: assessment_360_all_students_all_reviews_js_code.png|700px]]


'''Old Code (with complex for loops and more db calls)'''
* The javascript is used to listen to checkbox change events and dynamically modify the view.


@course_participants.each do |cp|
===assessment controller > course_student_grade_summary===
      # 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


The current implementation of this view:


'''Refactored Code (with limited iteration and db calls)'''
[[File: assessment_360_course_student_grade_current.png|700px]]
    @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


* Missing average peer review column
* Column is visible even if no data is present
* No option to filter columns to allow users to only see particular columns


2) '''app/views/assessment360/index.html.erb'''
====Solution====


[[File:E2219 indexhtmlerb 1.png|800px]]
Below, you can see the updates made to the view to fix the above identified problems:


[[File:E2219 indexhtmlerb 2.png|800px]]
[[File: assessment_360_course_student_grade_expected.png|700px]]


[[File:E2219 indexhtmlerb 3.png|800px]]
* When the peer reviews checkbox is unchecked:


1. We've created a new file called ''index.html.erb''. This file contains all the logic for the frontend of this module.
[[File: assessment_360_course_student_grade_hidden.png|700px]]


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.
====Code changes====


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.
GitHub Commit: https://github.com/expertiza/expertiza/pull/2490/commits/884c5a3eb9323b9a1b5744755dbbc064f7fcb00d


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.
'''Controller code updates'''


[[File: assessment_360_course_student_grade_controller_code.png|700px]]


* In the controller we introduced the hashmaps topic_exists, assignment_grade_exists and peer_review_score_exists, which store boolean values for particular assignments indicating if at least one data point exists for that particular column or not. These values are utilized in the UI, to determine whether or not these columns should be displayed or not.


3) '''config/routes.rb'''
* To calculate the average peer score, the objects total_peer_score and total_peer_reviews are being utilized.


[[File:E2219 routes 1.png|800px]]
'''UI code updates'''


Removed old route to this page and pointed it to the newly created index page.
[[File: assessment_360_course_student_grade_html_code.png|700px]]


* Checkboxes have been introduced here to allow users to hide/unhide the columns.


You can check all the issues fixed here - https://github.com/expertiza/expertiza/pull/2337
* Here, the variables from controller are used to conditionally check whether or not a particular column must be displayed or not.


== Test Plan==
[[File: assessment_360_course_student_grade_js_code.png|700px]]


=== Automated Testing using RSPEC ===
* The javascript is used to listen to checkbox change events and dynamically modify the view.
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.
===Refactor assessment360_controller - Ensure design principles & patterns===


2. Using RSpec, the test cases cover various scenarios and tests each scenario in depth.  
Adding appropriate comments and updating method/variable names wherever applicable. In addition to this, the plan is to ensure the SOLID design principles are followed and code will be refactored accordingly.
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.
Currently following changes are identified:


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.
* Update the variable name @teamed_count to @team_members_count
* Include appropriate comments wherever applicable


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.
The above changes have been implemented as part of the project.


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.
== Test Plan==
 
Please run the following command to execute the tests:


rspec spec/controllers/assessment360_controller_spec.rb
The following test plan has been identified to ensure that the above changes don't break the existing system and the new code being introduced is thoroughly tested.


=== Testing from UI ===
=== Manual Testing ===
The following steps needs to be performed to test this code from UI:
The following tests have been identified to ensure that the changes made work as anticipated:


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


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)
2. Go to the all_students_all_reviews page


3. Alternatively, you can log in and go to this URL: http://152.7.99.75:8080/assessment360/index?course_id=184
3. Verify that only those columns are visible with at least one data point.


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.
4. Verify empty data is shown as '--'


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.
5. Use checkboxes at the top of the screen and ensure columns are hidden or visible based on the selected checkboxes


=== Code Coverage ===
6. Go to course_student_grade_summary


[[File:E2219_codecov.png|800px]]
7. Verify that unattempted scores show up as '--'


== Scope for future improvement ==
8. Verify that average peer score column is visible and has correct values.


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.
7. Verify that unattempted scores aren't counted toward average.


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.
8. Use checkboxes at the top of the screen and ensure columns are hidden or visible based on the selected checkboxes


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.
==References==


'''''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.
#[https://github.com/expertiza/expertiza Expertiza on GitHub]
#[https://github.com/OODD-OSS/expertiza GitHub Project Repository Fork]
#[http://expertiza.ncsu.edu/ The live Expertiza website]
#[http://yoururl.tech/expertiza  Demo link]
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]
#[https://github.com/expertiza/expertiza/pull/2490 PR Link]
#[https://youtu.be/iOz4lAbyWnQ Demo Video]

Latest revision as of 04:07, 7 December 2022

This is the design document for Expertiza project E2278 Improve assessment360_controller.rb. This document describes the existing implementation of the assessment360 controller and the updates made to it as part of this project which is primarily UI-focused.

Introduction

Expertiza is an open-source project based on the Ruby on Rails framework. Expertiza provides functionality that allows instructors to get a full or 360-degree overview of a course they teach that includes all students in the course, all assignments, and the scores of every student in each assignment, averages, and final scores as well. This feature is supported by the assessment360 controller.

The assessment360 controller is mainly responsible for the following two views:

1) all_students_all_reviews: This view displays all the meta reviews and the teammate reviews of students for all the programs they have worked on in that semester. Additionally it provides an aggregate of these review scores as well.

2) course_student_grade_summary: This view displays the summary of all the programs that students have worked on, its topic, peer score and instructor grade. This includes the total and average of these scores as well.

Problem statement

  • In the assessment controller > all_students_all_reviews view, it shows columns even if all the data in those columns is nil. Additionally, the empty data is just shown as blank and thus leads to confusion.
  • Currently the assessment controller > course_student_grade_summary view is missing the columns for average peer review score. Additionally, the same issue of columns being shown even if all data is empty also exists.
  • Currently both the pages all_students_all_reviews & course_student_grade_summary show all columns by default and the user has no control to hide/unhide these columns as per their needs.
  • Basic refactoring changes need to be implemented, like updating the variable name @teamed_count and using a more appropriate variable name.

Problems & Solutions

assessment controller > all_students_all_reviews view

The current implementation of this view

Following problems were identified in this view:

  • Empty rows just show as blank
  • Column is visible even if no data is present
  • No option to filter columns to allow users to only see particular columns

Solution

Below, you can see the updates made to the view to fix the above identified problems:

  • When the meta reviews checkbox is unchecked:

Code changes

GitHub Commit: https://github.com/expertiza/expertiza/pull/2490/commits/dc9a3ea8b88809c1c3bcb4a3e4b900d1a1eced53

Controller code updates

  • In the controller we introduced the hashmaps meta_review_exists, teammate_review_exists, which store boolean values for particular assignments indicating if at least one data point exists for that particular column or not. These values are utilized in the UI, to determine whether or not these columns should be displayed or not.

UI code updates

  • Checkboxes have been introduced here to allow users to hide/unhide the columns.
  • Here, the variables from controller are used to conditionally check whether or not a particular column must be displayed or not.

  • The javascript is used to listen to checkbox change events and dynamically modify the view.

assessment controller > course_student_grade_summary

The current implementation of this view:

  • Missing average peer review column
  • Column is visible even if no data is present
  • No option to filter columns to allow users to only see particular columns

Solution

Below, you can see the updates made to the view to fix the above identified problems:

  • When the peer reviews checkbox is unchecked:

Code changes

GitHub Commit: https://github.com/expertiza/expertiza/pull/2490/commits/884c5a3eb9323b9a1b5744755dbbc064f7fcb00d

Controller code updates

  • In the controller we introduced the hashmaps topic_exists, assignment_grade_exists and peer_review_score_exists, which store boolean values for particular assignments indicating if at least one data point exists for that particular column or not. These values are utilized in the UI, to determine whether or not these columns should be displayed or not.
  • To calculate the average peer score, the objects total_peer_score and total_peer_reviews are being utilized.

UI code updates

  • Checkboxes have been introduced here to allow users to hide/unhide the columns.
  • Here, the variables from controller are used to conditionally check whether or not a particular column must be displayed or not.

  • The javascript is used to listen to checkbox change events and dynamically modify the view.

Refactor assessment360_controller - Ensure design principles & patterns

Adding appropriate comments and updating method/variable names wherever applicable. In addition to this, the plan is to ensure the SOLID design principles are followed and code will be refactored accordingly.

Currently following changes are identified:

  • Update the variable name @teamed_count to @team_members_count
  • Include appropriate comments wherever applicable

The above changes have been implemented as part of the project.

Test Plan

The following test plan has been identified to ensure that the above changes don't break the existing system and the new code being introduced is thoroughly tested.

Manual Testing

The following tests have been identified to ensure that the changes made work as anticipated:

1. Open any course

2. Go to the all_students_all_reviews page

3. Verify that only those columns are visible with at least one data point.

4. Verify empty data is shown as '--'

5. Use checkboxes at the top of the screen and ensure columns are hidden or visible based on the selected checkboxes

6. Go to course_student_grade_summary

7. Verify that unattempted scores show up as '--'

8. Verify that average peer score column is visible and has correct values.

7. Verify that unattempted scores aren't counted toward average.

8. Use checkboxes at the top of the screen and ensure columns are hidden or visible based on the selected checkboxes

References

  1. Expertiza on GitHub
  2. GitHub Project Repository Fork
  3. The live Expertiza website
  4. Demo link
  5. Expertiza project documentation wiki
  6. PR Link
  7. Demo Video