CSC/ECE 517 Fall 2019 - E1958. Two issues related to assignment management

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

Background

Expertiza has Assignment objects, which represent an assignment that is done by some number of users. An instructor or a TA can perform several kinds of operations on assignments, such as, ”Add participants”, “Create teams”, and “View scores”. These operations can be seen: First, on the homepage, under the “Actions” column in assignment list when a user (instructor or TA or admin) logs in and navigates to Manage -> Assignments.

Second, when editing an assignment (by clicking on edit logo above), on the tab called “Other stuff”.

Problem Statement

The following tasks were accomplished in this project:

  • Issue 1384: Implement a setting in the user’s (instructor/ TA) profile, from where the user can choose whether to see these actions on the homepage or in a tab associated with each assignment.
  • Issue 1430: Under the “General” tab of the assignment edit page, an instructor or a TA can change the course of an assignment.

What is wrong:

Issue 1430

A TA or an instructor can assign any course to an assignment even when they don't have access to the course. TAs can unassign an assignment from the course, and if they do so, they lose access to the assignment. What needs to be done:

Only those courses should be shown in the dropdown list of courses, the assignment is part of and the instructor or TA has access to. Instructors, but not TAs, would then be allowed to change an assignment to be part of no course. Also, change the name of the tab from “Other stuff” to “Etc.”.

Issue 1384

  • Implement a setting in the user’s (instructor/ TA) profile, from where the user can choose whether to see these actions on the homepage or in a tab associated with each assignment.

Two new flags in the user database namely preference_home_flag and preference_edit_flag were created which were initialized to be true and the user would see a checkbox for both of his preference in the profile page which would both be initially checked to be true. Now user can uncheck this to see where he/she wants to see the operations. We implemented them both on local. We tried to use one of the flags as a text box and tried to insert text values in the profile page and could not accomplish the expected output as the flag was not updating.

app/controllers/users_controller.rb

Before

 def user_params
    params.require(:user).permit(:name,
                                 :crypted_password,
                                 :role_id,
                                 :password_salt,
                                 :fullname,
                                 :email,
                                 :parent_id,
                                 :private_by_default,
                                 :mru_directory_path,
                                 :email_on_review,
                                 :email_on_submission,
                                 :email_on_review_of_review,
                                 :is_new_user,
                                 :master_permission_granted,
                                 :handle,
                                 :digital_certificate,
                                 :persistence_token,
                                 :timezonepref,
                                 :public_key,
                                 :copy_of_emails,
                                 :institution_id)
  end

After

  def user_params
    params.require(:user).permit(:name,
                                 :crypted_password,
                                 :role_id,
                                 :password_salt,
                                 :fullname,
                                 :email,
                                 :parent_id,
                                 :private_by_default,
                                 :mru_directory_path,
                                 :email_on_review,
                                 :email_on_submission,
                                 :email_on_review_of_review,
                                 :is_new_user,
                                 :master_permission_granted,
                                 :handle,
                                 :digital_certificate,
                                 :persistence_token,
                                 :timezonepref,
                                 :public_key,
                                 :copy_of_emails,
                                 :institution_id,
                                 :preference_home_flag,
                                 :preference_edit_flag)
  end

Added

app/views/users/_editpreference.html.erb

<%#created two checkboxes where the user can select where he wants to make the assignment operations visible %>
<% request_user ||= false %>
<%if !request_user%>
    <div>
      <table class="table borderless">
        <tr>
          <th align='left'>Where do you want to see actions?</th>
        </tr>
        <tr>
          <td><%= label_tag('user[preference_home_flag]', 'On the homepage')%></td>
          <td><%= check_box 'user', 'preference_home_flag', {},  true, false  %></td>
        </tr>
        <tr>
          <td><label for="user_preference_edit_flag">On the edit Assignment Page</label></td>
          <td><%= check_box 'user', 'preference_edit_flag', {},  true, false  %></td>
        </tr>
        <tr>
      </table>
    </div>
<% end %> 


db/migrate/20191028210443_add_preference_edit_flag_to_users.rb

class AddPreferenceEditFlagToUsers < ActiveRecord::Migration
  def change
    add_column :users, :preference_edit_flag, :boolean , :default => true
  end
