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
 
(34 intermediate revisions by one other user not shown)
Line 1: Line 1:
=Introduction=
=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,
                                :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
</pre>


   def send_email_to_reviewee(map)
====After====
    defn = {body: {type: "Peer Review", partial_name: "new_submission"} }
<pre>
    map.email(defn, Assignment.find(Participant.find(map.reviewer_id).parent_id))
   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
   end
</pre>
</pre>


====Added====
'''app/views/users/_editpreference.html.erb'''
<pre>
<%#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 %>
</pre>


====Issue2====


* Add new function to email all reviewers a new submission is ready to review:
'''db/migrate/20191028210443_add_preference_edit_flag_to_users.rb'''
::* 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)
class AddPreferenceEditFlagToUsers < ActiveRecord::Migration
     end
  def change
     redirect_to action: 'edit', id: @participant.id
     add_column :users, :preference_edit_flag, :boolean , :default => true
  end
end
</pre>
 
<pre>
class AddPreferenceHomeFlagToUsers < ActiveRecord::Migration
  def change
     add_column :users, :preference_home_flag, :boolean , :default => true
   end
   end
end
</pre>
</pre>


'''app/views/profile/edit.html.erb'''
<pre>
<pre>
def email_all_reviewers(participant)
  <%#added a new part in the front end for users to choose the options to see the assignment operations %>
    if participant.reviewers != []
  <%= render :partial => 'users/editpreference' %>
      participant.reviewers.each do |reviewer|
</pre>
        map = ReviewResponseMap.where(['reviewer_id = ? and reviewee_id = ?', reviewer.id, participant.team.id]).first
 
        responses = Response.where(:map_id => map.id)
 
        responses = responses.sort_by { |obj| obj.updated_at }
==Issue1430==
 
* Under the “General” tab of the assignment edit page, an instructor or a TA can change the course of an assignment.


        # the latest response will be the last
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.”.
        latest_response = responses.last


        # we need to pass the id of lastest_response in the URL mentioned in the mail.
'''app/helpers/assignment_helper.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)
====Before====
        instructor = User.find(user.parent_id)
<pre>
        bcc_mail_address = ""
module AssignmentHelper
        if instructor.copy_of_emails?
  def course_options(instructor)
          bcc_mail_address = instructor.email
    if session[:user].role.name == 'Teaching Assistant'
        else
      courses = []
          # do noting
      ta = Ta.find(session[:user].id)
        end
      ta.ta_mappings.each {|mapping| courses << Course.find(mapping.course_id) }
        if user.email_on_submission?
      # If a TA created some courses before, s/he can still add new assignments to these courses.
          MailerHelper.send_mail_to_reviewer(user,
      courses << Course.where(instructor_id: instructor.id)
                                            bcc_mail_address,
      courses.flatten!
                                            "You have a new submission to review",
    # Administrator and Super-Administrator can see all courses
                                            "update",
    elsif session[:user].role.name == 'Administrator' or session[:user].role.name == 'Super-Administrator'
                                            "Please visit https://expertiza.ncsu.edu/response/edit?id=#{latest_response.id} and proceed to peer reviews.").deliver
      courses = Course.all
        end
    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
     end
     end
  end
    options = []
</pre>
    options << ['-----------', nil]


 
    courses.each do |course|
'''app/helpers/mailer_helper.rb:'''
      options << [course.name, course.id]
<pre>
     end
def self.send_mail_to_reviewer(user, bcc_mail_address, subject, partial_name, note)
    Mailer.new_review_request_message ({
        to: user.email,
        bcc: bcc_mail_address,
        subject: subject,
        body: {
            user: user,
            first_name: ApplicationHelper.get_user_first_name(user),
            message: note,
            partial_name: partial_name
        }
     })
  end
</pre>
</pre>


'''app/views/mailer/new_review_message.html.erb:'''


====After====
<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>
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]


This message has been generated by <A HREF="http://expertiza.ncsu.edu">Expertiza</A><BR/>
http://expertiza.ncsu.edu


</body>
    courses.each do |course|
</html>
      options << [course.name, course.id]
    end
</pre>
</pre>


'''app/views/mailer/partials/update.html.html.erb:'''
'''app/views/assignments/edit.html.erb'''
 
<pre>
<pre>


Hi <%= @first_name %>,</br>
<li><a href="#tabs-8" id="Other">etc</a></li>
<p>
  One of the assignments you are reviewing has just been entered or revised.
  "<%= @message %>"
</p>
<br/>
</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