E1838 Project Red: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(24 intermediate revisions by the same user not shown)
Line 15: Line 15:
=='''Modified Files'''==
=='''Modified Files'''==


1) assignment_controller.rb
1) /app/views/submitted_content/_submitted_files.html.erb


2) assignment.rb
2) /app/controllers/assignment_controller.rb
 
3) assignment/new.html.erb


3) /app/views/assignments/edit/_general.html.erb
----
----


Line 33: Line 32:


Pseudo Code:
Pseudo Code:
    Added following logic in /app/views/submitted_content/_submitted_files.html.erb
Added following logic in /app/views/submitted_content/_submitted_files.html.erb


       <% if @assignment.directory_path != "" %>
       <% if @assignment.directory_path != "" %>
Line 52: Line 51:
Append assignment_name, assignment_id, course_id to make the directory name unique.
Append assignment_name, assignment_id, course_id to make the directory name unique.


Files modified:
Files modified:  
 
/app/controllers/assignment_controller.rb
/app/controllers/assignment_controller.rb
/app/views/assignments/edit/_general.html.erb
1) /app/views/assignments/edit/_general.html.erb


Pseudo code:
Pseudo code:


            if quesparams[:assignment][:directory_path] == ""
      <td><input type="checkbox" name="assignment_form[check_validate]" /> File submissions are allowed? </td>
            quesparams[:assignment][:directory_path] = "#{quesparams[:assignment][:name]}_#{quesparams[
                :assignment][:id]}_#{quesparams[:assignment][:course_id]}"
Explanation: Added a checkbox in the view for creating an assignment. An instructor can select if file submissions are allowed. If he selects 'yes' then if the instructor has given an empty directory path, the name of the directory for the assignment will be auto generated.
          end
 
2) /app/controllers/assignment_controller.rb
 
      if quesparams[:assignment][:directory_path] == "" and quesparams[:check_validate] == "on"
        quesparams[:assignment][:directory_path] = "#{quesparams[:assignment][:name]}_#{quesparams[:assignment][:id]}_#{quesparams[:assignment][:course_id]}"
      end


Explanation: If the check box is checked, it will pass the value "on" to the assignment controller and the directory name will be auto generated.


[[File:Blank_Diagram.jpeg]]
[[File:Blank_Diagram.jpeg]]
Line 86: Line 97:
5) Select if you want to allow file submissions
5) Select if you want to allow file submissions


6) If 'yes', then file directory name will be auto generated as assignment_name+assignment_id+course_name
6) If 'yes', then file directory name will be auto generated as 'assignment_name'_'assignment_id'_'course_name'


7) If 'no'
7) If 'no'
Line 92: Line 103:
8) Login as a student and you can see that only links can be submitted and file submissions are disabled since the directory is not specified
8) Login as a student and you can see that only links can be submitted and file submissions are disabled since the directory is not specified


==''' Automated tests for Issue #391 and #404 '''==
==''' Automated tests for Issue #1190 '''==
 
Following RSPEC Code is added to assignment_spec.rb:
 
1) To check if the directory storage path specified by the user is a part of any other submissions directory we check if the assignment.directory_path is a part of any existing directory path:
    1)describe 'check_directory_path' do:
    2)    it 'returns false if directory path already in use' do:
    3)        @assignment = create(:assignment)
    4)        expect(@assignment.check_directory_path).to eql(false)
    5)    end
    6)end
 
 
2) To check that an assignment object cannot be saved until a submission directory path is provided for that assignment:


1)it 'is not valid without directory_path' do
Following RSPEC Code is added to assignments_controller_spec.rb:
2)    assignment.directory_path = nil
3)    assignment.should_not be_valid
4)end


3)  To check if after assigning course to an assignment is the directory path updated to contain the course path:
The below code RSPEC snippet tests for the issue where in the assignment which is duplicated does not have the same directory for submissions as the original assignment.


1)it 'should contain course in path name' do
    context 'when new assignment directory is same as old' do
2)   @assignment = create(:assignment)
      it 'should show an error and redirect to assignments#edit page' do
3)   @assignment.directory_path = Course.first.directory_path.to_s + "/finaltest"
        allow(new_assignment).to receive(:save).and_return(true)
4)    expect(@assignment.directory_path).to include(Course.first.directory_path)
        allow(Assignment).to receive(:find).with(2).and_return(new_assignment)
5)end
        params = {id: 1}
** To test the changes clone the following repository https://github.com/daxamin/expertiza .
        get :copy, params
        expect(flash[:note]).to eq("Warning: The submission directory for the copy of this assignment will be the same as the submission directory "\
          "for the existing assignment. This will allow student submissions to one assignment to overwrite submissions to the other assignment. "\
          "If you do not want this to happen, change the submission directory in the new copy of the assignment.")
        expect(flash[:error]).to eq('The assignment was not able to be copied. Please check the original assignment for missing information.')
        expect(response).to redirect_to('/tree_display/list')
      end

