CSC/CSC 517 Fall 2016/oss E1667

From Expertiza_Wiki
Jump to navigation Jump to search

Template:Student sandbox

About Expertiza

Expertiza is an open source application developed on the Ruby on Rails framework. It allows instructors to create assignments, set deadlines and give grades to the assignments. In this application, students can submit their assignments by providing links to their sites or repositories or upload files and folders. The students can also review assignments submitted by their peers.

Problem Statement

Goal: The aim of the project was to write a feature test that mocks the Heat Map that a student views for an assignment of his. The following tasks were performed to accomplish the goal:

  1. Understanding the flow of the creation of Assignment by instructor.
  2. Understanding the flow of the submission of an assignment by a student and then the flow of submitting reviews to an assignment uploaded by a student.
  3. Understanding the flow of viewing the Heat Map related to an assignment by a student.
  4. Mock the above steps using capybara.

Project Links

Instructions for Reviewer

Clone the reopsitory

     git clone (repository URL)

Repository URL can be found by visiting this Github repo.

Installing Gems (ruby dependencies)

Go to your cloned expertiza directory in terminal and run the following command:

    bundle install

Setting up the databses

  • Run the Expertiza database migrations. This should populate your database with the current tables of the schema.
  rake db:migrate

Running the tests

  • Go to your cloned expertiza directory and run the following command for the tests:
   rspec spec/features/heat_map_spec.rb

Note : Travis CI build fails because we are directly using the development database for our tests, thus Travis CI is not able to locate the login information. This was done because it was not possible to create factories or fixtures for our tests. So, please don’t consider the build failure in the pull request to be a valid error.

Classes Involved

The heat_map_spce.rb contains the feature tests written to test the creation of the heat map viewed by the user. The rails_helper is copied to spec/ when you run 'rails generate rspec:install'. All the rspec-expectations config goes into the spec_helper_file. The testing has been done using Capybara and RSpec. Capybara helps in testing web applications by simulating how a real user would interact with the application. We selected Capybara to write our tests because it has an intuitive API which can mimic the language that an actual user uses while using the application and also we the tests can be run from a fast headless mode to an actual browser without changing our tests.

Flow of our test

Code

heat_map_spec.rb

