<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mguo6</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mguo6"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Mguo6"/>
	<updated>2026-08-23T19:38:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142692</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142692"/>
		<updated>2021-12-01T22:09:23Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;github_metric_uses&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: github_metric_uses'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The GithubMetricUsesController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_github_use' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;github_use&amp;quot; id=&amp;quot;github_use&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if GithubMetricUsesController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('github_use', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if GithubMetricUsesController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#github_use').change(function () {&lt;br /&gt;
            if (jQuery('#github_use').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/github_metric_uses/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/github_metric_uses/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\github_metric_uses_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table github_metric_uses. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table github_metric_uses&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
     github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
     !github_use.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table github_metric_uses, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table github_metric_uses, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
     unless exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.new(assignment_id)&lt;br /&gt;
       github_use.assignment_id = assignment_id&lt;br /&gt;
       github_use.save&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  #if assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
     if exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
       github_use.destroy&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table github_metric_uses&lt;br /&gt;
  def exist&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table github_metric_uses, save it&lt;br /&gt;
  def save&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.save(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.delete(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
The details are in the Test Plan [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations#Test_Plan].&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
Assignments could be edited on the assignment viewing page. Also, the submissions would be showed and there would be differences when &amp;quot;Github metrics&amp;quot; is chosen or is not chosen.&lt;br /&gt;
&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142691</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142691"/>
		<updated>2021-12-01T21:55:26Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Database Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;github_metric_uses&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: github_metric_uses'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The GithubMetricUsesController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if GithubMetricUsesController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if GithubMetricUsesController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/github_metric_uses/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/github_metric_uses/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\github_metric_uses_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table github_metric_uses. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table github_metric_uses&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
     github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
     !github_use.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table github_metric_uses, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table github_metric_uses, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
     unless exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.new(assignment_id)&lt;br /&gt;
       github_use.assignment_id = assignment_id&lt;br /&gt;
       github_use.save&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  #if assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
     if exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
       github_use.destroy&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table github_metric_uses&lt;br /&gt;
  def exist&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table github_metric_uses, save it&lt;br /&gt;
  def save&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.save(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.delete(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
The details are in the Test Plan [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations#Test_Plan].&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
Assignments could be edited on the assignment viewing page. Also, the submissions would be showed and there would be differences when &amp;quot;Github metrics&amp;quot; is chosen or is not chosen.&lt;br /&gt;
&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142690</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142690"/>
		<updated>2021-12-01T21:51:06Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The GithubMetricUsesController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if GithubMetricUsesController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if GithubMetricUsesController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/github_metric_uses/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/github_metric_uses/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\github_metric_uses_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table github_metric_uses. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table github_metric_uses&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
     github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
     !github_use.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table github_metric_uses, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table github_metric_uses, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
     unless exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.new(assignment_id)&lt;br /&gt;
       github_use.assignment_id = assignment_id&lt;br /&gt;
       github_use.save&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  #if assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
     if exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
       github_use.destroy&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table github_metric_uses&lt;br /&gt;
  def exist&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table github_metric_uses, save it&lt;br /&gt;
  def save&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.save(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table github_metric_uses, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.delete(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
The details are in the Test Plan [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations#Test_Plan].&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
Assignments could be edited on the assignment viewing page. Also, the submissions would be showed and there would be differences when &amp;quot;Github metrics&amp;quot; is chosen or is not chosen.&lt;br /&gt;
&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142689</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142689"/>
		<updated>2021-12-01T21:48:43Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The GithubMetricUsesController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if GithubMetricUsesController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if GithubMetricUsesController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
     github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
     !github_use.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
     unless exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.new(assignment_id)&lt;br /&gt;
       github_use.assignment_id = assignment_id&lt;br /&gt;
       github_use.save&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
     if exist(assignment_id)&lt;br /&gt;
       github_use = GithubMetricUses.find_by(assignment_id: assignment_id)&lt;br /&gt;
       github_use.destroy&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.save(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
     assignment_id = params[:assignment_id]&lt;br /&gt;
     GithubMetricUsesController.delete(assignment_id)&lt;br /&gt;
     respond_to do |format|&lt;br /&gt;
       format.json { render json: assignment_id }&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
The details are in the Test Plan [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations#Test_Plan].&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
Assignments could be edited on the assignment viewing page. Also, the submissions would be showed and there would be differences when &amp;quot;Github metrics&amp;quot; is chosen or is not chosen.&lt;br /&gt;
&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142688</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142688"/>
		<updated>2021-12-01T21:31:29Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Functionality Walk Through */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
The details are in the Test Plan [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations#Test_Plan].&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
Assignments could be edited on the assignment viewing page. Also, the submissions would be showed and there would be differences when &amp;quot;Github metrics&amp;quot; is chosen or is not chosen.&lt;br /&gt;
&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142687</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142687"/>
		<updated>2021-12-01T21:12:00Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
The details are in the Test Plan [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations#Test_Plan].&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142685</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142685"/>
		<updated>2021-12-01T20:38:13Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
Testing part Includes UI Testing and Rspec. Our UI tests aim to capture the following core pieces of functionality. Detailed of Using Github Testing first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142684</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142684"/>
		<updated>2021-12-01T20:37:51Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
Testing part Includes UI Testing and Rspec. Our UI tests aim to capture the following core pieces of functionality.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142683</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142683"/>
		<updated>2021-12-01T20:36:49Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
Testing part Includes UI Testing and Rspec.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142682</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142682"/>
		<updated>2021-12-01T20:35:50Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. We will some RSpec test code to test the function.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn off option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the class method in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses the instance method in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Class Methods =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Instance Methods =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment id if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
The Github API requires users to be authenticated to query the API. Since GitHub no longer supports authentication through query parameters, we move the authentication to the header. From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and communication between the Expertiza server and Github, and using client_id/client_secret to make OAuth app unauthenticated are disabled.&lt;br /&gt;
&lt;br /&gt;
The callback URL (the URL of the Expertiza server) is set within Github.com, where the OAuth app is configured (and Client Keys/Secrets are generated). The code from the previous project uses Client Key/Secret pairs that are tied to a Github OAuth app that is configured to callback to http://localhost:3000/auth/github/callback. Naturally, when Expertiza is running in a production environment, or a deployment on a remote server where the client is not on the localhost, this callback will fail to redirect.&lt;br /&gt;
&lt;br /&gt;
Therefore, we create a new OAuth app using a Github.com account that configures a callback URL to http://server_ip_or_url:port/auth/github2021/callback/. The production callback URL is: https://expertiza.ncsu.edu/auth/github2021/callback. The reason &amp;quot;github2021&amp;quot; is used for this project is due to Github's 2021 updates to their security infrastructure -- our code handles &amp;quot;github&amp;quot; and &amp;quot;github2021&amp;quot; callbacks differently to match these security updates.&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to  github https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Move the authentication to the header&lt;br /&gt;
  def query_commit_statistics(data)&lt;br /&gt;
    uri = URI.parse(&amp;quot;https://api.github.com/graphql&amp;quot;)&lt;br /&gt;
    http = Net::HTTP.new(uri.host, uri.port) # host: api.github.com, port: 443&lt;br /&gt;
    http.use_ssl = true&lt;br /&gt;
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER&lt;br /&gt;
    # request = Net::HTTP::Post.new(uri.path, 'Authorization' =&amp;gt; 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]) # set up authorization&lt;br /&gt;
    request = Net::HTTP::Post.new(uri.path) # set up authorization&lt;br /&gt;
    # send the token in the header&lt;br /&gt;
    request['Authorization'] = 'Bearer' + ' ' + session[&amp;quot;github_access_token&amp;quot;]&lt;br /&gt;
    request.body = data.to_json # convert query message to json and pass as request body&lt;br /&gt;
    response = http.request(request) # make the actual request&lt;br /&gt;
    ActiveSupport::JSON.decode(response.body.to_s) # convert the response body to string, decoded then return&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn off functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Using Github Testing&lt;br /&gt;
first, go to the assignment edit page and check the checkbox of use github metric, then go to the list submission page check the page if has the content about ithub data.&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;check the box of the use github metrics? and the list_submissions page will have the content 'Github data'  &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
    	check('Use github metrics?', allow_label_click: true)&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it &amp;quot;uncheck the checkbox of the use github metrics? and the list_submissions page will not have the content 'Github data' &amp;quot; do&lt;br /&gt;
         visit &amp;quot;/assignments/#{@assignment.id}/edit&amp;quot;&lt;br /&gt;
         check('Use github metrics?', allow_label_click: false)&lt;br /&gt;
         page.uncheck('Use github metrics?')&lt;br /&gt;
         visit &amp;quot;/assignments/list_submissions?id=#{@assignment.id}&amp;quot;&lt;br /&gt;
         expect(page).to have_no_content(&amp;quot;Github data&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/2158 Pull Request Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=8BveAT6ourQ&amp;amp;t=80s demo video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=UiPNnQdWPqo test video Of E2149]&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142567</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142567"/>
		<updated>2021-11-30T22:50:07Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Not Self Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the self function in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses not self functions in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Not Self Functions =====&lt;br /&gt;
URL in frontend uses such functions.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142566</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142566"/>
		<updated>2021-11-30T22:49:40Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the self function in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Post the assignment id if the user selects the 'check' button and delete the data if the user cancels it by url. The function uses not self functions in controller. &lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Not Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142565</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142565"/>
		<updated>2021-11-30T22:44:19Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the self function in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3.&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Not Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142564</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142564"/>
		<updated>2021-11-30T22:43:59Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics. The UseGithubMetricsController.exist use the self function in the controller. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3.&lt;br /&gt;
&lt;br /&gt;
 jQuery(document).ready(function () {&lt;br /&gt;
        // This function determines whether the 'Topics' tab must be displayed when the page is re-loaded&lt;br /&gt;
        var checkbox = jQuery('#assignment_has_topics');&lt;br /&gt;
        if (checkbox.is(':checked')) {&lt;br /&gt;
            // If this checkbox is checked, show the 'Topics' tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).show();&lt;br /&gt;
        } else {&lt;br /&gt;
            // Otherwise, hide topics tab&lt;br /&gt;
            jQuery(&amp;quot;#topics_tab_header&amp;quot;).hide();&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        $('#use_github').change(function () {&lt;br /&gt;
            if (jQuery('#use_github').is(':checked')) {&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'POST',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            } else{&lt;br /&gt;
                jQuery.ajax({&lt;br /&gt;
                    url: '/use_github_metrics/' + &amp;lt;%= @assignment.id %&amp;gt;,&lt;br /&gt;
                    method: 'DELETE',&lt;br /&gt;
                    xhrFields: {&lt;br /&gt;
                        withCredentials: true&lt;br /&gt;
                    },&lt;br /&gt;
                    dataType: 'json'&lt;br /&gt;
                })&lt;br /&gt;
            }&lt;br /&gt;
        })&lt;br /&gt;
    });&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Not Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GitHub's OAuth implementation &lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #Use Oauth protocols to attempt to authorize user for either google or github&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After requesting the user's GitHub identity,  the user will be redirected back to Expertiza by GitHub. If the user accepts the request, GitHub redirects back to expertiza with a temporary code in a code parameter and the state provided in the previous step in a state parameter. The client_id and client_secret are required as they received from GitHub for Expertiza. The code is also required as it would be a response to the request. Then the access token allows Expertiza to make requests to the API on a behalf of a user.&lt;br /&gt;
&lt;br /&gt;
  #Login functionality for Github to get access_token&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142545</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142545"/>
		<updated>2021-11-30T22:16:49Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Self Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Check if assignment_id exists in the table use_github_metrics. If so, return TRUE.&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. If assignment_id does not exist in the table use_github_metrics, save it.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. If assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Not Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
[[File:github-oauth.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142538</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142538"/>
		<updated>2021-11-30T22:13:55Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Controller Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== Self Functions =====&lt;br /&gt;
&lt;br /&gt;
 #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def self.exist(assignment_id)&lt;br /&gt;
    use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
    !use_github.nil?&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def self.save(assignment_id)&lt;br /&gt;
    unless exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.new(assignment_id)&lt;br /&gt;
      use_github.assignment_id = assignment_id&lt;br /&gt;
      use_github.save&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def self.delete(assignment_id)&lt;br /&gt;
    if exist(assignment_id)&lt;br /&gt;
      use_github = UseGithubMetric.find_by(assignment_id: assignment_id)&lt;br /&gt;
      use_github.destroy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===== Not Self Functions =====&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def custom_github_login&lt;br /&gt;
    session_code = request.env['rack.request.query_hash']['code']&lt;br /&gt;
    result = RestClient.post('https://github.com/login/oauth/access_token',&lt;br /&gt;
                               {:client_id =&amp;gt; GITHUB_CONFIG['client_key'],&lt;br /&gt;
                                :client_secret =&amp;gt; GITHUB_CONFIG['client_secret'],&lt;br /&gt;
                                :code =&amp;gt; session_code},&lt;br /&gt;
                                :accept =&amp;gt; :json)&lt;br /&gt;
    access_token = JSON.parse(result)['access_token']&lt;br /&gt;
    session[&amp;quot;github_access_token&amp;quot;] = access_token&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'list_submissions', id: session[&amp;quot;assignment_id&amp;quot;]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142533</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142533"/>
		<updated>2021-11-30T22:12:39Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Controller Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
===== self functions =====&lt;br /&gt;
&lt;br /&gt;
===== not self functions =====&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
  def oauth_login&lt;br /&gt;
    case params[:provider]&lt;br /&gt;
    when &amp;quot;github&amp;quot;&lt;br /&gt;
      github_login&lt;br /&gt;
    when &amp;quot;google_oauth2&amp;quot;&lt;br /&gt;
      google_login&lt;br /&gt;
    when &amp;quot;github2021&amp;quot; # due to github 0&lt;br /&gt;
      custom_github_login&lt;br /&gt;
    else&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, &amp;quot;Invalid OAuth Provider&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142515</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142515"/>
		<updated>2021-11-30T21:53:47Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142514</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142514"/>
		<updated>2021-11-30T21:53:29Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
1. We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
If the id of the assignment exists, there will be a checkbox for the user to use github metrics.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
If the id of the assignment exists and github_access_token is null (it means that the user hasn't logged in), then the page will show 'Login to Query Github data' button. If github_access_token is not null, it would show 'Refresh Github data' button because the user has logged in.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142503</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142503"/>
		<updated>2021-11-30T21:28:03Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Controller Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist. This function is for the frontend page to select the checkbox.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists. This function is for the frontend page to cancel the checkbox.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142502</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142502"/>
		<updated>2021-11-30T21:26:43Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Controller Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
1. Return TRUE if the assignment id exists. &lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2. Save assignment is if it doesn't exist.&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. Delete assignment id if it exists.&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142497</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142497"/>
		<updated>2021-11-30T21:22:11Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Controller Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
  #check if assignment_id exists in the table use_github_metrics&lt;br /&gt;
  def exist&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.exist(assignment_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  #if assignment_id does not exist in the table use_github_metrics, save it&lt;br /&gt;
  def save&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.save(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  #if assignment_id exists in the table use_github_metrics, delete it&lt;br /&gt;
  def delete&lt;br /&gt;
    assignment_id = params[:assignment_id]&lt;br /&gt;
    UseGithubMetricsController.delete(assignment_id)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.json { render json: assignment_id }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142488</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142488"/>
		<updated>2021-11-30T21:10:57Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Controller Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
We added a function in expertiza\app\controllers\use_github_metrics_controller.rb as follwowing.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;% if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt; img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142482</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142482"/>
		<updated>2021-11-30T20:51:54Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                       :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142481</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142481"/>
		<updated>2021-11-30T20:51:20Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
                                                                                                                                        :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142480</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142480"/>
		<updated>2021-11-30T20:50:45Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, &lt;br /&gt;
          :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142479</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142479"/>
		<updated>2021-11-30T20:50:11Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. If the id of the assignment exists, then &lt;br /&gt;
The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
             if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expertiza\app\views\assignments\list_submissions.html.erb is edited too. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%if UseGithubMetricsController.exist(@assignment.id) %&amp;gt;&lt;br /&gt;
 &amp;lt;% if session[&amp;quot;github_access_token&amp;quot;].nil? %&amp;gt;&lt;br /&gt;
   &amp;lt;% topic_identifier, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@teams.first) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to 'Login to Query Github data', { controller: 'metrics', action: 'show', id: participants.first.id } %&amp;gt;&lt;br /&gt;
   &amp;lt;% else %&amp;gt;&lt;br /&gt;
 &amp;lt;%= link_to 'Refresh Github data', { controller: 'metrics', action: 'query_assignment_statistics', id: @assignment.id}, :onclick =&amp;gt; &amp;quot;showLoadIcon()&amp;quot;%&amp;gt;&lt;br /&gt;
   &amp;lt;img id=&amp;quot;load_icon&amp;quot; src=&amp;quot;&amp;lt;%= image_url('ajax-loader.gif') %&amp;gt;&amp;quot; style=&amp;quot;display:none&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;% end %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142472</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142472"/>
		<updated>2021-11-30T20:42:53Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; &lt;br /&gt;
      if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142469</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142469"/>
		<updated>2021-11-30T20:40:10Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142468</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=142468"/>
		<updated>2021-11-30T20:39:27Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Frontend Modification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method. &lt;br /&gt;
&lt;br /&gt;
The last edition uses the lots of Google API to help generate the chart, we can use the method from helper to generate charts instead.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
&lt;br /&gt;
We edited expertiza\app\views\assignments\edit\_general.html.erb and added a checkbox. The codes are as follow.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;!--Github--&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td style='padding:5px' id='assignment_use_github' colspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;checkbox&amp;quot; name = &amp;quot;use_github&amp;quot; id=&amp;quot;use_github&amp;quot; &amp;lt;%= &amp;quot;checked&amp;quot; if UseGithubMetricsController.exist(@assignment_form.assignment.id) %&amp;gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;%= label_tag('use_github', 'Use github metrics?') %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141458</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141458"/>
		<updated>2021-11-09T04:16:32Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Clarify the Codes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Simplify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141455</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141455"/>
		<updated>2021-11-09T04:08:34Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Team Action Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Clarify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we could use this method.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141454</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141454"/>
		<updated>2021-11-09T04:08:01Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Team Action Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Clarify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we will use this method.&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141452</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141452"/>
		<updated>2021-11-09T04:07:30Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Team Action Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of the lack of support from the current API. It adds quite a lot of lines of code for a single project and some codes could be refactored. The test plans of the current project are not described thoroughly enough. We will modify the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have found numerous action items so far. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves&amp;quot; or features that are either left out of the original project or will make the integration display more integrated.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment whose GitHub metric is turned on. We also have an alternative solution to add a boolean field in the assignment table, but due to security concerns, we give it up. We think we should not change the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
==== Clarify the Codes ====&lt;br /&gt;
Extract the repeating part of codes and then construct an independent method based on them. Finally, we will use this method.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chooses not to include the GitHub metric in the assignment (the functionality is turned off), the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed on the frontend page.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to query and update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
this function will check whether the assignment_id is in the use_github_metric table. If not exist, the Github metric will be turned off. Otherwise, it will be turned on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
this function will update the status of using the Github metric of assignment and flashes a notice. If the metric is turned on, we will add the assignment_id to the table use_github_metric. If it is turned off, we will delete the assignment_id from the table.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
An instructor can customize an assignment in this view. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they choose Github metrics in the previous assignment edit page and is not authenticated to Github yet. The Login link redirects to an omniauth login page, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose the &amp;quot;use GitHub metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
This UML shows the new classes and models we created and implemented in our final project. Besides these, we also modified some of the existing classes and methods, we will give more detailed information later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication to the header.&lt;br /&gt;
From September 8, 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) and using client_id/client_secret to make OAuth app unauthenticated are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code uses the API with parameters。&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down option for Github metric on the page&lt;br /&gt;
:4. Process the page without choosing Github metrics report  for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
&lt;br /&gt;
After changing the way of calling the GitHub API, we need to test whether we can get the data from the GitHub API correctly.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141359</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141359"/>
		<updated>2021-11-09T01:31:00Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* OSS Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2156._Issues_related_to_meta-reviewing#Description_about_project CSC/ECE 517 Fall 2021 - E2156. Issues related to meta-reviewing]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2169. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
* [[E2157. Fix issues related to deadlines and late policies]]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141358</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141358"/>
		<updated>2021-11-09T01:29:17Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2156._Issues_related_to_meta-reviewing#Description_about_project CSC/ECE 517 Fall 2021 - E2156. Issues related to meta-reviewing]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2169. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
* [[E2157. Fix issues related to deadlines and late policies]]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141351</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141351"/>
		<updated>2021-11-09T01:02:10Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Adding turn on and turn down option */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric. We also have an alternative solution to add the boolean field in the assignment table, but for security concerns, we give it up we should not influence the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to help update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
the function will search the assignment_id in the use_github_metric table. If not exist, the Github metric will turn off. Otherwise, it will turn on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
the function will update the status of using the Github metric of assignment and flashes a notice. if turn on the metric, we will add the assignment_id to the table use_github_metric. If turn off we will delete the data.&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
After the change of call GitHub API, we need to test get data from the GitHub API.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141350</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141350"/>
		<updated>2021-11-09T01:01:52Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Final Design UML */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric. We also have an alternative solution to add the boolean field in the assignment table, but for security concerns, we give it up we should not influence the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to help update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
the function will search the assignment_id in the use_github_metric table. If not exist, the Github metric will turn off. Otherwise, it will turn on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
the function will update the status of using the Github metric of assignment and flashes a notice. if turn on the metric, we will add the assignment_id to the table use_github_metric. If turn off we will delete the data.&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
After the change of call GitHub API, we need to test get data from the GitHub API.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141349</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141349"/>
		<updated>2021-11-09T01:01:35Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Final Design UML */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric. We also have an alternative solution to add the boolean field in the assignment table, but for security concerns, we give it up we should not influence the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to help update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
the function will search the assignment_id in the use_github_metric table. If not exist, the Github metric will turn off. Otherwise, it will turn on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
the function will update the status of using the Github metric of assignment and flashes a notice. if turn on the metric, we will add the assignment_id to the table use_github_metric. If turn off we will delete the data.&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
[[File:E2149_Uml_1.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
After the change of call GitHub API, we need to test get data from the GitHub API.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141348</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141348"/>
		<updated>2021-11-09T01:01:23Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Final Design UML */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric. We also have an alternative solution to add the boolean field in the assignment table, but for security concerns, we give it up we should not influence the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to help update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
the function will search the assignment_id in the use_github_metric table. If not exist, the Github metric will turn off. Otherwise, it will turn on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
the function will update the status of using the Github metric of assignment and flashes a notice. if turn on the metric, we will add the assignment_id to the table use_github_metric. If turn off we will delete the data.&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
[[File:E2149_Uml_1.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
After the change of call GitHub API, we need to test get data from the GitHub API.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141347</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141347"/>
		<updated>2021-11-09T01:00:23Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Final Design UML */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric. We also have an alternative solution to add the boolean field in the assignment table, but for security concerns, we give it up we should not influence the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to help update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
the function will search the assignment_id in the use_github_metric table. If not exist, the Github metric will turn off. Otherwise, it will turn on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
the function will update the status of using the Github metric of assignment and flashes a notice. if turn on the metric, we will add the assignment_id to the table use_github_metric. If turn off we will delete the data.&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
[[File:E2149_Uml_1.png]]&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
After the change of call GitHub API, we need to test get data from the GitHub API.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2149_Uml_1.png&amp;diff=141346</id>
		<title>File:E2149 Uml 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2149_Uml_1.png&amp;diff=141346"/>
		<updated>2021-11-09T01:00:14Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141345</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141345"/>
		<updated>2021-11-09T00:56:57Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Adding turn on and turn down option */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Turn on.png]]&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric. We also have an alternative solution to add the boolean field in the assignment table, but for security concerns, we give it up we should not influence the data of the assignment.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
==== Controller Modification ====&lt;br /&gt;
we will add two functions in the assignment_controller to help update the status of using the Github metric.&lt;br /&gt;
&lt;br /&gt;
def query_github_metric_status&lt;br /&gt;
&lt;br /&gt;
the function will search the assignment_id in the use_github_metric table. If not exist, the Github metric will turn off. Otherwise, it will turn on.&lt;br /&gt;
&lt;br /&gt;
def update_github_metirc&lt;br /&gt;
&lt;br /&gt;
the function will update the status of using the Github metric of assignment and flashes a notice. if turn on the metric, we will add the assignment_id to the table use_github_metric. If turn off we will delete the data.&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
Detailed of Github Testing&lt;br /&gt;
After the change of call GitHub API, we need to test get data from the GitHub API.&lt;br /&gt;
&lt;br /&gt;
 describe '#gets data from GitHub api v4(graphql)' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_github_repository_details' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 describe '#get_statuses_for_pull_request' do&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Turn_on.png&amp;diff=141344</id>
		<title>File:Turn on.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Turn_on.png&amp;diff=141344"/>
		<updated>2021-11-09T00:54:30Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141306</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141306"/>
		<updated>2021-11-08T22:35:55Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code for a single project. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Design Patterns==&lt;br /&gt;
&lt;br /&gt;
To achieve the Primary Objectives while making the application more extensible, the team proposes using a more strict implementation of the '''Adapter'''  design pattern to decouple the details of the Github API from the proposed Metrics model. &lt;br /&gt;
Elements of the '''Observer''' design pattern will also come into play to ensure that once we queried Github data and an assignment has come to a close, the Metric for that Assignment would be unsubscribed from the Github API. This would further decouple the dependency on API data while retaining the data for future statistical analysis and/or research studies.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as following:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141303</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141303"/>
		<updated>2021-11-08T22:34:13Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code (&amp;gt; 1500) for a single project. Code size should be reduced. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Design Patterns==&lt;br /&gt;
&lt;br /&gt;
To achieve the Primary Objectives while making the application more extensible, the team proposes using a more strict implementation of the '''Adapter'''  design pattern to decouple the details of the Github API from the proposed Metrics model. &lt;br /&gt;
Elements of the '''Observer''' design pattern will also come into play to ensure that once we queried Github data and an assignment has come to a close, the Metric for that Assignment would be unsubscribed from the Github API. This would further decouple the dependency on API data while retaining the data for future statistical analysis and/or research studies.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as following:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==OminiAuth Github API update==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
===Using client_id/client_secret as a query param===&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Methods Added or Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141302</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141302"/>
		<updated>2021-11-08T22:33:26Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Methods Added or Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code (&amp;gt; 1500) for a single project. Code size should be reduced. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Design Patterns==&lt;br /&gt;
&lt;br /&gt;
To achieve the Primary Objectives while making the application more extensible, the team proposes using a more strict implementation of the '''Adapter'''  design pattern to decouple the details of the Github API from the proposed Metrics model. &lt;br /&gt;
Elements of the '''Observer''' design pattern will also come into play to ensure that once we queried Github data and an assignment has come to a close, the Metric for that Assignment would be unsubscribed from the Github API. This would further decouple the dependency on API data while retaining the data for future statistical analysis and/or research studies.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as following:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==Methods Added or Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141252</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141252"/>
		<updated>2021-11-08T20:04:02Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Methods Added or Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code (&amp;gt; 1500) for a single project. Code size should be reduced. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Design Patterns==&lt;br /&gt;
&lt;br /&gt;
To achieve the Primary Objectives while making the application more extensible, the team proposes using a more strict implementation of the '''Adapter'''  design pattern to decouple the details of the Github API from the proposed Metrics model. &lt;br /&gt;
Elements of the '''Observer''' design pattern will also come into play to ensure that once we queried Github data and an assignment has come to a close, the Metric for that Assignment would be unsubscribed from the Github API. This would further decouple the dependency on API data while retaining the data for future statistical analysis and/or research studies.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as following:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==Methods Added or Modified==&lt;br /&gt;
&lt;br /&gt;
===OminiAuth Github API update===&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
Starting on September 8 2021, using access_token as a query parameter to access the API (as a user or as a GitHub App) or using client_id/client_secret to make OAuth app unauthenticated calls are disabled. &lt;br /&gt;
&lt;br /&gt;
====Using access_token as a query param====&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
====Using client_id/client_secret as a query param====&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141251</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141251"/>
		<updated>2021-11-08T20:02:15Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Methods Added or Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code (&amp;gt; 1500) for a single project. Code size should be reduced. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Design Patterns==&lt;br /&gt;
&lt;br /&gt;
To achieve the Primary Objectives while making the application more extensible, the team proposes using a more strict implementation of the '''Adapter'''  design pattern to decouple the details of the Github API from the proposed Metrics model. &lt;br /&gt;
Elements of the '''Observer''' design pattern will also come into play to ensure that once we queried Github data and an assignment has come to a close, the Metric for that Assignment would be unsubscribed from the Github API. This would further decouple the dependency on API data while retaining the data for future statistical analysis and/or research studies.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as following:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==Methods Added or Modified==&lt;br /&gt;
&lt;br /&gt;
===OminiAuth Github API update===&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
&lt;br /&gt;
====Using access_token as a query param====&lt;br /&gt;
Originally, the code makes an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
====Using client_id/client_secret as a query param====&lt;br /&gt;
Originally, the code uses an OAuth app's client_id and client_secret to make unauthenticated calls with a higher rate limit similar to&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?client_id=my_client_id&amp;amp;client_secret=my_secret_id&amp;quot;&lt;br /&gt;
Instead, we use the following format:&lt;br /&gt;
 curl -u my_client_id:my_client_secret https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141246</id>
		<title>CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2149._Finish_Github_metrics_integration_-_Reputations&amp;diff=141246"/>
		<updated>2021-11-08T19:55:09Z</updated>

		<summary type="html">&lt;p&gt;Mguo6: /* Methods Added or Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Abstract==&lt;br /&gt;
Expertiza provides teammate reviews to measure how much each team member contributed. It also augments this data with Github data of each group’s submitted repo link to help differentiate the performance of team members for grading purposes and predict which projects are likely to be merged. Instructors would like to compile this Github repository statistics on a per-project, per-team basis, and integrate the display of these data within Expertiza.&lt;br /&gt;
The project team will troubleshoot existing code and add new features.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The functionality of the showing GitHub metrics cannot in the assignment be turned off, meaning that an instructor who uses Expertiza for writing assignments in an English course would get a Github metrics report. There needs to be a way to turn the report off for a particular assignment. The project doesn't report lines added and deleted because of a lack of support from the API. It adds quite a lot of lines of code (&amp;gt; 1500) for a single project. Code size should be reduced. The tests of the current project are not described very thoroughly. We will run the existing RSpec test code and add some new tests.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
The team has synced the revised 2021 Spring project E2111 code with the current status of the Expertiza/beta branch and has begun analyzing the existing code. Prior customer feedback has advised the team to address inextensibility/coupling issues, documentation issues, and synchronization issues. We are performing our own end-to-end analysis of the code in addition to this feedback, and have so far found numerous action items. We have separated these action items into Primary and Secondary objectives: Primary objectives are &amp;quot;must-haves&amp;quot; that need to be addressed before the existing code is mergeable. Secondary objectives are &amp;quot;nice-to-haves,&amp;quot; or features that were either left out of the original project or would make the integration display more complete.&lt;br /&gt;
&lt;br /&gt;
==Design Patterns==&lt;br /&gt;
&lt;br /&gt;
To achieve the Primary Objectives while making the application more extensible, the team proposes using a more strict implementation of the '''Adapter'''  design pattern to decouple the details of the Github API from the proposed Metrics model. &lt;br /&gt;
Elements of the '''Observer''' design pattern will also come into play to ensure that once we queried Github data and an assignment has come to a close, the Metric for that Assignment would be unsubscribed from the Github API. This would further decouple the dependency on API data while retaining the data for future statistical analysis and/or research studies.&lt;br /&gt;
&lt;br /&gt;
==Team Action Items==&lt;br /&gt;
&lt;br /&gt;
==== Adding turn on and turn down option ====&lt;br /&gt;
The functionality of the current project cannot be turned off. We will provide an option for instructors not to query Github metrics data before they post the assignment, which is the way we turn the GitHub report off for a particular assignment.&lt;br /&gt;
&lt;br /&gt;
==== Database Modification ====&lt;br /&gt;
In order to determine whether the GitHub report of the assignment is turned on or turned off, we need to create a new table named &amp;quot;use_github_metric&amp;quot; to save the id of the assignment which turns on GitHub metric.&lt;br /&gt;
&lt;br /&gt;
'''Table: use_github_metric'''&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- style=&amp;quot;font-weight:bold;&amp;quot;&lt;br /&gt;
! id(PK)&lt;br /&gt;
! Assignment_id(FK)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Frontend Modification ====&lt;br /&gt;
If a user chose not to include the GitHub metric in the assignment (the functionality is turned off), the frontend page should not occur the icon named &amp;quot;Login to Query of Github data&amp;quot; should not be displayed.&lt;br /&gt;
&lt;br /&gt;
==== Testing ====&lt;br /&gt;
See the details in Test Plan.&lt;br /&gt;
&lt;br /&gt;
==Functionality Walk Through==&lt;br /&gt;
=== Assignment edit page view ===&lt;br /&gt;
This view is where an instructor can customize an assignment. We will provide an option for instructors to decide whether they need Github metrics in the assignment or not.&lt;br /&gt;
&lt;br /&gt;
Before we modified this part, this page is as following:&lt;br /&gt;
&lt;br /&gt;
[[File:Before liang.png|900px]]&lt;br /&gt;
&lt;br /&gt;
After modifying it, this page is:&lt;br /&gt;
&lt;br /&gt;
[[File:Edit page.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: with Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they chose Github metrics in the previous assignment edit page and are not yet authenticated to Github. The Login link redirects to an omniauth login screen, which redirects back to this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwgithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== List Submissions View: without Github metrics option===&lt;br /&gt;
This is how a user will view List Submissions when they did not choose Github metrics in the previous assignment edit page. The Login link for querying Github data would not be provided to the instructors if they don't choose &amp;quot;use github metric&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
[[File:listviewwogithub.png|900px]]&lt;br /&gt;
&lt;br /&gt;
==Final Design UML==&lt;br /&gt;
We show the UML for the new classes and model we created and implemented in our final project for a overview. Other than these, we also modified some of the existing classes and method, we will give detailed introduction later.&lt;br /&gt;
&lt;br /&gt;
==Methods Added or Modified==&lt;br /&gt;
GitHub no longer supports authentication through query parameters. Thus, we move the authentication in the header.&lt;br /&gt;
&lt;br /&gt;
===Using access_token as a query param===&lt;br /&gt;
Originally, we make an API&lt;br /&gt;
 curl &amp;quot;https://api.github.com/user/repos?access_token=my_access_token&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Instead, we send the token in the header:&lt;br /&gt;
 curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Our UI tests aim to capture the following core pieces of functionality:&lt;br /&gt;
&lt;br /&gt;
'''Turn on and turn down functionality button: '''&lt;br /&gt;
&lt;br /&gt;
In order to test the functionality manually, we follow the following steps:&lt;br /&gt;
:1. Log in to Expertiza as an instructor&lt;br /&gt;
:2. Navigate to assignments through Manage &lt;br /&gt;
:3. Show a turn on/turn down button on the page&lt;br /&gt;
:4. Click the button to turn the Github metrics report off for a particular assignment&lt;br /&gt;
:5. The page should not display &amp;quot;Login to Query of Github data&amp;quot;, &amp;quot;Refresh Github data&amp;quot; and &amp;quot;Assign grade Github metrics&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
'''Reduce report lines added and deleted:'''&lt;br /&gt;
&lt;br /&gt;
=== Rspec ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====Key Links=====&lt;br /&gt;
&lt;br /&gt;
[https://docs.github.com/en/rest Github API Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Deprecating API authentication through query parameters]&lt;br /&gt;
&lt;br /&gt;
=====Previous Project References=====&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Original E1858 Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view E1983 Revision Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2021_-_E2111._Refactor_github_metrics_integration E2111 Project Refactoring]&lt;/div&gt;</summary>
		<author><name>Mguo6</name></author>
	</entry>
</feed>