E1867 allow reviewer to say review can be shown to class as an example: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== Introduction ==
== Introduction ==
=== Background ===
[http://expertiza.ncsu.edu/ Expertiza] is a web based open source peer reviewing tool developed and maintained by current and past students of [https://en.wikipedia.org/wiki/North_Carolina_State_University North Carolina State University]. Peer review is a great way for a student to learn how to approach a project and get ideas for their own projects. Currently, there is no way for a student to view another student's work, unless they are reviewing the other student's work.
[http://expertiza.ncsu.edu/ Expertiza] is a web based open source peer reviewing tool developed and maintained by current and past students of [https://en.wikipedia.org/wiki/North_Carolina_State_University North Carolina State University], Raleigh.  


== Problem Statement ==
The objective of this project is to:
# Add a feature to allow teams to publish their work for other students to see.
# Add a feature for a student to view sample submissions for a given assignment made available by other students:
## In the same assignment, available after deadline.
## In an old assignment, selected by the instructor from sample submissions made in an old assignment.
# Add a feature for instructor to select a previous assignment to show sample submissions for a new assignment.


Currently, when an '''instructor''' logs into Expertiza, he/she sees the following menu items across the top:
== Proposed Design ==
The proposed features will involve two kinds of users : Students and Instructors. 
Students will use the application to make their submissions public and view published reviews.


''Home Manage content  Survey Deployments  Assignments  Course Evaluation  Profile  Contact Us''
[[File:Application Flow Student.png]]


And, a student can see the following menu items across the top:
Instructors will use the application to make submissions from a previous assignment available as sample submissions for a current assignment. Only those submissions will be visible which were previously made public by the students.


''Home Assignments Pending Surveys Profile Contact Us''
[[Image:Application Flow Instructor.png]]


== Project Tasks ==
The tasks that need to be completed as part of this project can be listed as follows:
# Add checkbox against each assignment in student_tasks/list view to allow student to publish their work
# Add column make_public to table teams for storing user permission (published or not) for each project.
# Add controller for Sample submissions and implement corresponding methods.
# Add views for sample submissions
# Make changes to  page student_task/view which would have link to sample submissions for each project.
# Add drop down in assignments/edit/_general view.
# Add controller code for the drop down.
# Add column sample_assignment_id to table assignment.
# Add test scripts for all the functionality.


On the instructor’s “Manage content” menu, one of the options is “Assignments”.  Having “Assignments” appear in two places is potentially confusing.  “Manage content > Assignments” allows the instructor to edit and create assignments, whereas the “Assignments” menu (that both students and instructors) see allows the instructor to participate in assignments.
== Current status of Development ==
All tasks mentioned in Project tasks are completed.


Therefore, it makes sense to create a '''student view''' for instructors, which will enable them to see menu items that are only related to students. This will help resolve the confusion.
== Developed Code ==
 
1. Add checkbox against each assignment in student_tasks/list view to allow student to publish their work
=== Problem statement ===
Create a '''student view''' for instructors. When in '''student view''', an instructor must not be able to view ''"Manage content"'' and ''"Survey Deployments"'' menu items, and must be able to switch back to the '''instructor view''' (the default view that an instructor first sees when he/she logs in). When in '''instructor view''', an instructor must not be able to view the ''"Assignment"'' and ''"Course Evaluation"'' menu items.
 
== Implementation ==
=== expertiza/app/views/shared/_navigation.html.erb ===
This file is shared between all views and is responsible for rendering all the elements in the top-most part of the web page. (i.e Displaying the menu items, the logout button etc.)
 
In order to switch between '''instructor view''' and '''student view''', the following code was added. When the user is in '''instructor view''', there is a link named "Switch to Student View" to switch to '''student view''' and when the user is in '''student view''', 'here is a link named "Revert to Instructor View" to switch back to the '''instructor view'''.
<% if session[:user].role.instructor? %>
                  <% if session.key?(:student_view) %>
                      <%= link_to "Revert to Instructor View", {controller: "instructor", action: "revert_to_instructor_view"},
                                  method: :post, :style => "color: white" %>
                  <% else %>
                      <%= link_to "Switch to Student View", {controller: "instructor", action: "set_student_view"},
                                  method: :post, :style => "color: white" %>
                  <% end %>
              <% end %>
 
=== expertiza/app/views/menu_items/_suckerfish.html.erb ===
This file is responsible for rendering all menu items and their children (if any).
 
A condition was needed to check if the current menu item that is to be rendered is in the list of hidden menu items. The ''hidden_menu_items'' session variable holds the IDs of menu items that must not be rendered. This applies only when the type of user currently logged in is an instructor. Hence, the following condition was added.
<pre>
<pre>
display_item_condition = (session[:user].role.instructor?)?(session[:hidden_menu_items].include?item_id)?false:true:true
<% if !participant.team.nil? %>
    <td align=center>
        <input id="makeSubPublic" teamid="<%= participant.team.id %>" type="checkbox" onclick="publishConfirmation(this)" <% if participant.team.make_public %>checked<% end %>>
    </td>
<% end %>
</pre>
</pre>


=== expertiza/app/controllers/instructor_controller.rb ===
2. Add column make_public to table teams for storing user permission (published or not) for each project.
 
A new instructor_controller.rb file has been added. This controller currently contains the actions to switch to student view and revert back to instructor view.
<pre>
<pre>
class InstructorController < ApplicationController
class AddSampleAssignmentToAssignments < ActiveRecord::Migration
  # check to see if the current action is allowed
   def change
   def action_allowed?
     add_column :assignments, :sample_assignment_id, :integer, index: true
     # only an instructor is allowed to perform all the actions in
     add_foreign_key :assignments, :assignments, column: :sample_assignment_id
     # this controller
    return true if session[:user].role.instructor?
   end
   end
 
end
  # sets student_view in session object and redirects to
</pre>
  # student_task/list after updating hidden_menu_items
3. Add controller for Sample submissions and implement corresponding methods.
   def set_student_view
<pre>
     session[:student_view] = true
# To give permission for making a submission available to others
     MenuItemsHelper.update_hidden_menu_items_for_student_view(session)
   def make_public
     redirect_to controller: 'student_task', action: 'list'
     @team = Team.find(params[:id])
    @team.make_public = params[:status]
     @team.save
     respond_to do |format|
      format.html { head :no_content }
    end
   end
   end
  # destroys student_view in session object and redirects to
  # tree_display/list after updating hidden_menu_items
  def revert_to_instructor_view
    session.delete(:student_view)
    MenuItemsHelper.update_hidden_menu_items_for_instructor_view(session)
    redirect_to controller: 'tree_display', action: 'list'
  end
end
</pre>
</pre>
4. Add views for sample submissions
<pre>
<!-- View to display sample submissions to the student -->
<h2>Sample Submissions for <%= @assignment.name%>:</h2>
<br>
<!-- Displaying sample submissions by students of the current course -->
<h3>Submissions made public by peers:</h3>
<% if @assignment_due_date==nil or @assignment_due_date>Time.new() %>
    <br><i>Will be available once the assignment submission is completed</i>
<% elsif @assignment_teams==[] %>
    <br><i>No sample submissions from current assignment made public yet</i>
<% else %>
    <ul>
      <% @assignment_teams.each do |assignment_team| %>
          <% if assignment_team.hyperlinks != [] %>
              <li>
                <ul>
                  <h4>Team name : <%=assignment_team.name%></h4>
                  <% assignment_team.hyperlinks.each do |assignment_link| %>
                      <li><a href="<%=assignment_link%>"><%=assignment_link%></a></li>
                  <%end%>
                </ul>
              </li>
          <%end%>
      <% end%>
    </ul>
<% end %>
<br>
<hr/>
<br>


=== expertiza/app/helpers/menu_items_helper.rb ===
<!-- Displaying sample submissions from a previous assignment chosen by the instructor -->
<h3>Submissions made public by instructor:</h3>
<% if @assignment_teams_professor == [] %>
    <br><i>No sample submissions from previous assignments made available yet</i>
<% else %>
    <ul>
      <% @assignment_teams_professor.each do |assignment_team| %>
          <% if assignment_team.hyperlinks != [] %>
              <ul>
                <li>
                  <h4>Team name : <%=assignment_team.name%></h4>
                  <% assignment_team.hyperlinks.each do |assignment_link| %>
                    <li><a href="<%=assignment_link%>"><%=assignment_link%></a></li>
                <%end%>
                </li>
              </ul>
          <%end%>
      <% end%>
    </ul>
<% end %>
<br><br>


This is a helper for deciding what menu items must be hidden.
<a href="javascript:window.history.back()">Back</a>
<br><br>The ''update_hidden_menu_items_for_student_view'' method is used to hide the ''Survey Deployments'' and ''Manage Instructor Content'' menu items. It does this by including the menu item IDs of these two menus in the ''hidden_menu_items'' session variable. (The ''hidden_menu_item'' variable will be used by <b>_suckerfish.html.erb</b> to decide whether or not to render a given menu item).
</pre>
<br><br>Similarly, the ''update_hidden_menu_items_for_instructor_view'' method is used to hide the ''Assignments'' and ''Course Evaluation'' menu items.  
5. Make changes to  page student_task/view which would have link to sample submissions for each project.
<br><br>The ''set_hidden_menu_items'' method is used to set check if the given user is an instructor. If it is, then the ''update_hidden_menu_items_for_instructor_view'' method is called. This method is used to ensure that only those items that must be visible to an instructor view are visible to an instructor when he logs in for the first time. The method has been designed in this way because, in the future, other menu items may need to be hidden based on the user type.
<pre>
<li>
  <%= link_to "Sample Submissions", controller: 'sample_submissions', :action => 'index', :id => @assignment.id %>
    (View sample work submitted by other participants/teams)
</li>
</pre>
6. Add drop down in assignments/edit/_general view.
<pre>
<!-- Adding sample submissions for students to refer to -->
  <tr>
    <td style='padding:5px'><%= label_tag('assignment_form[assignment][sample_assignment_id]', 'Sample Assignment:') %>
      <img src="/assets/info.png" title='- Select an assignment that students can refer sample submission from.'>
    </td>
    <td style='padding:5px'><%= select('assignment_form[assignment]', 'sample_assignment_id', sample_sub_options, :selected => @assignment_form.assignment.sample_assignment_id) %>
    </td>
  </tr>
</pre>
7. Add controller code for the drop down.
<pre>
<pre>
module MenuItemsHelper
  def sample_sub_options
  # sets hidden_menu_items for the given user if
    assignments = Assignment.all
  # user is an instructor. This method is needed to set
    options = []
  # the hidden_menu_items during initial login by instructor.
    assignments.each do |assignment|
  def self.set_hidden_menu_items(user, session)
      course_name = ""
    if user.role.instructor?
      if assignment.course_id and assignment.course_id != 0 and !Course.find(assignment.course_id).nil?
      MenuItemsHelper.update_hidden_menu_items_for_instructor_view(session)
        course_name = Course.find(assignment.course_id).name
    else
      end
       session[:hidden_menu_items] = []
       options << [course_name + '- ' + assignment.name, assignment.id]
     end
     end
    options.uniq.sort
    options.unshift(['-----------', nil])
  end
</pre>
8. Add column sample_assignment_id to table assignment.
<pre>
class AddSampleAssignmentToAssignments < ActiveRecord::Migration
  def change
    add_column :assignments, :sample_assignment_id, :integer, index: true
    add_foreign_key :assignments, :assignments, column: :sample_assignment_id
   end
   end
end
</pre>
9. Add test scripts for all the functionality.
<pre>
def create_assignment_team(assignment_name, parent_id)
  assignment_team = AssignmentTeam.new
  assignment_team.name = assignment_name
  assignment_team.parent_id = parent_id
  assignment_team.save!
end


   # updates hidden_menu_items in session object when an instructor is
def init_test
   # in student view
   # create assignment and topic
   def self.update_hidden_menu_items_for_student_view(session)
   assignment = build(Assignment)
    # 35 - Survey Deployments, 37 - Manage Instructor Content
  course = Course.new
    session[:hidden_menu_items] = [35, 37]
   course.name = "SampleSubmissionTestCourse"
   end
  course.save
  assignment.course_id = course.id
   assignment.save


   # updates hidden_menu_items in session object when an instructor is
   create_assignemnt_team("ss_assignment_team_1", assignment.id)
   # in instructor view
   create_assignemnt_team("ss_assignment_team_2", assignment.id)
  def self.update_hidden_menu_items_for_instructor_view(session)
    # 26 - Assignments, 30 - Course Evaluation
    session[:hidden_menu_items] = [26, 30]
  end
end
end
</pre>


=== expertiza/app/controllers/auth_controller.rb ===
def visit_sample_submissions_page
The ''after_login'' method in this controller sets up the session object after the user logs in, so it is a good candidate to include the initial set up of the ''hidden_menu_items'' session variable.
  visit '/student_task/list'
  click_on "Example Assignment"
  click_on "Sample Submissions"
end


The following lines were added to the ''after_login'' method. This call is intended to set the 'hidden_menu_items' variable in the session object when an instructor logs in for the first time. This is done so that the instructor is by default in Instructor View when he logs in. (i.e ''Assignments'' and ''Course Evaluation'' are hidden).
describe "sample submission test" do
<pre>
  before(:each) { init_test }
    # hide menu items based on type of user
    MenuItemsHelper.set_hidden_menu_items(user,session)
</pre>


The following lines were added to the ''clear_session'' method. These lines clear the ''student_view'' and ''hidden_menu_items'' session variables.
  it "is able to make an assignment public" do
<pre>
    visit '/student_task/list'
     session[:student_view] = nil
    find(:css, "#makeSubPublic[teamid='6050']").trigger("click")
    session[:hidden_menu_items] = nil
    click_button 'OK'
</pre>
     expect(page).to have_http_status(200)
  end


=== expertiza/config/routes.rb ===
  it "should not see current assignment submissions if deadline is not met" do # Set deadline after current time.
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from current assignment made public yet"
  end


New post methods are added in ''config/routes.rb''. The routes are directed to the instructor controller's ''set_student_view'' and ''revert_to_instructor_view'' actions.
  it "should see current assignment submissions if deadline is met" do # Set deadline before current time.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from current assignment made public yet"
  end


<pre>
   it "should not see instructor selected submissions if instructor has not selected them" do
   resources :instructor, only: [] do
     visit_sample_submissions_page
     collection do
     expect(page).to have_content "No sample submissions from previous assignment made available yet"
      post  :set_student_view
      post  :revert_to_instructor_view
     end
   end
   end


  it "should see instructor selected submissions if instructor has selected them" do # Instructor makes submission available.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from previous assignment made available yet"
  end
end
</pre>
</pre>


== Manual UI Testing ==
== Sample Submissions View ==


The user needs to log-in as an instructor to view this functionality.
1. The first screenshot of the application is taken when the deadline for the current assignment has not crossed and the instructor also has not given any sample assignment for this assignment.


1. Log into Expertiza as an instructor. Enter 'instructor6' as username and 'password' as password.
[[Image:Assignments not made public.PNG]]


2. Click on '''Switch to Student View''' below username to switch to student view.
2. The second screenshot of the application is taken when the deadline for the current assignment has not crossed but the instructor has selected a sample assignment for viewing against this assignment.


[[Image:Assignment submission date not passed.PNG]]


[[File:Student_View_1.PNG]]
3. The third screenshot of the application is taken when both the deadline for the current assignment has crossed and the instructor has selected a sample assignment for viewing.


[[Image:Assignments available.PNG]]


3. Click on '''Revert to Instructor View'''' below username to come back to instructor view.
== Test Plan ==


Many of our changes are reflected on views (user interface). So we build tests with rspec/capybara. Following is the list of tests that conduct:


[[File:Instructor_View_1.PNG]]
# it "is able to make an assignment public"
 
# it "is able to view sample submissions page"
== Automated Test Plan ==
# it "should not see current assignment submissions if deadline is not met"
1. '''Check whether ''Assignments'' and ''Course Evaluation'' are hidden when in instructor view.''' 
# it "should see current assignment submissions if deadline is met"
This test case is to check if the menu items ''Assignments'' and ''Course Evaluation'' are hidden when an instructor is in instructor view. The following lines can be added to a spec/features file:
# it "should not see instructor selected submissions if instructor has not selected them"
# it "should see instructor selected submissions if instructor has selected them"


<pre>
<pre>
it " can display relevant menu items after login as an admin/instructor/TA", js: true do
def create_assignment_team(assignment_name, parent_id)
    create(:instructor)
  assignment_team = AssignmentTeam.new
    login_as 'instructor6'
  assignment_team.name = assignment_name
    visit '/tree_display/list'
  assignment_team.parent_id = parent_id
    expect(page).to have_current_path('/tree_display/list')
  assignment_team.save!
    expect(page).to have_content('Manage content')
    expect(page).to have_content('Survey Deployments')
    expect(page).not_to have_content('Assignments')
    expect(page).not_to have_content('Course Evaluation')
end
end
</pre>


2. '''Check whether ''Manage content'' and ''Survey Deployments'' are hidden in student view.'''
def init_test
This test case is to check if the menu items ''Manage content'' and ''Survey Deployments'' are hidden when the instructor switches to student view. The following lines are to be added:
  # create assignment and topic
  assignment = build(Assignment)
  course = Course.new
  course.name = "SampleSubmissionTestCourse"
  course.save
  assignment.course_id = course.id
  assignment.save
 
  create_assignemnt_team("ss_assignment_team_1", assignment.id)
  create_assignemnt_team("ss_assignment_team_2", assignment.id)
end


<pre>
def visit_sample_submissions_page
it "can display relevant menu items when switching to student view", js: true do
  visit '/student_task/list'
    create(:instructor)
  click_on "Example Assignment"
    login_as 'instructor6'
  click_on "Sample Submissions"
    visit '/tree_display/list'
    click_link 'Swtich to Student View'
    expect(page).to have_current_path('/student_task/list')
    expect(page).to have_content('Assignments')
    expect(page).to have_content('Course Evaluation')
    expect(page).not_to have_content('Manage content')
    expect(page).not_to have_content('Survey Deployments')
end
end
</pre>


== External Links ==
describe "sample submission test" do
# Link to forked repository [[https://github.com/akshayravichandran/expertiza]]
  before(:each) { init_test }
 
  it "is able to make an assignment public" do
    visit '/student_task/list'
    find(:css, "#makeSubPublic[teamid='6050']").trigger("click")
    click_button 'OK'
    expect(page).to have_http_status(200)
  end
 
  it "should not see current assignment submissions if deadline is not met" do # Set deadline after current time.
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from current assignment made public yet"
  end
 
  it "should see current assignment submissions if deadline is met" do # Set deadline before current time.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from current assignment made public yet"
  end


==References==
  it "should not see instructor selected submissions if instructor has not selected them" do
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from previous assignment made available yet"
  end


Expertiza
  it "should see instructor selected submissions if instructor has selected them" do # Instructor makes submission available.
* https://expertiza.ncsu.edu/  
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from previous assignment made available yet"
  end
end
</pre>


Expertiza Github
== Future Scope ==
* https://github.com/expertiza/expertiza
# Publishing sample reviews made by students: This feature will require students to allow their review to be published as a sample review. This can then be made available to future students.


Expertiza Documentation
== External Links ==
* http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation
# link to forked repository [https://github.com/ashiskumar123/expertiza]
# link to the git pull request [https://github.com/expertiza/expertiza/pull/1169]
# link to the deployed application [http://ec2-13-59-7-94.us-east-2.compute.amazonaws.com:3000]


RSpec Documentation
== References ==
* http://rspec.info/documentation/
# Link to expertiza website: [https://expertiza.ncsu.edu/]

Revision as of 01:45, 14 November 2018

Introduction

Expertiza is a web based open source peer reviewing tool developed and maintained by current and past students of North Carolina State University. Peer review is a great way for a student to learn how to approach a project and get ideas for their own projects. Currently, there is no way for a student to view another student's work, unless they are reviewing the other student's work.

Problem Statement

The objective of this project is to:

  1. Add a feature to allow teams to publish their work for other students to see.
  2. Add a feature for a student to view sample submissions for a given assignment made available by other students:
    1. In the same assignment, available after deadline.
    2. In an old assignment, selected by the instructor from sample submissions made in an old assignment.
  3. Add a feature for instructor to select a previous assignment to show sample submissions for a new assignment.

Proposed Design

The proposed features will involve two kinds of users : Students and Instructors. Students will use the application to make their submissions public and view published reviews.

Instructors will use the application to make submissions from a previous assignment available as sample submissions for a current assignment. Only those submissions will be visible which were previously made public by the students.

Project Tasks

The tasks that need to be completed as part of this project can be listed as follows:

  1. Add checkbox against each assignment in student_tasks/list view to allow student to publish their work
  2. Add column make_public to table teams for storing user permission (published or not) for each project.
  3. Add controller for Sample submissions and implement corresponding methods.
  4. Add views for sample submissions
  5. Make changes to page student_task/view which would have link to sample submissions for each project.
  6. Add drop down in assignments/edit/_general view.
  7. Add controller code for the drop down.
  8. Add column sample_assignment_id to table assignment.
  9. Add test scripts for all the functionality.

Current status of Development

All tasks mentioned in Project tasks are completed.

Developed Code

1. Add checkbox against each assignment in student_tasks/list view to allow student to publish their work

<% if !participant.team.nil? %>
    <td align=center>
        <input id="makeSubPublic" teamid="<%= participant.team.id %>" type="checkbox" onclick="publishConfirmation(this)" <% if participant.team.make_public %>checked<% end %>>
    </td>
<% end %>

2. Add column make_public to table teams for storing user permission (published or not) for each project.

class AddSampleAssignmentToAssignments < ActiveRecord::Migration
  def change
    add_column :assignments, :sample_assignment_id, :integer, index: true
    add_foreign_key :assignments, :assignments, column: :sample_assignment_id
  end
end

3. Add controller for Sample submissions and implement corresponding methods.

# To give permission for making a submission available to others
  def make_public
    @team = Team.find(params[:id])
    @team.make_public = params[:status]
    @team.save
    respond_to do |format|
      format.html { head :no_content }
    end
  end

4. Add views for sample submissions

<!-- View to display sample submissions to the student -->
<h2>Sample Submissions for <%= @assignment.name%>:</h2>
<br>
<!-- Displaying sample submissions by students of the current course -->
<h3>Submissions made public by peers:</h3>
<% if @assignment_due_date==nil or @assignment_due_date>Time.new() %>
    <br><i>Will be available once the assignment submission is completed</i>
<% elsif @assignment_teams==[] %>
    <br><i>No sample submissions from current assignment made public yet</i>
<% else %>
    <ul>
      <% @assignment_teams.each do |assignment_team| %>
          <% if assignment_team.hyperlinks != [] %>
              <li>
                <ul>
                  <h4>Team name : <%=assignment_team.name%></h4>
                  <% assignment_team.hyperlinks.each do |assignment_link| %>
                      <li><a href="<%=assignment_link%>"><%=assignment_link%></a></li>
                  <%end%>
                </ul>
              </li>
          <%end%>
      <% end%>
    </ul>
<% end %>
<br>
<hr/>
<br>

<!-- Displaying sample submissions from a previous assignment chosen by the instructor -->
<h3>Submissions made public by instructor:</h3>
<% if @assignment_teams_professor == [] %>
    <br><i>No sample submissions from previous assignments made available yet</i>
<% else %>
    <ul>
      <% @assignment_teams_professor.each do |assignment_team| %>
          <% if assignment_team.hyperlinks != [] %>
              <ul>
                <li>
                  <h4>Team name : <%=assignment_team.name%></h4>
                  <% assignment_team.hyperlinks.each do |assignment_link| %>
                    <li><a href="<%=assignment_link%>"><%=assignment_link%></a></li>
                <%end%>
                </li>
              </ul>
          <%end%>
      <% end%>
    </ul>
<% end %>
<br><br>

<a href="javascript:window.history.back()">Back</a>

5. Make changes to page student_task/view which would have link to sample submissions for each project.

<li>
  <%= link_to "Sample Submissions", controller: 'sample_submissions', :action => 'index', :id => @assignment.id %>
    (View sample work submitted by other participants/teams)
</li>

6. Add drop down in assignments/edit/_general view.

<!-- Adding sample submissions for students to refer to -->
  <tr>
    <td style='padding:5px'><%= label_tag('assignment_form[assignment][sample_assignment_id]', 'Sample Assignment:') %>
      <img src="/assets/info.png" title='- Select an assignment that students can refer sample submission from.'>
    </td>
    <td style='padding:5px'><%= select('assignment_form[assignment]', 'sample_assignment_id', sample_sub_options, :selected => @assignment_form.assignment.sample_assignment_id) %> 
    </td>
  </tr>

7. Add controller code for the drop down.

   def sample_sub_options
    assignments = Assignment.all
    options = []
    assignments.each do |assignment|
      course_name = ""
      if assignment.course_id and assignment.course_id != 0 and !Course.find(assignment.course_id).nil?
        course_name = Course.find(assignment.course_id).name
      end
      options << [course_name + '- ' + assignment.name, assignment.id]
    end
    options.uniq.sort
    options.unshift(['-----------', nil])
  end

8. Add column sample_assignment_id to table assignment.

class AddSampleAssignmentToAssignments < ActiveRecord::Migration
  def change
    add_column :assignments, :sample_assignment_id, :integer, index: true
    add_foreign_key :assignments, :assignments, column: :sample_assignment_id
  end
end

9. Add test scripts for all the functionality.

def create_assignment_team(assignment_name, parent_id)
  assignment_team = AssignmentTeam.new
  assignment_team.name = assignment_name
  assignment_team.parent_id = parent_id
  assignment_team.save!
end

def init_test
  # create assignment and topic
  assignment = build(Assignment)
  course = Course.new
  course.name = "SampleSubmissionTestCourse"
  course.save
  assignment.course_id = course.id
  assignment.save

  create_assignemnt_team("ss_assignment_team_1", assignment.id)
  create_assignemnt_team("ss_assignment_team_2", assignment.id)
end

def visit_sample_submissions_page
  visit '/student_task/list'
  click_on "Example Assignment"
  click_on "Sample Submissions"
end

describe "sample submission test" do
  before(:each) { init_test }

  it "is able to make an assignment public" do
    visit '/student_task/list'
    find(:css, "#makeSubPublic[teamid='6050']").trigger("click")
    click_button 'OK'
    expect(page).to have_http_status(200)
  end

  it "should not see current assignment submissions if deadline is not met" do # Set deadline after current time.
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from current assignment made public yet"
  end

  it "should see current assignment submissions if deadline is met" do # Set deadline before current time.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from current assignment made public yet"
  end

  it "should not see instructor selected submissions if instructor has not selected them" do
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from previous assignment made available yet"
  end

  it "should see instructor selected submissions if instructor has selected them" do # Instructor makes submission available.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from previous assignment made available yet"
  end
end

Sample Submissions View

1. The first screenshot of the application is taken when the deadline for the current assignment has not crossed and the instructor also has not given any sample assignment for this assignment.

2. The second screenshot of the application is taken when the deadline for the current assignment has not crossed but the instructor has selected a sample assignment for viewing against this assignment.

3. The third screenshot of the application is taken when both the deadline for the current assignment has crossed and the instructor has selected a sample assignment for viewing.

Test Plan

Many of our changes are reflected on views (user interface). So we build tests with rspec/capybara. Following is the list of tests that conduct:

  1. it "is able to make an assignment public"
  2. it "is able to view sample submissions page"
  3. it "should not see current assignment submissions if deadline is not met"
  4. it "should see current assignment submissions if deadline is met"
  5. it "should not see instructor selected submissions if instructor has not selected them"
  6. it "should see instructor selected submissions if instructor has selected them"
def create_assignment_team(assignment_name, parent_id)
  assignment_team = AssignmentTeam.new
  assignment_team.name = assignment_name
  assignment_team.parent_id = parent_id
  assignment_team.save!
end

def init_test
  # create assignment and topic
  assignment = build(Assignment)
  course = Course.new
  course.name = "SampleSubmissionTestCourse"
  course.save
  assignment.course_id = course.id
  assignment.save

  create_assignemnt_team("ss_assignment_team_1", assignment.id)
  create_assignemnt_team("ss_assignment_team_2", assignment.id)
end

def visit_sample_submissions_page
  visit '/student_task/list'
  click_on "Example Assignment"
  click_on "Sample Submissions"
end

describe "sample submission test" do
  before(:each) { init_test }

  it "is able to make an assignment public" do
    visit '/student_task/list'
    find(:css, "#makeSubPublic[teamid='6050']").trigger("click")
    click_button 'OK'
    expect(page).to have_http_status(200)
  end

  it "should not see current assignment submissions if deadline is not met" do # Set deadline after current time.
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from current assignment made public yet"
  end

  it "should see current assignment submissions if deadline is met" do # Set deadline before current time.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from current assignment made public yet"
  end

  it "should not see instructor selected submissions if instructor has not selected them" do
    visit_sample_submissions_page
    expect(page).to have_content "No sample submissions from previous assignment made available yet"
  end

  it "should see instructor selected submissions if instructor has selected them" do # Instructor makes submission available.
    visit_sample_submissions_page
    expect(page).to_not have_content "No sample submissions from previous assignment made available yet"
  end
end

Future Scope

  1. Publishing sample reviews made by students: This feature will require students to allow their review to be published as a sample review. This can then be made available to future students.

External Links

  1. link to forked repository [1]
  2. link to the git pull request [2]
  3. link to the deployed application [3]

References

  1. Link to expertiza website: [4]