end
class AddPreferenceHomeFlagToUsers < ActiveRecord::Migration
  def change
    add_column :users, :preference_home_flag, :boolean , :default => true
  end
end

app/views/profile/edit.html.erb

  <%#added a new part in the front end for users to choose the options to see the assignment operations %>
  <%= render :partial => 'users/editpreference' %>


Issue1430

  • Under the “General” tab of the assignment edit page, an instructor or a TA can change the course of an assignment.

Only those courses are shown in the dropdown list of courses, the assignment is part of and the instructor or TA has access to. Instructors, but not TAs, would be allowed to change an assignment to be part of no course. Also, changed the name of the tab from “Other stuff” to “Etc.”.

app/helpers/assignment_helper.rb

Before

module AssignmentHelper
  def course_options(instructor)
    if session[:user].role.name == 'Teaching Assistant'
      courses = []
      ta = Ta.find(session[:user].id)
      ta.ta_mappings.each {|mapping| courses << Course.find(mapping.course_id) }
      # If a TA created some courses before, s/he can still add new assignments to these courses.
      courses << Course.where(instructor_id: instructor.id)
      courses.flatten!
    # Administrator and Super-Administrator can see all courses
    elsif session[:user].role.name == 'Administrator' or session[:user].role.name == 'Super-Administrator'
      courses = Course.all
    elsif session[:user].role.name == 'Instructor'
      courses = Course.where(instructor_id: instructor.id)
      # instructor can see courses his/her TAs created
      ta_ids = []
@@ -21,8 +25,7 @@ def course_options(instructor)
        ta.ta_mappings.each {|mapping| courses << Course.find(mapping.course_id) }
      end
    end
    options = []
    options << ['-----------', nil]

    courses.each do |course|
      options << [course.name, course.id]
    end


After


module AssignmentHelper
  def course_options(instructor)
    options = []
    if session[:user].role.name == 'Teaching Assistant'
      courses = []
      ta = Ta.find(session[:user].id)
      #the course corresponding to each TA will be added to the dropdown.
      ta.ta_mappings.each {|mapping| courses << Course.find(mapping.course_id) }
      # If a TA created some courses before, s/he can still add new assignments to these courses.
      courses << Course.where(instructor_id: instructor.id)
      #courses << Course.where(instructor_id: instructor.id)
      courses.flatten!
    # Administrator and Super-Administrator can see all courses
    elsif session[:user].role.name == 'Administrator' or session[:user].role.name == 'Super-Administrator'
      # Only SuperAdmin and Admin can have the right to make an assignment to a nil course.
      options << ['-----------', nil]
      courses = Course.all
    elsif session[:user].role.name == 'Instructor'
      # Only SuperAdmin and Admin can have the right to make an assignment to a nil course.
      options << ['-----------', nil]
      courses = Course.where(instructor_id: instructor.id)
      # instructor can see courses his/her TAs created
      ta_ids = []
      ta_ids << Instructor.get_my_tas(session[:user].id)
      ta_ids.flatten!
      ta_ids.each do |ta_id|
        ta = Ta.find(ta_id)
        ta.ta_mappings.each {|mapping| courses << Course.find(mapping.course_id) }
      end
      # ta_ids = []
      # ta_ids << Instructor.get_my_tas(session[:user].id)
      # ta_ids.flatten!
      # ta_ids.each do |ta_id|
      #   ta = Ta.find(ta_id)
      #   ta.ta_mappings.each {|mapping| courses << Course.find(mapping.course_id) }
      # end
    end
    options = []
    options << ['-----------', nil]


    courses.each do |course|
      options << [course.name, course.id]
    end

app/views/assignments/edit.html.erb


<li><a href="#tabs-8" id="Other">etc</a></li>


Testing

Travis-CI Build Testing Travis-CI Build Test of the beta branch after a refactored function is merged in the beta branch.


Team Information

  1. Parvathy Haridas Menon (pharida@ncsu.edu)
  2. Anmol Desai (adesai5@ncsu.edu)
  3. Suyash Jain (sjain26@ncsu.edu)

References

  1. Expertiza on GitHub
  2. The live Expertiza website
  3. Expertiza project documentation wiki
  4. GitHub Project Repository Fork
  5. Demo link
  6. Rspec Documentation