CSC/ECE 517 Spring 2021 - E2110. Regulate changing of rubrics while projects are in progress

From Expertiza_Wiki
Jump to navigation Jump to search

Members

  • Nicholas Himes
  • Surya Makthal
  • Jordan Boerger
  • Sai Krishna Wupadrashta Dhinakara Subrahmanya

Project Description

While setting up an assignment, the instructor will be asked to choose different kinds of rubrics. Any of these rubrics can later be edited or changed to a different rubric. A problem arises when an assignment is underway (students have already started reviewing) and a rubric is edited or changed. Some students started reviewing with the old rubric and the rest of the students who had not started a review will be presented with the updated rubric. This usually happens when an assignment is copied from a previous year and the rubrics are not updated to match the current topic. It could be at a later point that the instructor/TA realizes this and changes it.

Goal

If the instructor does edit or change a rubric while an assignment is in progress:

  • If the change affects only the wording of a particular rubric item (e.g., to clarify the statement), no action is necessary.
  • If a rubric is replaced, or the items/questions are changed, then all the reviews that have been done need to be redone. The system should then email the previously done reviews to the reviewer and delete the response object and all associated answer objects. (However, the response_map should not be changed.)


This project was done in Fall 2019. However, it was not tested thoroughly. Our team's work in Spring 2021 is to improve the testing and readability of the code.

Design Diagrams

Use Case Diagrams

*Using UML Use Case Diagram Syntax

Data Flow Diagrams

Note: This data flow diagram was originally made by the team from project E1982 in Fall 2019. Their wiki link can be viewed here:

https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1982._Regulate_changing_of_rubrics_while_projects_are_in_progress

Proposed Solution

We will write comprehensive tests and fix any bugs in the code written already for changing rubrics while projects are in progress.

Some known issues already have been identified:

  • Additions:
    • A method comment is needed on in_active_period method in answer_helper.rb
    • Line-by-line comments are needed for all added functions
  • Refactoring:
    • The method find_review_period is possibly redundant as Find deadlines does exist already in the code. This method needs to be replaced/removed if possible
    • Split delete_existing_responses into more functions as it's complexity is reletively high
      • Contains some nested loops so these should be removed
  • Testing:
    • Email functionality needs to be thoroughly tested
    • Tests need to be more thorough and verify that correct rows are being deleted for delete_existing_responses function in answer_helper.rb
    • Confirm changes do not affect students who have not yet submitted their reviews by doing UI testing

Completed Solution

  • Additions:
    • Added more extensive comments to all added functions and lines of code for better readability
    • Added a popup confirmation message when deleting a question during active period similar to when adding a question to ensure instructor wants to delete all responses
    • Destroy response object instead of individual answers when editing a questionnaire during active period to return all students who submitted reviews to the 'begin' stage rather than 'edit' and give them a fresh questionnaire
  • Refactoring:
    • Split complicated functions from previous team, such as delete_existing_responses(), into more manageable and modular functions which only complete 1 main task
    • Fixed email formatting for email sent to users when questionnaire is edited
    • find_review_period() now uses find_due_dates() to search for assignment due dates. Reduced number of database calls in find_review_period() to reduce interaction, number of iterating loops, and incorporate DRY principles
    • answer data in log_response_info() now uses hash format for better readability
    • Local array and hash variables now instantiated correctly.
  • Testing:
    • Improved rspec tests for all files
    • Confirmed that changes do not affect students that have not yet submitted their reviews

Flow

The main actions this project affects are adding and removing questions from a questionnaire. These diagrams will show how these events now occur. Because these events are handled differently in Expertiza, the implementation is slightly different for both cases.

*Note: As you can see in the diagrams below, the confirmation popup is thrown in different ways for "Add" vs "Remove". This is because in _questionnaire.html.erb:

"Add" is implemented as a submit_tag which can easily have a confirm: attribute added to it causing it to throw a popup within expertiza.

"Remove" is an <a> tag hyperlink rendered to the page by line <%=question.edit(i)%> which iterates through all questions in the questionnaire and renders their edit() functions. Edit() is a function in each question types model (criterion.rb, cake.rb, etc.). Edit() adds lines to the html for each field in the question table, including the "Remove" link. The "Remove" hyperlink has an href attribute which dynamically links to /questions/ + self.id.to_s based on the desired questions id. It then uses a data-method="delete" attribute to select the destroy method in questions_controller.rb. Because this hyperlink exists in each question types model, it is hard to implement a clean solution which does not edit all the model files. To do this, we added a short <script> to the end of _questionnaire.html.erb which scans for <a> hyperlink redirects with the [data-method="delete"] attribute and throws a popup within the browser rather than expertiza. This popup works the same as the "Add" popup. The script returns the result (true/false) of this popup to the <a> tag. In html, the redirect is cancelled if a false is returned to the tag and continues if a true is returned.

