User:Mxu: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(One intermediate revision by one other user not shown)
Line 26: Line 26:
An instructor chooses to create an assignment that has a quiz [S1]. While editing the assignment they may choose the number of quiz questions [S2] and set which phases students are allowed to take the quizzes [S3].
An instructor chooses to create an assignment that has a quiz [S1]. While editing the assignment they may choose the number of quiz questions [S2] and set which phases students are allowed to take the quizzes [S3].


* [S1] - When creating the quiz there is a checkbox labeled "has quiz." Checking this box creates an assignment that includes a quiz.
* [S1] - When creating the assignment there is a checkbox labeled "has quiz." Checking this box creates an assignment that includes a quiz.
* [S2] - When an assignment has a quiz there is an input field that accepts the number of questions that will be on each quiz. Setting this number appropriately changes the number of quiz questions.
* [S2] - When an assignment has a quiz there is an input field that accepts the number of questions that will be on each quiz. Setting this number appropriately changes the number of quiz questions.
* [S3] - Students may not take quizzes on a phase that does not allow them to do so. When on a stage that does allow for quizzes, they may take quizzes on work that they have reviewed.
* [S3] - Students may not take quizzes on a phase that does not allow them to do so. When on a stage that does allow for quizzes, they may take quizzes on work that they have reviewed.
Line 34: Line 34:


* [S1] - The instructor may navigate to the list of assignments. Assignments with quizzes enabled will provide a link for the instructor to follow and view student quizzes.
* [S1] - The instructor may navigate to the list of assignments. Assignments with quizzes enabled will provide a link for the instructor to follow and view student quizzes.
* [S2] - The quiz title and questions are to be presented in a clear manner. The correct answer choices should be easily determined.
* [S2] - The instructor shall be presented with the quiz title, questions, and answer choices. The correct answer choices will be in bold.
* [S3] - The score for each student who has taken the quiz shall be listed along with the average quiz score.
* [S3] - The score for each student who has taken the quiz shall be listed along with the average quiz score.



Latest revision as of 01:38, 16 April 2016

CSC/ECE 517 Spring 2016 E1621: Refactor and test the quizzing feature

Introduction to Expertiza

Expertiza<ref>https://github.com/expertiza/expertiza</ref> is a project developed using Ruby on Rails<ref>http://guides.rubyonrails.org/getting_started.html</ref>. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from GitHub. This application provides an efficient way to manage assignments, grades and reviews.

Problem Statement

The Expertiza quiz feature is in need of refactoring. Currently, quizzes are checked by questionnaires_controller.valid_quiz. This method is rather long, involved, and does not take advantage of object-oriented practices. It combs through the parameters hash received from a request and manually checks all quiz fields, all question fields, all question choice fields, and verifies that each question has a correct choice.

We will refactor the method to construct a quiz questionniare and then call valid? to recursively validate the object tree using ActiveRecord validations. This is an improvement over the current code which checks all questions manually. The purpose of refactoring in this manner is to enhance readability, DRYness, and maintainability of Expertiza code.

In addition to this refactoring we will implement integration testing on the quiz feature to verify that the expected behavior is present for all use cases.

A full description of the assignment may be found here

Classes involved

  • questionnaires_controller.rb
  • quiz_quesetionnaire.rb
  • quiz_question.rb
  • quiz_question_choice.rb
  • spec/features/quiz_spec.rb

Use Case and Scenarios

The Quiz Use Case allows for instructors to create and manage assignments where students may write quizzes for reviewers on materials they have submitted. See the following scenarios for a complete description of how the feature is expected to work.

Instructors are able to create and manage an assignment's quiz feature

An instructor chooses to create an assignment that has a quiz [S1]. While editing the assignment they may choose the number of quiz questions [S2] and set which phases students are allowed to take the quizzes [S3].

  • [S1] - When creating the assignment there is a checkbox labeled "has quiz." Checking this box creates an assignment that includes a quiz.
  • [S2] - When an assignment has a quiz there is an input field that accepts the number of questions that will be on each quiz. Setting this number appropriately changes the number of quiz questions.
  • [S3] - Students may not take quizzes on a phase that does not allow them to do so. When on a stage that does allow for quizzes, they may take quizzes on work that they have reviewed.

Instructors can view quiz questions and scores from the tree view

After an assignment has been created the instructor may choose to view student quizzes from the tree view [S1]. While on the quiz view page they see student quizzes [S2] and student responses [S3].

  • [S1] - The instructor may navigate to the list of assignments. Assignments with quizzes enabled will provide a link for the instructor to follow and view student quizzes.
  • [S2] - The instructor shall be presented with the quiz title, questions, and answer choices. The correct answer choices will be in bold.
  • [S3] - The score for each student who has taken the quiz shall be listed along with the average quiz score.

Students can create and edit quizzes

A student navigates to the assignment work page and chooses to create a new quiz [S1] or edit an existing one [S2]. By doing so they are able to choose a quiz title and quiz questions [S3]. Invalid input results in an error message prompting the student to fix the issue [E1].

  • [S1] - A student may only create a quiz if they have not yet done so.
  • [S2] - A student may only edit a quiz if they have previously created one.
  • [S3] - The quiz has the number of quiz questions defined by the instructor in the assignment.
  • [E1] - Possible errors include:
    • The quiz has no name.
    • One or more questions is missing text.
    • One or more choices is missing text.
    • A question is missing a correct answer choice.

Students can take quizzes on assignments they have reviewed

A student decides to take a quiz [S1] on another team's assignment that they have previously reviewed. They select an artifact for review [S2] and fill in their answers. After submitting the quiz they can view their score on the take quizzes page [S3] and see question-by-question scores by clicking view [S4].

  • [S1] - The student may only take a quiz during a stage in which the assignment is configured to allow them to do so.
  • [S2] - Only quizzes from submissions they have reviewed are available.
  • [S3] - The take quizzes page lists the final score for each quiz.
  • [S4] - Choosing to view a quiz will show a student each question along with their answers and the correct answers.

Design and Implementation

Design for the refactoring has been driven by object oriented principles and test-driven-development, and makes use of the existing object hierarchy described in the following UML diagram.

Expertiza Quiz Hierarchy

See the below sections for a part-by-part breakdown of the planned implementation for this project.

Tests

Quiz tests will be added to the file spec/features/quiz_spec.rb and will make use of

  • rspec
  • capybara
  • selenium

Tests will be made which fully cover the expected behavior of each listed scenario in the Use Case.

Refactoring

Each of the following files will be refactored as described.

QuestionnaireController

Refactor the valid_quiz method. It will be renamed to validate_quiz to more properly describe the action that occurs as a result of it being called. The behavior will be changed to construct a new quiz questionnaire with submitted questions wich will be validated using quiz.valid?.

QuizQuestionnaire

The following fields will be validated using ActiveRecord validations.

  • Presence of name

QuizQuestion

The following fields will be validated using ActiveRecord validations

  • Presence of text
  • Presence of type
  • Has a correct answer

QuizQuestionChoice

The following fields will be validated using ActiveRecord validations

  • Presence of text

Test Cases

In order to verify that refactoring has been done correctly and maintains the same external behavior, we will write test cases to the existing implementation. These test cases will be the ground truth of the validation feature. Refactored code will not be considered complete until all of these test cases once again pass.

References

<references/>