require 'rails_helper'
describe "HeatMapTest", type: :feature do
 before(:each) do
   create(:assignment, name: "TestAssignment", directory_path: 'test_assignment')
   create_list(:participant, 3)
   create(:assignment_node)
   create(:deadline_type, name: "submission")
   create(:deadline_type, name: "review")
   create(:deadline_type, name: "metareview")
   create(:deadline_type, name: "drop_topic")
   create(:deadline_type, name: "signup")
   create(:deadline_type, name: "team_formation")
   create(:deadline_right)
   create(:deadline_right, name: 'Late')
   create(:deadline_right, name: 'OK')
   create(:assignment_due_date, deadline_type: DeadlineType.where(name: 'review').first, due_at: Time.now + (100 * 24 * 60 * 60))
   create(:topic)
   create(:topic, topic_name: "TestReview")
   create(:team_user, user: User.where(role_id: 2).first)
   create(:team_user, user: User.where(role_id: 2).second)
   create(:assignment_team)
   create(:team_user, user: User.where(role_id: 2).third, team: AssignmentTeam.second)
   create(:signed_up_team)
   create(:signed_up_team, team_id: 2, topic: SignUpTopic.second)
   create(:assignment_questionnaire)
   create(:question)
   #create(:review_response_map, reviewer_id: User.where(role_id: 2).third.id)
   #create(:review_response_map, reviewer_id: User.where(role_id: 2).second.id, reviewee: AssignmentTeam.second)
   #create(:response, additional_comment:'Round 1 - Good job', round:1)
   #create(:response, additional_comment:'Round 2 - not so good job', round:2)
   #sleep(100)
 end
 def createReviews
   user = User.find_by_name("student2066")
   stub_current_user(user, user.role.name, user.role)
   visit '/student_task/list'
   expect(page).to have_content "User: student2066"
   expect(page).to have_content "TestAssignment"
   click_link "TestAssignment"
   expect(page).to have_content "Submit or Review work for TestAssignment"
   click_link('Your work')
   expect(page).to have_content "Submit work"
   fill_in "submission", with: "https://www.idonothing.com"
   expect(page).to have_content "Submit work"
   click_button('Upload link')
   user = User.find_by_name("student2065")
   stub_current_user(user, user.role.name, user.role)
   visit '/student_task/list'
   expect(page).to have_content "User: student2065"
   expect(page).to have_content "TestAssignment"
   click_link "TestAssignment"
   expect(page).to have_content "Submit or Review work for TestAssignment"
   expect(page).to have_content "Others' work"
   click_link "Others' work"
   expect(page).to have_content 'Reviews for "TestAssignment"'
   choose "topic_id"
   click_button "Request a new submission to review"
   click_link "Begin"
   fill_in "responses[0][comment]", with: "HelloWorld"
   select 5, from: "responses[0][score]"
   fill_in "review[comments]", with: "Excellent work done!"
   click_button "Submit Review"
   expect(page).to have_content 'Your response was successfully saved.'
   user = User.find_by_name("student2064")
   stub_current_user(user, user.role.name, user.role)
   visit '/student_task/list'
   expect(page).to have_content "User: student2064"
   expect(page).to have_content "TestAssignment"
   click_link "TestAssignment"
   expect(page).to have_content "Submit or Review work for TestAssignment"
   expect(page).to have_content "Others' work"
   click_link "Others' work"
   expect(page).to have_content 'Reviews for "TestAssignment"'
   choose "topic_id"
   click_button "Request a new submission to review"
   click_link "Begin"
   fill_in "responses[0][comment]", with: "HelloWorld"
   select 5, from: "responses[0][score]"
   fill_in "review[comments]", with: "Excellent work done!"
   click_button "Submit Review"
   expect(page).to have_content 'Your response was successfully saved.'
 end
 def load_questionnaire
   user = User.find_by_name("student2066")
   stub_current_user(user, user.role.name, user.role)
   visit '/student_task/list'
   expect(page).to have_content "User: student2066"
   expect(page).to have_content "TestAssignment"
   click_link "TestAssignment"
   expect(page).to have_content "Submit or Review work for TestAssignment"
   expect(page).to have_content "Others' work"
   click_link "Alternate View"
 end
 xit "Loads Heat Map page" do
   load_questionnaire
   expect(page).to have_content "Summary Report for assignment"
 end
 it "See submitted review in the page" do
   createReviews
   load_questionnaire
   expect(page).to have_content "Review 1"
 end
end


Issues

We faced the following issues and hence were not able to complete the project:

  1. We could not find any documentation about how to use the factory related to our task and couldn’t figure out its implementation in other tests.
  2. We tried to solve the problem by using previously implemented test but were unsuccessful.
  3. So we (Mahesh Masale) contacted you and you provided us with a new approach for the problem. What we were asked to do was to write a test that would simulate everything from scratch. There were multiple points where we struggled in this approach but the major ones were:
    1. While adding questions to rubric the question field’s id is auto generated so there is no way to assume an id for that field in test. We overcame this problem by searching a specific text to find the all text fields but this will be a problem if that test is present at a location other than the test field.
    2. While trying to select a rubric which is a dropdown there was no id provided to the select tag. So we googled but to no success and then we found a piece of code in the assignment_creatiion_spec.rb but that code also failed in our solution.
    3. We also tried to add a participant to an existing assignment through test and struggled with it because the id to the button was dynamically generated and the url could not be accessed through “visit” command.
  4. So we switched back to the old method due to lack of progress after investing a lot of time. We used the factory and were able to create assignments and reviews but our user was not able to view those reviews in heat map. We even tried previously implemented code but that also did not show reviews for our test.
  5. We communicated with other teams for help but they also could not solve our issues.