CSC/ECE 517 Fall 2020 - E2058. Two issues related to assignment management

From Expertiza_Wiki
Revision as of 15:36, 13 October 2020 by Lhan6 (talk | contribs) (→‎Extra Tasks)
Jump to navigation Jump to search

Project Introduction

Expertiza has Assignment objects, which represent an assignment that is done by some number of users. This project enabled instructors or TAs to customize viewing preference and fixed two bugs in their assigment management process.

Team

Hao Zhang (hzhang62)

Zhuolin Li (zli82)

Lige Han (lhan6)

Project Goal

The goals of this project were to solve tow issues related to assignment management.

  • Issue 1384: On the homepage, under the “Actions” column in the assignment list when a user (instructor orTA or admin) logs in and navigates to Manage -> Assignments(as shown below).

It looks crowded and is easy to be misclicked by some users. The goal of this issue is to add a preference option in user's profile where they can choose wether to show or hide detailed actions on the assignment management homepage.
  • Issue 1430:
What is wrong:
1. A TA or an instructor can assign an assignment to any course even when they don't have access to the course.
2. TAs can unassign an assignment from the course, and if they do so, they lose access to the assignment.
What needs to be done:
1. 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.
2. Instructors, but not TAs, would then be allowed to change an assignment to be part of no course.

Files Involved

tree_display.jsx

profile_controller.rb

users_controller.rb

user.rb

edit.html.erb

list.html.erb

assignment_helper.rb

_general.html.erb

Running Tests

  To Be Specified

Modifications made w.r.t issue 1384

app/assets/javascripts/tree_display.jsx

Before

let app_variables = {
  currentUserId: null
};

After

let app_variables = {
  currentUserId: null,
  homeActionShowFlag: null
};

...

Before

