User:Mxu
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. We will refactor the method to construct a quiz question object and then call valid? to check if the question is valid. This is an improvement over the current code which checks all questions manually.
In addition to this refactoring we will implement integration testing on the quiz feature to verify that the correct behavior is present.
A full description of the assignment may be found here
Classes involved
- questionnaires_controller.rb
- spec/features/quiz_spec.rb
What it does
The purpose of this assignment is to enhance readability, DRYness, and maintainability of Expertiza code through refactoring and functional testing.
What is wrong with it
The valid_quiz method in questionnaires_controller needs to be refactored. This method should not check the questions one by one, instead, it should create the quiz_question objects and quiz_choice objects, then call “quiz_question.valid?” to check whether the question is valid.
What needs to be done
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, you need to do refactoring and create functional tests for this feature:
- Refactoring:
- Refactor the valid_quiz method in questionnaires_controller. This method should not check the questions one by one, instead, it should create the quiz_question objects and quiz_choice objects, then call “quiz_question.valid?” to check whether the question is valid.
- Testing:
- The instructor can set up an assignment which supports quizzing feature by
- Checking the “has quiz” box
- Setting the # of question for each set of quiz
- Setting in which deadline can student reviewers take the quizzes
- Student authors can create quizzes and edit them:
- They can create quizzes on the “Your work” page
- They can edit the quiz questions.
- They can view the quiz questions.
- If the quiz question has something missing, the system will flash an error message, either:
- The name of quiz is missing.
- The question text is missing for one or more questions.
- The choices are missing for one or more questions.
- The correct answer(s) have not been provided.
- Student reviewers can take the quizzes on the work they have reviewed/they need to review
- They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.
- They can click “take quiz” then request quizzes to take.
- They can fill in their choices on the quizzes.
- After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page
- On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”
- Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.
- The instructor can set up an assignment which supports quizzing feature by
Scope
This project can be divided into major work items:
- Instructors is able to create and manage an assignment's quiz feature.
- Instructors can view quiz questions and scores from the tree view.
- Students can create quizzes and edit them.
- Students can take quizzes on assignments they have reviewed.
- Refactor questionnaires_controller#valid_quiz
Implementation
Quiz test will be added to spec/features/quiz_spec.rb and will make use of
- rspec
- capybara
- selenium
Additionally, refactoring on questionnaires_controller may include the creation of the valid? method in app/models/quiz_question.rb.
Design
Design for the refactoring will be driven by object oriented principles and test-driven-development.
QuizQuestion
Implement a validate
method that validates a quiz question for correctness including
- Has text
- Has type
- Has all options
- Has a correct answer
- If radio only one correct answer
- If checkbox at least one correct anser
QuizQuestionnaire
Implement a validate>
method that validate a quiz and all of its questions for correctness including
- Has name
QuestionnaireController
Refactor the valid_quiz
method to construct a new quiz object with submitted questions. This quiz object will be validated using quiz.validate
.
Test Cases
Implement unit test cases for each of the methods listed above.
References
<references/>