CSC/ECE 517 Fall 2019 - E1954. Auto-generate submission directory names based on assignment names

From Expertiza_Wiki
Jump to navigation Jump to search

This wiki page is for the description of changes made under E1954. Auto-generate submission directory names based on assignment names for Fall 2019, CSC/ECE 517.

Expertiza Background

Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open-source project developed on Ruby on Rails platform and its code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.

Description of the current project

The following is an Expertiza based OSS project which deals primarily with the AssignmentsController and AssignmentsView - _general.html.erb. Here is the details description of the project:
The directory name is auto-generated from the assignment name. The instructor is allowed to edit
It is done by changing spaces in the names to underscores. E.g., the directory for Program 1 is by default "Program_1".
The special characters like '/','\','$' etc are to be removed from the auto-generated submission directory name.
A check is added to prevent two assignments in the same course from having the same name.
A check is made to stop two assignments from sharing the same directory.

Submitted Work and Demonstration of the Project

Files modified in Project

A controller and a helper file were modified for this project namely:
1. AssignmentsController
2. AssignmentsView - _general.html.erb

AssignmentsController

This is a controller that helps instructors create, modify, copy new assignments. Each assignment can be associated with specific Rubrics, Review Strategy and Due dates.


AssignmentsView - _general.html.erb

This the View for creating the new assignments and editing the existing assignments. This view also handles specifications of Rubrics, Review Strategy and Dates.

List of changes

We worked on the following work items(WIs)
WI1: Created exist_assignment and exist_directory to check if the assignment name and directory name already exists in the current course. If any of those are already present then flash the respective error, else save the assignment. Here is the create method of controller -> assignments_controller.rb:

  def create
    @assignment_form = AssignmentForm.new(assignment_form_params)
    if params[:button]
      # Do not create an assignment if the assignment name or directory name already present in the course
      exist_assignment = Assignment.find_by(name: @assignment_form.assignment.name, course_id: @assignment_form.assignment.course_id)
      exist_directory = Assignment.find_by(directory_path: assignment_form_params[:assignment][:directory_path], course_id: @assignment_form.assignment.course_id)
      if !exist_assignment and !exist_directory
        if @assignment_form.save
          @assignment_form.create_assignment_node
          # Get the details of the assignment which is saved in current_assignment
          current_assignment = Assignment.find_by(name: @assignment_form.assignment.name, course_id: @assignment_form.assignment.course_id)
          assignment_form_params[:assignment][:id] = current_assignment.id.to_s
          ques_array = assignment_form_params[:assignment_questionnaire]
          due_array = assignment_form_params[:due_date]
          ques_array.each do |cur_questionnaire|
            cur_questionnaire[:assignment_id] = current_assignment.id.to_s
          end
          due_array.each do |cur_due|
            cur_due[:parent_id] = current_assignment.id.to_s
          end
          assignment_form_params[:assignment_questionnaire] = ques_array
          assignment_form_params[:due_date] = due_array
          @assignment_form.update(assignment_form_params, current_user)
          aid = Assignment.find_by(name: @assignment_form.assignment.name, course_id: @assignment_form.assignment.course_id).id
          ExpertizaLogger.info "Assignment created: #{@assignment_form.as_json}"
          redirect_to edit_assignment_path aid
          undo_link("Assignment \"#{@assignment_form.assignment.name}\" has been created successfully. ")
          return
        else
          flash.now[:error] = "Failed to create assignment"
          render 'new'
        end
      else
        flash.now[:error] = "This assignment/directory already exists in the selected course. Kindly rename."
        render 'new'
      end
    else
      render 'new'
      undo_link("Assignment \"#{@assignment_form.assignment.name}\" has been created successfully. ")
    end
  end

WI2: Auto-generate the Submission directory name based on the assignment name. Allow, the Submission Directory name field to be explicitly editable by the instructor. Here is the javascript function introduced in views -> assignments -> edit -> _general.html.erb

<tr><div class="form-inline">
<td style='padding:5px'><%= label_tag('assignment_form[assignment][directory_path]', 'Submission directory:') %></td>
<td style='padding:5px'><%= text_field_tag('assignment_form[assignment][directory_path]', @assignment_form.assignment.directory_path, required: true, 
:id => 'directory_field', :style => 'width:250px', class: 'form-control') %> (Note: Directory name is auto-generated from Assignment Name. You can change it if you wish to.)
<img src="/assets/info.png" title='- DO NOT change this filed for an on-going assignment. This may cause lost of student submitted file.'>
</td></div>
</tr>

$(function() {
    $("#name_field").change(function() {
        filename = $( "#name_field" ).val().replace(/ /g,"_").replace(/[/\\?%*:|"<>/$&!#%^@]/g, '');;
        $('#directory_field').val(filename);
    });
});

WI3: Earlier the assignment was getting generated even if the instructor was not giving it any name or submission directory path, now both of these fields have been made mandatory.

Testing Details

RSpec

In the spec file for assignments controller, a check is made if the assignment which is getting created is of the name which already exists then the assignment should not be allowed to save.

UI Testing

Following Steps needs to be performed to test the project from UI:-
Step 1: Login as Instructor. Create an assignment under any of the existing courses with name as "test assignment".




Step 2: Check if the Submission directory field is automatically getting populated based on the assignment name (replacing spaces with underscores and removing special characters).





Step 3: Fill in the details for Rubrics and Review Strategy.





Step 4: Click on create. You should be able to see the assignment you created in the list.


<br

Step 5: Now, try to create another assignment with the same name in the same course. Also, try to change the submission directory name to any of the existing assignment or same the assignment created in Step 2, Check if the system flashes an error in the creation of this assignment.




Scope for future improvement

While working on this project, we identified an existing issue where if you try to edit the name of the already existing assignment to something which is the same as another existing asignment then the system breaks. This could be made another OSS topic to be worked on.


Team Information

1) Amit Mandliya (amandli)

2) Anuja Kulkarni (apkulka2)

3) Samruddhi Khandale (sskhanda)

Mentor : Akanksha Mohan