CSC/ECE 517 Fall 2019 - E1971. OSS project Finklestein: Instructors & Institutions: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(189 intermediate revisions by the same user not shown)
Line 1: Line 1:
=E1971. OSS project Finklestein: Instructors & Institutions=
=E1971. OSS project Finklestein: Instructors & Institutions=


[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows instructors to manager courses and assignments for students. Students can form up teams in Expertiza to work on different projects and assignments and do peer review about other students' submissions.


__TOC__
__TOC__


 
==Introduction==
===Brief Introduction===
   
   
* E1961 Project aims to fix the problems of making the email notification function more reliable.
* E1971 Project aims to fix the associations problems between the Institution and Instructor class.


* The forked git repository for this project can be found [https://github.com/YongjianZhu/expertiza YongjianZhu/expertiza.git]
* The forked git repository for this project can be found [https://github.com/YongjianZhu/expertiza Expertiza-E1971]


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


* 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.
* Task1: The institution list should be sorted alphabetically.
** Details: When creating a course, the drop-down list for selecting the institution does not show in alphabetical order.
  [[File:E1971-Task1.png]]


* Issue2: Fix the bugs to make Expertiza emails reviewers each time an author that they have reviewed submits new work.
* Task2: Adding a new institution during creation of an instructor profile.
** Details: The admin can attempt to create a new institution when creating a new instructor. But, after one types in the name of the institution & clicks create, it crashes.
  [[File:E1971-Task2.png]]


* Issue3: The instructor could get a Blind carbon copy every time.
* Task3: Listing of instructors should show their institutions on the same line as their new feature.
** Details: When listing users, there is currently no column to display the user’s associated institution.
  [[File:E1971-Task3.png]]


====Task1====
As the issue is the Institution drop-down list is not alphabetically sorted. We simply added a step of sort when the Institution list was retrieved from the Database.
'''Changed files:''' <font color="blue">_course.html.erb</font>
<font color="grey">'''''line3'''''</font> <%= select("course", "institutions_id", Institution.all<font color="green">.order(:name)</font>.collect{ |c| [ c.name, c.id] }) %>


====Task2====
The issue occurs when the admin trying to create a new instructor with a new institution name. To fix this problem, we added a function to create a new institution and a confirmation prompt to alert the admin.


====Issue1====
'''Changed files:''' <font color="blue">app/controllers/users_controller.rb</font>
<font color="grey">'''''116'''''</font>  # if the user name already exists, register the user by email address
<font color="grey">'''''117'''''</font>  check = User.find_by(name: params[:user][:name])
<font color="grey">'''''118'''''</font>  params[:user][:name] = params[:user][:email] unless check.nil?
<font color="green">'''''119'''''  if params[:user][:institution_id].empty?</font>
<font color="green">'''''120'''''    institution = Institution.find_or_create_by(name: params[:institution][:name])</font>
<font color="green">'''''121'''''    params[:user][:institution_id] = institution.id</font>
<font color="green">'''''122'''''  end</font>
<font color="grey">'''''123'''''</font>  @user = User.new(user_params)
<font color="grey">'''''124'''''</font>  @user.institution_id = params[:user][:institution_id]
-------------------------------------------------------------------------------------------------
<font color="grey">'''''142'''''</font>  else
<font color="grey">'''''143'''''</font>    foreign
<font color="green">'''''144'''''    flash[:error] = "Create Instructor Error!"</font>
<font color="green">'''''145'''''    render action: 'new'</font>
<font color="grey">'''''146'''''</font>  end


* 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
'''Changed files:''' <font color="blue">app/views/users/new.html.erb</font>
<pre>
app/controllers/response_controller.rb:
<font color="green">'''''8'''''  <ρ style="color: red; font-weight: bold">* Please Make Sure All Information is Correct</ρ></font>
<font color="grey">'''''9'''''</font>  <%= submit_tag "Create" %>


  def send_email_to_reviewee(map)
====Task3====
    defn = {body: {type: "Peer Review", partial_name: "new_submission"} }
The issue is that the user page is not displaying the user's associated institution. To fix this issue, we added an 'institution' column in the HTML file retrieving the institution names of each user.
    map.email(defn, Assignment.find(Participant.find(map.reviewer_id).parent_id))
'''Changed files:''' <font color="blue">app/models/user.rb</font>
  end
</pre>
<font color="green">'''''111'''''  def institution(ip_address = nil)
'''''112'''''    if User.anonymized_view?(ip_address)
'''''113'''''      self.role.name + ', ' + self.id.to_s
'''''114'''''    else
'''''115'''''      if self[:role_id] == 2
'''''116'''''        self[:institution_id].nil? ? "" : Institution.find(self[:institution_id]).name
'''''117'''''      end
'''''118'''''    end
'''''119'''''  end</font>


'''Changed files:''' <font color="blue">app/views/users/list.html.erb</font>
 
<font color="grey">'''''20'''''</font>  <tr>
<font color="grey">'''''21'''''</font>      <th class="head">Name</th>
<font color="grey">'''''22'''''</font>      <th class="head">Full Name</th>
<font color="green">'''''23'''''      <th class="head">Institution</th></font>
<font color="grey">'''''24'''''</font>      <th class="head">Email Address</th>
<font color="grey">'''''25'''''</font>      <th class="head">Role</th>
<font color="grey">'''''26'''''</font>      <th class="head">Parent</th>
<font color="grey">'''''27'''''</font>      <th class="head">Review</th>
<font color="grey">'''''28'''''</font>      <th class="head">Submission</th>
<font color="grey">'''''29'''''</font>      <th class="head">Metareview</th>
<font color="grey">'''''30'''''</font>  </tr>
<font color="grey">'''''31'''''</font>  <% for user in @users %>
<font color="grey">'''''32'''''</font>    <% if ((params[:show] != 'true' && !user.name(session[:ip]).include?("_hidden")) || params[:show] == 'true')%>
<font color="grey">'''''33'''''</font>      <tr class="exp">
<font color="grey">'''''34'''''</font>        <td><%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post %></td>
<font color="grey">'''''35'''''</font>        <td><%= link_to user.fullname(session[:ip]), :controller=> 'users', :action => 'show', :id => user.id %></td>
<font color="green">'''''36'''''        <td><%= user.institution(session[:ip]) %></td></font>
<font color="grey">'''''37'''''</font>        <td><%= user.email(session[:ip]) %></td>
<font color="grey">'''''38'''''</font>        <td><%= link_to user.role.name, :controller => 'roles', :action => 'show', :id => user.role.id %></td>
<font color="grey">'''''39'''''</font>        <td align="center"><%= user.parent.try :name %></td>
<font color="grey">'''''40'''''</font>        <td><%= User.yesorno(user.email_on_review) %></td>
<font color="grey">'''''41'''''</font>        <td><%= User.yesorno(user.email_on_submission) %></td>
<font color="grey">'''''42'''''</font>        <td><%= User.yesorno(user.email_on_review_of_review) %></td>
<font color="grey">'''''43'''''</font>      </tr>
<font color="grey">'''''44'''''</font>    <% end %>
<font color="grey">'''''45'''''</font>  <% end -%>


====Issue2====
==Task Demonstration==
====Task1====
[[File:Task1-new.png]]
====Task2====
[[File:Task2-new.png]]
[[File:Task2-2-new.png]]


* Add new function to email all reviewers a new submission is ready to review:
====Task3====
::* In the first round, there is no reviewer before they take a request
[[File:Task2-2-new.png]]
::* ...........................................................
::* ...........................................................


'''app/controllers/submitted_content_controller.rb:'''
==Test==
<pre>
====Test for Task1====
email_all_reviewers(@participant)
We created 4 institutions and check if they are alphabetically sorted in the selection box
    end
  '''Changed files:''' <font color="blue">spec/features/course_creation_spec.rb</font>
    redirect_to action: 'edit', id: @participant.id
   end
  <font color="green">'''''13'''''  it "check if the courses are sorted alphabetically" do
</pre>
  '''''14'''''    create(:superadmin, name: 'super_administrator2')
  '''''15'''''   login_as('super_administrator2')
  '''''16'''''    visit "/course/new?private=1"
  '''''17'''''    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[1]").text).to eq("A")
  '''''18'''''    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[2]").text).to eq("B")
  '''''19'''''   expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[3]").text).to eq("C")
  '''''20'''''    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[4]").text).to eq("D")
   '''''21'''''  end</font>


<pre>
====Test for Task2====
def email_all_reviewers(participant)
We tried to create a new instructor6 with a new institution name
    if participant.reviewers != []
  '''Changed files:''' <font color="blue">spec/controllers/users_controller_spec.rb</font>
      participant.reviewers.each do |reviewer|
        map = ReviewResponseMap.where(['reviewer_id = ? and reviewee_id = ?', reviewer.id, participant.team.id]).first
  <font color="green">'''''233'''''  it 'save successfully with a new institution' do
        responses = Response.where(:map_id => map.id)
  '''''234'''''    session = {user: admin}
        responses = responses.sort_by { |obj| obj.updated_at }
  '''''235'''''    params = {
  '''''236'''''      user: {name: 'instructor6',
  '''''237'''''            crypted_password: 'password',
  '''''238'''''            role_id: 2,
  '''''239'''''            password_salt: 1,
  '''''240'''''            fullname: '6, instructor',
  '''''241'''''            email: 'yzhu48@ncsu.edu',
  '''''242'''''            parent_id: 1,
  '''''243'''''            private_by_default: false,
  '''''244'''''            mru_directory_path: nil,
  '''''245'''''            email_on_review: true,
  '''''246'''''            email_on_submission: true,
  '''''247'''''            email_on_review_of_review: true,
  '''''248'''''            is_new_user: false,
  '''''249'''''            master_permission_granted: 0,
  '''''250'''''            handle: 'handle',
  '''''251'''''            digital_certificate: nil,
  '''''252'''''            timezonepref: 'Eastern Time (US & Canada)',
  '''''253'''''            public_key: nil,
  '''''254'''''            copy_of_emails: nil,
  '''''255'''''            institution_id: 666,
  '''''256'''''            institution: {
  '''''257'''''                name: 'yzhu48'
  '''''258'''''            }
  '''''259'''''      }
  '''''260'''''    } 
  '''''261'''''   post :create, params, session
  '''''262'''''    allow_any_instance_of(User).to receive(:undo_link).with('The user "instructor6" has been successfully created. ').and_return(true)
  '''''263'''''    expect(flash[:success]).to eq "A new password has been sent to new user's e-mail address."
  '''''264'''''    expect(response).to redirect_to('http://test.host/users/list')
  '''''265'''''  end


        # the latest response will be the last
====Test for Task3====
        latest_response = responses.last
We tested if the Institution column was on the page
 
  '''Changed files:''' <font color="blue">spec/controllers/users_controller_spec.rb</font>
        # we need to pass the id of lastest_response in the URL mentioned in the mail.
        # this will open the correct /response/edit?id=#{latest_response.id} page for the reviewer when (s)he clicks on it.
   <font color="green">'''''18'''''  it "check if instructors show their institutions on the same line as their new feature" do
 
  '''''19'''''   create(:superadmin, name: 'super_administrator2')
        user = User.find(reviewer.user_id)
   '''''20'''''    login_as('super_administrator2')
        instructor = User.find(user.parent_id)
   '''''21'''''   visit "/users/list"
        bcc_mail_address = ""
  '''''22'''''   expect(page.has_content?("Institution")).to eq(true)
        if instructor.copy_of_emails?
  '''''23''''' end</font>
          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
</pre>
 
 
'''app/helpers/mailer_helper.rb:'''
<pre>
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>
 
'''app/views/mailer/new_review_message.html.erb:'''
 
<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>
 
This message has been generated by <A HREF="http://expertiza.ncsu.edu">Expertiza</A><BR/>
http://expertiza.ncsu.edu
 
</body>
</html>
</pre>
 
'''app/views/mailer/partials/update.html.html.erb:'''
 
<pre>
 
Hi <%= @first_name %>,</br>
<p>
  One of the assignments you are reviewing has just been entered or revised.
  "<%= @message %>"
</p>
<br/>
</pre>
 
====Issue3====
* ...........................................................................................
'''app/controllers/submitted_content_controller.rb:'''
<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>
bcc: bcc_mail_address,
</pre>


====Issue4====
==Process Video==
* ...........................................................................................
Video Demonstration for Testing Task1: [https://youtu.be/FXQu1fcbM20 Task1-Video]
'''app/views/users/_prefs.html.erb:'''
Video Demonstration for Testing Task2: [https://youtu.be/3BIsI2UpNRo Task2-Video]
* previous version:
Video Demonstration for Testing Task3: [https://youtu.be/ZmLfvYLmLTo Task3-Video]


<pre>
==Project Deployment==
<td><label for="user_email_on_review">When someone else <strong>reviews</strong> my work</label></td>
[http://152.46.17.133:8080/ Expertiza_Team_4430]
            <td><%= check_box 'user', 'email_on_review', {},  true, false  %></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', {},  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>


* correct version:
==Team Information==
<pre>
  '''Team_4430:'''
<tr>
  Ruiwen Wu (rwu5@ncsu.edu)
            <td><label for="user_email_on_review">When someone else <strong>reviews</strong> my work</label></td>
  Yongjian Zhu (yzhu48@ncsu.edu)
            <td><%= check_box 'user', 'email_on_review'  %></td>
  Ling Li (lli46@ncsu.edu)
          </tr>
  '''Mentor:''' Carmen Bentley (cnaiken@ncsu.edu)
          <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>


===Process Video===
==References==


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


===Test===
[http://expertiza.ncsu.edu/ Expertiza website]


===Team Information===
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]
#Siwei Wen (swen4@ncsu.edu)
#Shuzheng Wang (swang41@ncsu.edu)
#Zhifeng Zhu (zzhu25@ncsu.edu)
#'''Mentor:''' Ed Gehringer (efg@ncsu.edu)


===References===
[https://github.com/YongjianZhu/expertiza GitHub Project Repository Fork]


#[https://github.com/expertiza/expertiza Expertiza on GitHub]
[https://relishapp.com/rspec Rspec Documentation]
#[http://expertiza.ncsu.edu/ The live Expertiza website]
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]
#[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]
#[http://bit.ly/myexpertiza  Demo link]
#[https://relishapp.com/rspec Rspec Documentation]

Latest revision as of 20:45, 30 October 2019

E1971. OSS project Finklestein: Instructors & Institutions

Expertiza is an open-source project based on Ruby on Rails framework. Expertiza allows instructors to manager courses and assignments for students. Students can form up teams in Expertiza to work on different projects and assignments and do peer review about other students' submissions.

Introduction

  • E1971 Project aims to fix the associations problems between the Institution and Instructor class.

Problem Statement

The following tasks were accomplished in E1971 project:

  • Task1: The institution list should be sorted alphabetically.
    • Details: When creating a course, the drop-down list for selecting the institution does not show in alphabetical order.
 
  • Task2: Adding a new institution during creation of an instructor profile.
    • Details: The admin can attempt to create a new institution when creating a new instructor. But, after one types in the name of the institution & clicks create, it crashes.
 
  • Task3: Listing of instructors should show their institutions on the same line as their new feature.
    • Details: When listing users, there is currently no column to display the user’s associated institution.
 

Task1

As the issue is the Institution drop-down list is not alphabetically sorted. We simply added a step of sort when the Institution list was retrieved from the Database.

Changed files: _course.html.erb

line3 <%= select("course", "institutions_id", Institution.all.order(:name).collect{ |c| [ c.name, c.id] }) %>

Task2

The issue occurs when the admin trying to create a new instructor with a new institution name. To fix this problem, we added a function to create a new institution and a confirmation prompt to alert the admin.

Changed files: app/controllers/users_controller.rb

116  # if the user name already exists, register the user by email address
117  check = User.find_by(name: params[:user][:name])
118  params[:user][:name] = params[:user][:email] unless check.nil?
119  if params[:user][:institution_id].empty?
120    institution = Institution.find_or_create_by(name: params[:institution][:name])
121    params[:user][:institution_id] = institution.id
122  end
123  @user = User.new(user_params)
124  @user.institution_id = params[:user][:institution_id]
-------------------------------------------------------------------------------------------------
142  else
143    foreign
144    flash[:error] = "Create Instructor Error!"
145    render action: 'new'
146  end
Changed files: app/views/users/new.html.erb

8  <ρ style="color: red; font-weight: bold">* Please Make Sure All Information is Correct</ρ>
9  <%= submit_tag "Create" %>

Task3

The issue is that the user page is not displaying the user's associated institution. To fix this issue, we added an 'institution' column in the HTML file retrieving the institution names of each user.

Changed files: app/models/user.rb

111  def institution(ip_address = nil)
112    if User.anonymized_view?(ip_address)
113      self.role.name + ', ' + self.id.to_s
114    else
115      if self[:role_id] == 2
116        self[:institution_id].nil? ? "" : Institution.find(self[:institution_id]).name
117      end
118    end
119  end
Changed files: app/views/users/list.html.erb
 

20 21 Name 22 Full Name 23 Institution 24 Email Address 25 Role 26 Parent 27 Review 28 Submission 29 Metareview 30 31 <% for user in @users %> 32 <% if ((params[:show] != 'true' && !user.name(session[:ip]).include?("_hidden")) || params[:show] == 'true')%> 33 34 <%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post %> 35 <%= link_to user.fullname(session[:ip]), :controller=> 'users', :action => 'show', :id => user.id %> 36 <%= user.institution(session[:ip]) %> 37 <%= user.email(session[:ip]) %> 38 <%= link_to user.role.name, :controller => 'roles', :action => 'show', :id => user.role.id %> 39 <%= user.parent.try :name %> 40 <%= User.yesorno(user.email_on_review) %> 41 <%= User.yesorno(user.email_on_submission) %> 42 <%= User.yesorno(user.email_on_review_of_review) %> 43 44 <% end %> 45 <% end -%>

Task Demonstration

Task1


Task2



Task3


Test

Test for Task1

We created 4 institutions and check if they are alphabetically sorted in the selection box

 Changed files: spec/features/course_creation_spec.rb

 13  it "check if the courses are sorted alphabetically" do
 14    create(:superadmin, name: 'super_administrator2')
 15    login_as('super_administrator2')
 16    visit "/course/new?private=1"
 17    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[1]").text).to eq("A")
 18    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[2]").text).to eq("B")
 19    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[3]").text).to eq("C")
 20    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[4]").text).to eq("D")
 21  end

Test for Task2

We tried to create a new instructor6 with a new institution name
 Changed files: spec/controllers/users_controller_spec.rb

 233  it 'save successfully with a new institution' do
 234    session = {user: admin}
 235    params = {
 236      user: {name: 'instructor6',
 237             crypted_password: 'password',
 238             role_id: 2,
 239             password_salt: 1,
 240             fullname: '6, instructor',
 241             email: 'yzhu48@ncsu.edu',
 242             parent_id: 1,
 243             private_by_default: false,
 244             mru_directory_path: nil,
 245             email_on_review: true,
 246             email_on_submission: true,
 247             email_on_review_of_review: true,
 248             is_new_user: false,
 249             master_permission_granted: 0,
 250             handle: 'handle',
 251             digital_certificate: nil,
 252             timezonepref: 'Eastern Time (US & Canada)',
 253             public_key: nil,
 254             copy_of_emails: nil,
 255             institution_id: 666,
 256             institution: {
 257                 name: 'yzhu48'
 258             }
 259       }
 260    }  
 261    post :create, params, session
 262    allow_any_instance_of(User).to receive(:undo_link).with('The user "instructor6" has been successfully created. ').and_return(true)
 263    expect(flash[:success]).to eq "A new password has been sent to new user's e-mail address."
 264    expect(response).to redirect_to('http://test.host/users/list')
 265  end

Test for Task3

We tested if the Institution column was on the page
 Changed files: spec/controllers/users_controller_spec.rb

 18  it "check if instructors show their institutions on the same line as their new feature" do
 19    create(:superadmin, name: 'super_administrator2')
 20    login_as('super_administrator2')
 21    visit "/users/list"
 22    expect(page.has_content?("Institution")).to eq(true)
 23  end

Process Video

Video Demonstration for Testing Task1: Task1-Video
Video Demonstration for Testing Task2: Task2-Video
Video Demonstration for Testing Task3: Task3-Video

Project Deployment

Expertiza_Team_4430

Team Information

 Team_4430:
 Ruiwen Wu (rwu5@ncsu.edu)
 Yongjian Zhu (yzhu48@ncsu.edu)
 Ling Li (lli46@ncsu.edu)
 Mentor: Carmen Bentley (cnaiken@ncsu.edu)

References

Expertiza on GitHub

Expertiza website

Expertiza project documentation wiki

GitHub Project Repository Fork

Rspec Documentation