Adding question during active period Removing question during active period

Documentation

Here is a list of files and the functions that were added or edited, excluding rspec files.

app/helpers/answer_helper.rb

Helper module containing important functions for deletion of responses and answers when editing a questionnaire during review period.

  • delete_existing_responses(question_ids, questionnaire_id)

Calls log_answer_responses and log_answer_info to store responses users made to the questionnaire. If review_mailer can mail these responses to the user then delete_answers destroys the response object.

  • log_answer_responses(question_ids, questionnaire_id)

Given a list of question_ids and a questionnaire_id, gathers reponse_ids for all users responses to the questionnaire.

  • log_response_info(response_ids)

Given a list of response_ids, gathers users responses to a questionnaire and records their comments in a hash along with their name, email, and the assignment name.

NOTE: The only issue we have found on this project stems from the way this function gets answers. Sometimes these review comments are sent to users in an email, and sometimes they are not. Our issue here [1] explains it in more detail.

  • review_mailer(email, answers, name, assignment_name)

Given an email, answer list, name, and assignment name, calls notify_review_rubric_change() to send given information about previous review submission to user at given email.

  • delete_answers(response_id)

Given a response_id, set the response to be no longer submitted then destroy the response object. This destroys designated dependencies as well such as answers.

  • in_active_period(questionnaire_id, answer=nil)

Given a questionnaire and possibly an answer, determine the assignment and round number. Use these to determine if the assignment is in a review period. Return true if in active period, false if not.


app/controllers/questionnaires_controller.rb

  • add_new_questions

Added call to in_active_period. If in active period, call delete_existing_responses(). If not, continue as normal.


app/controllers/questions_controller.rb

  • destroy

Added call to in_active_period. If in active period, call delete_existing_responses(). If not, continue as normal.


app/mailers/mailer.rb

  • notify_review_rubric_change(defn)

Mailer function which set necessary attributes for sending an email about a deleted response including previous answers. Calls mail() to send email to desired user.


app/models/assignment.rb

  • find_review_period(round)

Determines the start and end dates of the rounds of an assignment and returns them. Using previous teams code as a base, we changed this function to make minimal database calls and iterate fewer times.


app/models/assignment_questionnaire.rb

  • get_latest_assignment(questionnaire_id)

Given questionnaire_id, returns assignment and round where questionnaire is used (if multiple questionnaires are used in an assignment)


app/views/questionnaires/_questionnaire.html.erb

  • Added in_active_period() call to display warning about edited questionnaire during active period
  • Added confirm: to submit_tag 'Add' to display confirmation popup when adding a question during active period
  • Added script to catch <a> tag redirects with [data-method="delete"] to display popup when removing a question. Script only active if in active period.

app/views/mailer/notify_review_rubric_change.html.erb

File:2110 img4.png

  • New file containing email layout used when emailing students their answers after questionnaire is edited during active period.

Changed Files

  • Added:
    • app/helpers/answer_helper.rb
    • app/views/mailer/notify_review_rubric_change.html.erb
  • Edited:
    • app/controllers/questionnaires_controller.rb
    • app/controllers/questions_controller.rb
    • app/mailers/mailer.rb
    • app/models/assignment.rb
    • app/models/assignment_questionnaire.rb
    • app/views/questionnaires/_questionnaire.html.erb
  • Test Case Files
    • spec/controllers/questionnaires_controller_spec.rb
    • spec/models/assignment_spec.rb
    • spec/controllers/questions_controller_spec.rb
    • spec/helpers/answer_helper_spec.rb

Test Plan

Tests are created in the following files:

  • spec/controllers/questionnaires_controller_spec.rb
  • spec/models/assignment_spec.rb
  • spec/controllers/questions_controller_spec.rb
  • spec/helpers/answer_helper_spec.rb

These tests cover the following cases:

  • Adding questions to a questionnaire during the review period
  • Adding questions to a questionnaire outside the review period
  • Determining if an assignment is in the review period
  • Determining if an assignment is outside the review period
  • Finding the start and end dates for a specific review period of an assignment
  • Finding the start and end dates for all review periods of an assignment
  • Deleting existing responses resulting from changes made to questionnaires during the review period
  • Deleting questions

The same cases were also tested manually through the Expertiza UI, as shown in the demo video.

Team Links

Here is the video our team recorded to show functionality: [2]

The link to our team's repository: [3]

The link to the Expertiza pull request for our project: [4]