CSC/ECE 517 Spring 2021 - E2102. Refactor quiz questionnaires controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 48: Line 48:


== Test Plan ==
== Test Plan ==
'''Note: Our project is a refactoring of existing controller code. It cleaned up the controller and therefore does not really have anything to test besides if the app is still working.'''
Steps:
1) Visit our hosted website (until the end of April 2021) at http://152.7.99.72:8080/
2) Login with the username ''instructor6'' and password ''password''
3) Click assignments at the top
4) For "773HimesMakthalTest" click the edit pencil icon
5) Note that Has Quiz? is enabled and it has due dates and is assigned to student7366
6) At the top, go to Manage > Impersonate User > student7366
7) Under assignments, click the 773HimesMakthalTest assignment
8) Click "Your work" > Click "Create a quiz" if no quiz has been made yet
9) You can fill in the new quiz or edit an existing one. Also you can view the quiz.
Again, this all worked before we made any changes. Our project was just refactoring.

Revision as of 22:00, 23 March 2021

Members

  • Nicholas Himes
  • Surya Makthal

Introduction

In order for students to write effective reviews, they need to understand the work that they are reviewing. Expertiza can allow authors to create a quiz over their work. If an assignment is set up to use quizzes, then a reviewer must take the quiz over the author’s work before reviewing it. Then, based on how the reviewer scores on that quiz, Expertiza can weight that author’s scores accordingly in calculating a peer grade. Thus, reviewers who understand the author’s work better have more say in determining the author’s (peer) grade.

Problem Statement

quiz_questionnaires_controller, naturally, is the controller that administers a quiz. A quiz_questionnaire is a kind (subclass) of questionnaire in Expertiza. A questionnaire consists of a number of questions (or “items”) that the reviewer needs to answer. This questionnaire contains many violations of good programming practices. E2102 deals with refactoring the code inside quiz_questionnaires_controller.rb so that it is clear and conforms to DRY principles.

Issues

Issues and their progress/comments can be viewed in more detail on our repository project board [1].

  • action_allowed? needs to be refactored to use authorization utilities (see project E1915 on the Expertiza wiki)
  • Lines 23-24 contain useless comments; remove.
  • Line 26 needs a comment saying what a valid request is.
  • Line 26: if !assignment.require_quiz? ⇒ unless assignment.require_quiz?
  • Line 31: Change message to, “This assignment is not configured to use quizzes.”
  • Line 34: team_check is an unacceptable method name; the method name needs to say what the method does. Also the comment at the end of the line is useless; replace it by one that says what is going on.
  • Line 50: Why isn’t if valid.eql?("valid") simply if valid?

There also needs to be a comment saying what “valid” means in this context.

  • Comment at line 52 is confusing.
  • Line 55 needs a comment saying what it is doing.
  • Line 78: Your quiz has been taken by some other students, you cannot edit it anymore ⇒ Your quiz has been taken by other students; you cannot edit it anymore
  • create and update need to share code. Looks like create is missing some functionality present in update.
  • Line 100: What about other question types, e.g., Criterion? Or are these not permitted in quizzes? If so, what stops them from being used?

I’m not clear on what a “choice” is; please explain.

  • Line 133: Seems like this should be a method of assignment_participant; then the participant_id can be the receiver.

Suggested name: has_team_and_topic

  • Line 146: Need an explanation (comment) about what a valid question is.
  • Lines 165 ff.: Why are the update methods before the create methods?

Comment on Line 159 should say, # update checkbox question But, “question” should be replaced with “item” throughout. Why is code so different between update & create methods? Should this code be moved to the model files for the appropriate question types?

  • Line 244?: I think it would be good to flash a message before deleting a question.
  • Line 255: Not clear what a “choice type” is.
  • Lines 264 to 272: Big if-statement checks types & creates correct type of question. This should be changed to use the Factory Method pattern, shared by code for creating rubric items and code for creating quiz questions.


Test Plan

Note: Our project is a refactoring of existing controller code. It cleaned up the controller and therefore does not really have anything to test besides if the app is still working.

Steps:

1) Visit our hosted website (until the end of April 2021) at http://152.7.99.72:8080/ 2) Login with the username instructor6 and password password 3) Click assignments at the top 4) For "773HimesMakthalTest" click the edit pencil icon 5) Note that Has Quiz? is enabled and it has due dates and is assigned to student7366 6) At the top, go to Manage > Impersonate User > student7366 7) Under assignments, click the 773HimesMakthalTest assignment 8) Click "Your work" > Click "Create a quiz" if no quiz has been made yet 9) You can fill in the new quiz or edit an existing one. Also you can view the quiz.

Again, this all worked before we made any changes. Our project was just refactoring.