Latest revision as of 23:59, 9 November 2018

Introduction

Problem Statement

In Expertiza, if the instructor doesn’t specify the assignment directory for a submission, the directory defaults to the home directory. This can lead to multiple assignment submissions being in the same place and creating confusion. The aim of the project if to handle all the scenarios that can arise when the instructor is not specifying any directory name.

Issues to be fixed

Issue #391: In Expertiza, if the instructor doesn’t specify the assignment directory for a submission, the directory defaults to the home directory. This can lead to multiple assignment submissions being in the same place and creating confusion. Please take a look at the Github issue for suggestions on how to solve this.

Issue #1190: An issue with conflicting directories for copied assignments was fixed. You need to write the test to verify that this issue doesn’t recur. This test should check that the assignment directories for copied assignments are distinct from the original directories.

Issue #1201: Expertiza has the feature to auto generate the directory names for submissions from the assignment name. However, this may be concerning if two assignments have the same name, in which case the submission folders would be the same and this would again create a problem. This needs to be fixed.


Modified Files

1) /app/views/submitted_content/_submitted_files.html.erb

2) /app/controllers/assignment_controller.rb

3) /app/views/assignments/edit/_general.html.erb


Approach taken to resolve the issues

Issue #391

-> When the instructor has not specified a directory path, there is no directory where the files can be stored. -> Hence we allow only links to be submitted in such an assignment. -> In the view of submitted content controller we disabled the button to upload files in such assignment where the directory path is null. -> We displayed the message 'Fie submissions are disabled' whenever anyone tries to upload files to such assignment.

Pseudo Code: Added following logic in /app/views/submitted_content/_submitted_files.html.erb

     <% if @assignment.directory_path != "" %>
       <% puts "Assign Directory: #{@assignment.directory_path}" %>
       <%= submit_tag 'Upload file', class: 'btn btn-default' %>
     <% else %>
       <%= 'File Submissions are disabled' %>
     <%end%>

Explanation: If the assignment directory path is specified by the instructor then the button to upload files will be displayed else the warning message 'File submissions are disabled will be displayed'.

Issue #1201

Expertiza has the feature to auto generate the directory names for submissions from the assignment name. However, this may be concerning if two assignments have the same name, in which case the submission folders would be the same and this would again create a problem.

Approach taken to solve the issue: Logic for Auto generation of the directory names: Append assignment_name, assignment_id, course_id to make the directory name unique.

Files modified:

/app/controllers/assignment_controller.rb

/app/views/assignments/edit/_general.html.erb


1) /app/views/assignments/edit/_general.html.erb

Pseudo code:

<input type="checkbox" name="assignment_form[check_validate]" /> File submissions are allowed?

Explanation: Added a checkbox in the view for creating an assignment. An instructor can select if file submissions are allowed. If he selects 'yes' then if the instructor has given an empty directory path, the name of the directory for the assignment will be auto generated.

2) /app/controllers/assignment_controller.rb

     if quesparams[:assignment][:directory_path] == "" and quesparams[:check_validate] == "on"
       quesparams[:assignment][:directory_path] = "#{quesparams[:assignment][:name]}_#{quesparams[:assignment][:id]}_#{quesparams[:assignment][:course_id]}"
     end

Explanation: If the check box is checked, it will pass the value "on" to the assignment controller and the directory name will be auto generated.

How to Test

Link to ScreenCast Bug #391 : https://youtu.be/OVVknOBkG6Y

Link to ScreenCast Bug #404 : https://youtu.be/uvnamlY2

Test Plan

issue #391 and issue #1201

Steps to test Issue #391 and #1201

1) Login as Instructor

2) Click on Manage , select assignments.

3) New public assignment/ New private assignment

4) Fill in the details

5) Select if you want to allow file submissions

6) If 'yes', then file directory name will be auto generated as 'assignment_name'_'assignment_id'_'course_name'

7) If 'no'

8) Login as a student and you can see that only links can be submitted and file submissions are disabled since the directory is not specified

Automated tests for Issue #1190

Following RSPEC Code is added to assignments_controller_spec.rb:

The below code RSPEC snippet tests for the issue where in the assignment which is duplicated does not have the same directory for submissions as the original assignment.

    context 'when new assignment directory is same as old' do
     it 'should show an error and redirect to assignments#edit page' do
       allow(new_assignment).to receive(:save).and_return(true)
       allow(Assignment).to receive(:find).with(2).and_return(new_assignment)
       params = {id: 1}
       get :copy, params
       expect(flash[:note]).to eq("Warning: The submission directory for the copy of this assignment will be the same as the submission directory "\
         "for the existing assignment. This will allow student submissions to one assignment to overwrite submissions to the other assignment. "\
         "If you do not want this to happen, change the submission directory in the new copy of the assignment.")
       expect(flash[:error]).to eq('The assignment was not able to be copied. Please check the original assignment for missing information.')
       expect(response).to redirect_to('/tree_display/list')
     end