CSC/ECE 517 Fall 2017/E1754 Feature test of rubric advice

From Expertiza_Wiki
Revision as of 23:55, 27 October 2017 by Ryshukla (talk | contribs)
Jump to navigation Jump to search

Introduction

Expertiza is a web application which provides a dashboard to the students where they can submit and peer-review assignments, projects, codes, and other such objects. It allows students to review each other’s work and improve their work upon this feedback. Rubric advice allows reviewers to see what characteristics of work merit a particular score.


The problem statement

Rubric advice lets a user see what criterion or characteristics of work merit a particular score. An instructor can retrieve peer review assignments and leave some advice or give scores based on some criteria. Similarly, students can log in and retrieve the rubric advice left by the instructor. We mocked the behavior of the user (both as an instructor and student) to see how different scenarios work, like modifying, saving and retrieving advice and building feature tests for it. The testing frameworks used for the same were Selenium and Capybara.


Tasks identified

Student Side: A student, when filling a peer review should be able to see the rubric advice associated with a particular test score. We test this task through adding a test case in the peer_review_spec.rb since Peer Review is superset of the Rubric Advice feature as it is a task where a student uses the rubric advice and submit it.

Files changed: peer_review_spec.rb The test case checks if student is able to select a rubric advice that the instructor has created and then submit it.

  it "able to view and use rubric advice", :js => true do
    load_questionnaire
    expect(page).to have_content "Show advice"
    page.find('#showAdivce_1').click
    expect(page).to have_content "5 - Good"
    page.find("a", :text => "5 - Good").click
    click_button "Save Review"
    expect(page).to have_content "Your response was successfully saved."
  end

The existing code given creates the required environment for the test student. It sets up a team, assignment and other required elements for the test student to submit a review.

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.in_time_zone + 1.day)
    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(:question_advices)
   end

The rubric advice is prepared in factory.rb with the following code addition . This allows our test Student to get a ready rubric advice that he can choose.

  factory :question_advices, class: QuestionAdvice do
    question_id 1
    score 5
    advice "Good work"
  end


Instructor side:

Edit a certain review rubric, and add advice to it. Test that when advice is added for a particular criterion, the advice can be retrieved and that it is exactly the advice that was added. Files added: review_rubric_spec.rb

describe "Edit a rubric advice" do
    it "is able to edit a review rubric advice" do
      # creating a new rubric advice
      load_question 'Criterion'
      click_button "Edit/View advice"
      expect(page).to have_content('Edit an existing questionnaire')
      # setting intital advice in the field
      first(:css, "textarea[id^='horizontal_'][id$='advice']").set("Initial advice")
      click_button "Save and redisplay advice"
      expect(page).to have_content('advice was successfully saved')
      expect(page).to have_content('Initial advice')
      # editing a review rubric - Setting any element with new data
      first(:css, "textarea[id^='horizontal_'][id$='advice']").set("Edited the advice")
      click_button "Save and redisplay advice"
      expect(page).to have_content('advice was successfully saved')
      expect(page).to have_content('Edited the advice')
    end
  end

  describe "Remove a rubric advice" do
    it "should be able to delete a rubric advice" do
      load_question 'Criterion'
      click_button "Edit/View advice"
      expect(page).to have_content('Edit an existing questionnaire')
      first(:css, "textarea[id^='horizontal_'][id$='advice']").set("Initial advice")
      click_button "Save and redisplay advice"
      expect(page).to have_content('advice was successfully saved')
      expect(page).to have_content('Initial advice')
      # edit review advice to set to blank i.e. delete rubric advice
      first(:css, "textarea[id^='horizontal_'][id$='advice']").set("")
      click_button "Save and redisplay advice"
      expect(page).to have_content('advice was successfully saved')
    end
  end
end

Apart from the major test case for Rubric advice, it is essential to test if the logged in instructor is an authorized instructor. To test this, we have added the following test in review_rubric_spec.rb. Also, the task of loading the questionnaire and the question types is implemented in separate methods to allow reuse.


include InstructorInterfaceHelperSpec

# Feature test of rubric advice
describe "Edit rubric advice" do
  before(:each) do
    assignment_setup
  end

  # Login test
  describe "Login as instructor" do
    it "logs in with valid username and password" do
      login_as("instructor6")
      visit '/tree_display/list'
      expect(page).to have_content("Manage content")
    end

    it "logs in with invalid username and password" do
      visit root_path
      fill_in 'login_name', with: 'instructor6'
      fill_in 'login_password', with: 'wrongpassword'
      click_button 'SIGN IN'
      expect(page).to have_text('Your username or password is incorrect.')
    end
  end

  def load_questionnaire
    login_as("instructor6")
    visit '/questionnaires/new?model=ReviewQuestionnaire&private=0'
    fill_in('questionnaire_name', with: 'DummyReview')
    fill_in('questionnaire_min_question_score', with: '0')
    fill_in('questionnaire_max_question_score', with: '5')
    select('no', from: 'questionnaire_private')
    click_button "Create"
  end

  def load_question question_type
    load_questionnaire
    fill_in('question_total_num', with: '1')
    select(question_type, from: 'question_type')
    click_button "Add"
  end

Factories.rb



Testing Instructions

References