jQuery(document).ready(function() {
  // This preloadedImages function is refered from http://jsfiddle.net/slashingweapon/8jAeu/
  // Actually I am not using the values in preloadedImages, but image loading speed is indeed getting faster
  var preloadedImages = []
  function preloadImages() {
    for (var idx = 0; idx < arguments.length; idx++) {
};

After

jQuery(document).ready(function() {
  // This preloadedImages function is refered from http://jsfiddle.net/slashingweapon/8jAeu/
  // Actually I am not using the values in preloadedImages, but image loading speed is indeed getting faster
  var preloadedImages = []
  function preloadImages() {
    for (var idx = 0; idx < arguments.length; idx++) {
};

...

Before

else if (newNodeType === 'assignments') {
          // Assignment tab starts here
          // Now is_intelligent and Add Manager related buttons have not been added into the new UI
          moreContent.push(

After

else if (newNodeType === 'assignments' && app_variables.homeActionShowFlag=='true') {
          // Assignment tab starts here
          // Now is_intelligent and Add Manager related buttons have not been added into the new UI
          moreContent.push(

app/controllers/profile_controller.rb

Before

    end
    if @user.update_attributes(params[:user])
      ExpertizaLogger.info LoggerMessage.new(controller_name, @user.name, "Your profile was successfully updated.", request)
      flash[:success] = 'Your profile was successfully updated.'
    else
      ExpertizaLogger.error LoggerMessage.new(controller_name, @user.name, "An error occurred and your profile could not updated.", request)

After

    end
    if @user.update_attributes(params[:user])
      ExpertizaLogger.info LoggerMessage.new(controller_name, @user.name, "Your profile was successfully updated.", request)
      if params[:no_show_action] == 'not_show_actions'
        @user.preference_home_flag = false
      else
        @user.preference_home_flag = true
      end
      @user.save!
      flash[:success] = 'Your profile was successfully updated.'
    else
      ExpertizaLogger.error LoggerMessage.new(controller_name, @user.name, "An error occurred and your profile could not updated.", request)

...

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)

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)
  end

app/controllers/user_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)
  end

app/models/user.rb

Before

  def initialize(attributes = nil)
    super(attributes)
    Authlogic::CryptoProviders::Sha1.stretches = 1
    @email_on_review = true
    @email_on_submission = true
    @email_on_review_of_review = true
    @copy_of_emails = false
  end

After

  def initialize(attributes = nil)
    super(attributes)
    Authlogic::CryptoProviders::Sha1.stretches = 1
    @email_on_review = true
    @email_on_submission = true
    @email_on_review_of_review = true
    @copy_of_emails = false
    @preference_home_flag = true
  end

...

Before

  def self.export(csv, _parent_id, options)
    users = User.all
    users.each do |user|
      tcsv = []
      tcsv.push(user.name, user.fullname, user.email) if options["personal_details"] == "true"
      tcsv.push(user.role.name) if options["role"] == "true"
      tcsv.push(user.parent.name) if options["parent"] == "true"
      tcsv.push(user.email_on_submission, user.email_on_review, user.email_on_review_of_review, user.copy_of_emails) if options["email_options"] == "true"
      tcsv.push(user.handle) if options["handle"] == "true"
      csv << tcsv
    end
  end

After

  def self.export(csv, _parent_id, options)
    users = User.all
    users.each do |user|
      tcsv = []
      tcsv.push(user.name, user.fullname, user.email) if options["personal_details"] == "true"
      tcsv.push(user.role.name) if options["role"] == "true"
      tcsv.push(user.parent.name) if options["parent"] == "true"
      tcsv.push(user.email_on_submission, user.email_on_review, user.email_on_review_of_review, user.copy_of_emails) if options["email_options"] == "true"
      tcsv.push(user.handle) if options["handle"] == "true"
      tcsv.push(user.preference_home_flag) if options["preference_home_flag"] == "true"
      csv << tcsv
    end
  end

app/views/profile/edit.html.erb

Before

  <%= render :partial => 'users/email' %>
  <%= render :partial => 'users/institutions' %>
  <%= render :partial => 'users/prefs' %>
  <%= render :partial => 'handle' %>

After

  <%= render :partial => 'users/email' %>
  <%= render :partial => 'users/institutions' %>
  <%= render :partial => 'users/prefs' %>
  <p><strong>Action Preference<strong><p>
  <%= radio_button_tag(:no_show_action, 'not_show_actions',checked = @user.preference_home_flag ? false : true) %>
  <%= label_tag(:no_show_action, "homepage cannot show actions") %>
  <%= radio_button_tag(:no_show_action, 'show_actions', checked = @user.preference_home_flag) %>
  <%= label_tag(:no_show_action, "homepage can show actions") %>
  <%= render :partial => 'handle' %>

app/views/tree_display/list.html.erb

Before

<h1>Manage content</h1>

<%= link_to 'Manage Notifications', notifications_url %>
<%# add data-user-id %>
<%# associated with current logged in user %>
<%# done to make it available in the frontend %>
<div id="tree_display" params="#{@reactjsParams}" data-menu-item= '<%= "#{@currCtlr}" %>'></div>

After

<h1>Manage content</h1>

<%= link_to 'Manage Notifications', notifications_url %>
<%# add data-user-id %>
<%# associated with current logged in user %>
<%# done to make it available in the frontend %>
<div id="tree_display" params="#{@reactjsParams}" data-user-id="<%= current_user.id %>" data-user-show="<%= current_user.preference_home_flag %>" data-menu-item= '<%= "#{@currCtlr}" %>'></div>

Modifications made w.r.t issue 1430

Results

34 out of 34 tests in the review_mapping_helper_spec.rb test file.

Our code changes can be viewed here.

URL link of video of review_mapping_helper_spec.rb tests running and passing:- https://drive.google.com/file/d/1OS4yNI0fDGo4TlkOSxuWNgfMZ4D-XU2f/view

Relevant Links

Main Expertiza Repository can be found here.

Our forked Repository can be found here.