CSC/ECE 517 Fall 2019 - E1958. Two issues related to assignment management: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(36 intermediate revisions by one other user not shown)
Line 1: Line 1:
=E1958. Two issues related to assignment management=
=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”.


__TOC__
__TOC__


=Problem Statement=
The following tasks were accomplished in this project:


===Brief Introduction===
* 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.
* E1961 Project aims to fix the problems of making the email notification function more reliable.


* The forked git repository for this project can be found [https://github.com/YongjianZhu/expertiza YongjianZhu/expertiza.git]
* 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:  


===Problem Statement===
==Issue 1430==
The following tasks were accomplished in this project:
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:


* Issue1: Fix the problem that the author(reviewee) cannot receive the email notification about the review from someone else. The Expertiza is supposed to email authors each time a review of their work is submitted.
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..


* Issue2: Fix the bugs to make Expertiza emails reviewers each time an author that they have reviewed submits new work.
==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. 


====Issue1====
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.


* Add a method in both "update" and "create" functions to call the email function to make the Experiza send the email to reviewee when reviewers submit the reviews
'''app/controllers/users_controller.rb'''
====Before====
<pre>
<pre>
app/controllers/response_controller.rb:
def user_params
 
    params.require(:user).permit(:name,
  def send_email_to_reviewee(map)
                                :crypted_password,
    defn = {body: {type: "Peer Review", partial_name: "new_submission"} }
                                :role_id,
    map.email(defn, Assignment.find(Participant.find(map.reviewer_id).parent_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
   end
</pre>
</pre>


 
====After====
====Issue2====
 
* Add new function to email all reviewers a new submission is ready to review:
::* In the first round, there is no reviewer before they take a request
::* ...........................................................
::* ...........................................................
 
'''app/controllers/submitted_content_controller.rb:'''
<pre>
<pre>
email_all_reviewers(@participant)
  def user_params
    end
    params.require(:user).permit(:name,
    redirect_to action: 'edit', id: @participant.id
                                :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
   end
</pre>
</pre>


====Added====
'''app/views/users/_editpreference.html.erb'''
<pre>
<pre>
def email_all_reviewers(participant)
<%#created two checkboxes where the user can select where he wants to make the assignment operations visible %>
    if participant.reviewers != []
<% request_user ||= false %>
      participant.reviewers.each do |reviewer|
<%if !request_user%>
         map = ReviewResponseMap.where(['reviewer_id = ? and reviewee_id = ?', reviewer.id, participant.team.id]).first
    <div>
         responses = Response.where(:map_id => map.id)
      <table class="table borderless">
        responses = responses.sort_by { |obj| obj.updated_at }
        <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 %>
</pre>


        # the latest response will be the last
        latest_response = responses.last


        # we need to pass the id of lastest_response in the URL mentioned in the mail.
'''db/migrate/20191028210443_add_preference_edit_flag_to_users.rb'''
        # this will open the correct /response/edit?id=#{latest_response.id} page for the reviewer when (s)he clicks on it.


        user = User.find(reviewer.user_id)
<pre>
        instructor = User.find(user.parent_id)
class AddPreferenceEditFlagToUsers < ActiveRecord::Migration
        bcc_mail_address = ""
  def change
        if instructor.copy_of_emails?
    add_column :users, :preference_edit_flag, :boolean , :default => true
          bcc_mail_address = instructor.email
        else
          # do noting
        end
        if user.email_on_submission?
          MailerHelper.send_mail_to_reviewer(user,
                                            bcc_mail_address,
                                            "You have a new submission to review",
                                            "update",
                                            "Please visit https://expertiza.ncsu.edu/response/edit?id=#{latest_response.id} and proceed to peer reviews.").deliver
        end
      end
    end
   end
   end
end
</pre>
</pre>


'''app/helpers/mailer_helper.rb:'''
<pre>
<pre>
def self.send_mail_to_reviewer(user, bcc_mail_address, subject, partial_name, note)
class AddPreferenceHomeFlagToUsers < ActiveRecord::Migration
    Mailer.new_review_request_message ({
  def change
        to: user.email,
    add_column :users, :preference_home_flag, :boolean , :default => true
        bcc: bcc_mail_address,
        subject: subject,
        body: {
            user: user,
            first_name: ApplicationHelper.get_user_first_name(user),
            message: note,
            partial_name: partial_name
        }
    })
   end
   end
end
</pre>
</pre>


'''app/views/mailer/new_review_message.html.erb:'''
'''app/views/profile/edit.html.erb'''
<pre>
  <%#added a new part in the front end for users to choose the options to see the assignment operations %>
  <%= render :partial => 'users/editpreference' %>
</pre>


<pre>
<!DOCTYPE html>
<html>
<head>
  <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<%= render :partial => 'mailer/partials/'+@partial_name+'_html' %>


<hr>
==Issue1430==


This message has been generated by <A HREF="http://expertiza.ncsu.edu">Expertiza</A><BR/>
* Under the “General” tab of the assignment edit page, an instructor or a TA can change the course of an assignment.
http://expertiza.ncsu.edu


</body>
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.”.
</html>
</pre>


'''app/views/mailer/partials/update.html.html.erb:'''
'''app/helpers/assignment_helper.rb'''


====Before====
<pre>
<pre>
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]


Hi <%= @first_name %>,</br>
    courses.each do |course|
<p>
      options << [course.name, course.id]
  One of the assignments you are reviewing has just been entered or revised.
    end
  "<%= @message %>"
</p>
<br/>
</pre>
</pre>


====Issue3====
 
* ...........................................................................................
====After====
'''app/controllers/submitted_content_controller.rb:'''
<pre>
<pre>
instructor = User.find(user.parent_id)
        bcc_mail_address = ""
        if instructor.copy_of_emails?
          bcc_mail_address = instructor.email
        else
          # do noting
        end
</pre>


<pre>
module AssignmentHelper
bcc: bcc_mail_address,
  def course_options(instructor)
</pre>
    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]


====Issue4====
* ...........................................................................................
'''app/views/users/_prefs.html.erb:'''
* previous version:


<pre>
    courses.each do |course|
<td><label for="user_email_on_review">When someone else <strong>reviews</strong> my work</label></td>
      options << [course.name, course.id]
            <td><%= check_box 'user', 'email_on_review', {},  true, false  %></td>
    end
          </tr>
          <tr>
            <td><label for="user_email_on_submission">When someone else <strong>submits</strong> work I am assigned to review</label></td>
            <td><%= check_box 'user', 'email_on_submission', {},  true, false  %></td>
          </tr>
          <tr>
            <td><label for="user_email_on_review_of_review">When someone else reviews one of my reviews (<strong>metareviews</strong> my work)</label></td>
            <td><%= check_box 'user', 'email_on_review_of_review', {},  true, false %></td>
          </tr>
</pre>
</pre>


* correct version:
'''app/views/assignments/edit.html.erb'''
<pre>
<pre>
<tr>
 
            <td><label for="user_email_on_review">When someone else <strong>reviews</strong> my work</label></td>
<li><a href="#tabs-8" id="Other">etc</a></li>
            <td><%= check_box 'user', 'email_on_review'  %></td>
          </tr>
          <tr>
            <td><label for="user_email_on_submission">When someone else <strong>submits</strong> work I am assigned to review</label></td>
            <td><%= check_box 'user', 'email_on_submission'  %></td>
          </tr>
          <tr>
            <td><label for="user_email_on_review_of_review">When someone else reviews one of my reviews (<strong>metareviews</strong> my work)</label></td>
            <td><%= check_box 'user', 'email_on_review_of_review' %></td>
          </tr>
</pre>
</pre>


===Process Video===
 
=Testing=
Travis-CI Build Testing
Travis-CI Build Test of the beta branch after a refactored function is merged in the beta branch.
 
[[File:Exp1386.jpeg]]




===Test===
[[File:Exp1430.jpeg]]


===Team Information===
=Team Information=
#Siwei Wen (swen4@ncsu.edu)
#Parvathy Haridas Menon (pharida@ncsu.edu)
#Shuzheng Wang (swang41@ncsu.edu)
#Anmol Desai (adesai5@ncsu.edu)
#Zhifeng Zhu (zzhu25@ncsu.edu)
#Suyash Jain (sjain26@ncsu.edu)
#'''Mentor:''' Ed Gehringer (efg@ncsu.edu)


===References===
=References=


#[https://github.com/expertiza/expertiza Expertiza on GitHub]
#[https://github.com/expertiza/expertiza Expertiza on GitHub]

Latest revision as of 22:29, 17 November 2019

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