<?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=Tkundra</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=Tkundra"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Tkundra"/>
	<updated>2026-09-11T17:15:17Z</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_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130730</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130730"/>
		<updated>2019-12-07T02:08:14Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
&lt;br /&gt;
2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
We have forked the repository [https://github.com/CarlColglazier/expertiza CarlColglazier/expertiza/gh-integration] currently doing work upon for an independent study project by Carl. We have extended his work and added upon that to show the metrices.&lt;br /&gt;
The link for our project PR is [https://github.com/CarlColglazier/expertiza/pull/1 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a horizontal stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics3.png]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130728</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130728"/>
		<updated>2019-12-07T02:07:49Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
&lt;br /&gt;
2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
We have forked the repository [https://github.com/CarlColglazier/expertiza gh-integration] currently doing work upon for an independent study project by Carl. We have extended his work and added upon that to show the metrices.&lt;br /&gt;
The link for our project PR is [https://github.com/CarlColglazier/expertiza/pull/1 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a horizontal stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics3.png]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130725</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130725"/>
		<updated>2019-12-07T02:06:35Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
1. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
We have forked the repository [https://github.com/CarlColglazier/expertiza gh-integration] currently doing work upon for an independent study project by Carl. We have extended his work and added upon that to show the metrices.&lt;br /&gt;
The link for our project PR is [https://github.com/CarlColglazier/expertiza/pull/1 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a horizontal stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics3.png]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130724</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130724"/>
		<updated>2019-12-07T02:06:08Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
We have forked the repository [https://github.com/CarlColglazier/expertiza gh-integration] currently doing work upon for an independent study project by Carl. We have extended his work and added upon that to show the metrices.&lt;br /&gt;
The link for our project PR is [https://github.com/CarlColglazier/expertiza/pull/1 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a horizontal stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics3.png]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics1.jpeg&amp;diff=130715</id>
		<title>File:Githubmetrics1.jpeg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics1.jpeg&amp;diff=130715"/>
		<updated>2019-12-07T02:00:50Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: uploaded a new version of &amp;amp;quot;File:Githubmetrics1.jpeg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics3.png&amp;diff=130713</id>
		<title>File:Githubmetrics3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics3.png&amp;diff=130713"/>
		<updated>2019-12-07T01:59:43Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: uploaded a new version of &amp;amp;quot;File:Githubmetrics3.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics2.png&amp;diff=130712</id>
		<title>File:Githubmetrics2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics2.png&amp;diff=130712"/>
		<updated>2019-12-07T01:59:25Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: uploaded a new version of &amp;amp;quot;File:Githubmetrics2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130711</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130711"/>
		<updated>2019-12-07T01:57:35Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a horizontal stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics3.png]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130710</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130710"/>
		<updated>2019-12-07T01:56:35Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics3.png]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130708</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130708"/>
		<updated>2019-12-07T01:55:47Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics2.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics3.png&amp;diff=130706</id>
		<title>File:Githubmetrics3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics3.png&amp;diff=130706"/>
		<updated>2019-12-07T01:55:08Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics2.png&amp;diff=130704</id>
		<title>File:Githubmetrics2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Githubmetrics2.png&amp;diff=130704"/>
		<updated>2019-12-07T01:54:57Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130697</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130697"/>
		<updated>2019-12-07T01:51:43Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Resolve merge conflicts of the existing PR with expertiza:master */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mock.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130696</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130696"/>
		<updated>2019-12-07T01:51:06Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Code Climate Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mock.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130695</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130695"/>
		<updated>2019-12-07T01:50:41Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Rspec Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mock.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also, some of the modules can be subdivided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context &amp;quot;when graph type is number of commits and group by week&amp;quot; do&lt;br /&gt;
      it 'should return commits group by week' do&lt;br /&gt;
        git_variable = {}&lt;br /&gt;
&lt;br /&gt;
        git_variable[:parsed_data] = {&lt;br /&gt;
          &amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;2, :deletions=&amp;gt;2&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt; {&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }&lt;br /&gt;
          }, &lt;br /&gt;
          &amp;quot;ssbhoyar@gmail.com&amp;quot;=&amp;gt;{&lt;br /&gt;
            &amp;quot;2018-11-14&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;0, :additions=&amp;gt;0, :deletions=&amp;gt;0&lt;br /&gt;
            }, &lt;br /&gt;
            &amp;quot;2018-11-23&amp;quot;=&amp;gt;{&lt;br /&gt;
              :commits=&amp;gt;1, :additions=&amp;gt;0, :deletions=&amp;gt;3292&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        git_variable[:authors] = [&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;ssbhoyar@gmail.com&amp;quot;]&lt;br /&gt;
        git_variable[:dates] = [&amp;quot;2018-11-14&amp;quot;, &amp;quot;2018-11-23&amp;quot;]&lt;br /&gt;
        graph_type = '0'&lt;br /&gt;
        timeline_type = '0'&lt;br /&gt;
        due_date = &amp;quot;2017-09-08 23:59:00 -0400&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        data = helper.get_chart_data(git_variable, graph_type, timeline_type, due_date)&lt;br /&gt;
&lt;br /&gt;
        expected_data = {&lt;br /&gt;
          :labels=&amp;gt;[-10, -11],&lt;br /&gt;
          :datasets=&amp;gt;[&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[1, 0], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;tushar.h.dahibhate@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ed1c1c&amp;quot;},&lt;br /&gt;
            {&amp;quot;borderWidth&amp;quot;=&amp;gt;1, &amp;quot;data&amp;quot;=&amp;gt;[0, 1], &amp;quot;stack&amp;quot;=&amp;gt;1, &amp;quot;label&amp;quot;=&amp;gt;&amp;quot;ssbhoyar@gmail.com&amp;quot;, &amp;quot;backgroundColor&amp;quot;=&amp;gt;&amp;quot;#ffea00&amp;quot;}&lt;br /&gt;
          ]&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        expect(data).to eq(expected_data)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130693</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=130693"/>
		<updated>2019-12-07T01:50:06Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Rspec Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/saxenaakshay/expertiza/tree/gh-integration here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as a vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner. Assignment policy contains variables for due date and start date which can be used to get the timeline to plot week-wise data, this way we'll have max around 3-4 weeks of bars. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mock.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UmlDiagram.jpg|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:githubmetrics1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of the code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also, some of the modules can be subdivided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
====Add horizontal bar charts for user statistics====&lt;br /&gt;
A bar graph needs to be added to display data like the number of commits, the number of lines of code added/removed per user basis. The current work consists of cluttered graphs for code frequency for the entire team which makes it difficult to gather user-level activities/submissions in different timelines. We intend to add horizontal bar charts that can be mapped to user-level contributions in different per week.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
&lt;br /&gt;
Github Metrics By Week&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
Github Metrics By Student&lt;br /&gt;
* Number Of Commits&lt;br /&gt;
* Lines Added&lt;br /&gt;
* Lines Deleted&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_chart_data&amp;quot; function parses the input github data based on the type of the graph and timeline selected to the required data format required by the chartjs-ror &amp;quot;horizontal_bar_chart&amp;quot; function&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129446</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129446"/>
		<updated>2019-11-16T02:56:12Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
The data is shown as vertical stacked graph grouped by the time range for eg: weekly or daily. The bar will show the no of commits, lines of code in a stacked manner.&lt;br /&gt;
[[File:MockGraph.png]]&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:Final2.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129445</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129445"/>
		<updated>2019-11-16T02:54:07Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
[[File:MockGraph.png]]&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:Final2.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129444</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129444"/>
		<updated>2019-11-16T02:53:39Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Project Task */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
===UI===&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
*Old Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
*New Graph Representation&lt;br /&gt;
[[File:OldScreen.png]]&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:Final2.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:OldScreen.png&amp;diff=129443</id>
		<title>File:OldScreen.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:OldScreen.png&amp;diff=129443"/>
		<updated>2019-11-16T02:52:05Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:MockGraph.png&amp;diff=129442</id>
		<title>File:MockGraph.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:MockGraph.png&amp;diff=129442"/>
		<updated>2019-11-16T02:51:42Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129434</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=129434"/>
		<updated>2019-11-16T02:32:57Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Project Task */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
#The current screen looks cluttered and needs to be changed to display the data in more organised and easy to read way. The github commit data can be shown on weekly basis instead of the current day wise. Showing the data day wise does not add much for the instructor grading. A bar graph needs to be added to display data like no of commits, no of lines of code, etc. per uses basis.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:Final2.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
==== Resolve merge conflicts of the existing PR with expertiza:master====&lt;br /&gt;
The merge conflicts in app/views/grades/_tabbing.html.erb and app/assets/stylesheets/grades.scss have to fixed for auto-merge to work.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128947</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128947"/>
		<updated>2019-11-12T02:05:55Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* &amp;quot;Dry&amp;quot; the Redundant Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128946</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128946"/>
		<updated>2019-11-12T02:04:39Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Move JavaScript Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
==== Move controller code to helper====&lt;br /&gt;
The controller code contains auxiliary functions that make calls to Github for third party resources. These can be moved to a helper class.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128936</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128936"/>
		<updated>2019-11-12T01:50:15Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Our Improvements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Feedbacks and Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
We will test all the existing functionality for the page where we are showing GitHub matrices.&lt;br /&gt;
&lt;br /&gt;
New Features which we will test:&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*retrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128934</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128934"/>
		<updated>2019-11-12T01:49:41Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Our Improvements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1858, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128933</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128933"/>
		<updated>2019-11-12T01:48:49Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Our Improvements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1983, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128932</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128932"/>
		<updated>2019-11-12T01:48:10Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128930</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128930"/>
		<updated>2019-11-12T01:46:51Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128926</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128926"/>
		<updated>2019-11-12T01:40:47Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* &amp;quot;Dry&amp;quot; the Redundant Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
==== Code Climate Issues====&lt;br /&gt;
'''Problem:''' Currently there are 134 code climate issues to be corrected&lt;br /&gt;
For example, the size of functions and the depth exceeds the limit. Also some of the modules can be sub divided into smaller modules.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
We added and changed the new controller '''github_metrics controller''' and some ralated files.&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/controllers/github_metrics_controller.rb github_metrics controller.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/helpers/github_metrics_helper.rb github_metrics_helper.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb github_metrics_controller_spec.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/config/routes.rb routes.rb]&lt;br /&gt;
&lt;br /&gt;
The GitHub metrics part is separated into the new files.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
&lt;br /&gt;
Previous work includes JavaScript code. After carefully testing and examination, we found these JavaScript code were another version of the implementation of our task. So we remove those redundant codes to make our code clean.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/02de332e9d1c2fc463ef0120dca70360b6356eda Remove redundant JavaScript codes]&lt;br /&gt;
&lt;br /&gt;
====Refactor Redandent Variables====&lt;br /&gt;
&lt;br /&gt;
We create a hash table to cover all the created instance variables.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/fab8468a296f0abcb336869283bd6acb282bff61 Refactor instance variables]&lt;br /&gt;
&lt;br /&gt;
====Callback setup for github token====&lt;br /&gt;
&lt;br /&gt;
we set the callback URL as: ./auth/github/callback&lt;br /&gt;
&lt;br /&gt;
[[File:callback.png]]&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128921</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128921"/>
		<updated>2019-11-12T01:34:30Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Design Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE. To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
We added and changed the new controller '''github_metrics controller''' and some ralated files.&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/controllers/github_metrics_controller.rb github_metrics controller.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/helpers/github_metrics_helper.rb github_metrics_helper.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb github_metrics_controller_spec.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/config/routes.rb routes.rb]&lt;br /&gt;
&lt;br /&gt;
The GitHub metrics part is separated into the new files.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
&lt;br /&gt;
Previous work includes JavaScript code. After carefully testing and examination, we found these JavaScript code were another version of the implementation of our task. So we remove those redundant codes to make our code clean.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/02de332e9d1c2fc463ef0120dca70360b6356eda Remove redundant JavaScript codes]&lt;br /&gt;
&lt;br /&gt;
====Refactor Redandent Variables====&lt;br /&gt;
&lt;br /&gt;
We create a hash table to cover all the created instance variables.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/fab8468a296f0abcb336869283bd6acb282bff61 Refactor instance variables]&lt;br /&gt;
&lt;br /&gt;
====Callback setup for github token====&lt;br /&gt;
&lt;br /&gt;
we set the callback URL as: ./auth/github/callback&lt;br /&gt;
&lt;br /&gt;
[[File:callback.png]]&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128920</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128920"/>
		<updated>2019-11-12T01:33:13Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Design Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Expertiza provides teammate reviews to gauge how much each team member contributed, but we would like to augment this data with data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  This information should prove useful for differentiating the performance of team members for grading purposes. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - Representational State Transfer REST  web services helps in establishing the interoperability between different applications. RESTful API uses the HTTP requests for performing the actions GET, PUT, POST and DELETE.&lt;br /&gt;
To get the data from Github we will use their query api.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we will add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller, moving javascript code and after adding new UI changes.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
We added and changed the new controller '''github_metrics controller''' and some ralated files.&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/controllers/github_metrics_controller.rb github_metrics controller.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/helpers/github_metrics_helper.rb github_metrics_helper.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb github_metrics_controller_spec.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/config/routes.rb routes.rb]&lt;br /&gt;
&lt;br /&gt;
The GitHub metrics part is separated into the new files.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
&lt;br /&gt;
Previous work includes JavaScript code. After carefully testing and examination, we found these JavaScript code were another version of the implementation of our task. So we remove those redundant codes to make our code clean.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/02de332e9d1c2fc463ef0120dca70360b6356eda Remove redundant JavaScript codes]&lt;br /&gt;
&lt;br /&gt;
====Refactor Redandent Variables====&lt;br /&gt;
&lt;br /&gt;
We create a hash table to cover all the created instance variables.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/fab8468a296f0abcb336869283bd6acb282bff61 Refactor instance variables]&lt;br /&gt;
&lt;br /&gt;
====Callback setup for github token====&lt;br /&gt;
&lt;br /&gt;
we set the callback URL as: ./auth/github/callback&lt;br /&gt;
&lt;br /&gt;
[[File:callback.png]]&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128913</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128913"/>
		<updated>2019-11-12T01:27:16Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Design Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
'''Expertiza''' provides '''teammate reviews''' to gauge how much each team member contributed, this information could be generated from data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
* Restful Api - &lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller and moving javascript codes.&lt;br /&gt;
&lt;br /&gt;
Management -&amp;gt; Assignment -&amp;gt; Github Metrics&lt;br /&gt;
&lt;br /&gt;
You can see the test result in [https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
We added and changed the new controller '''github_metrics controller''' and some ralated files.&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/controllers/github_metrics_controller.rb github_metrics controller.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/helpers/github_metrics_helper.rb github_metrics_helper.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb github_metrics_controller_spec.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/config/routes.rb routes.rb]&lt;br /&gt;
&lt;br /&gt;
The GitHub metrics part is separated into the new files.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
&lt;br /&gt;
Previous work includes JavaScript code. After carefully testing and examination, we found these JavaScript code were another version of the implementation of our task. So we remove those redundant codes to make our code clean.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/02de332e9d1c2fc463ef0120dca70360b6356eda Remove redundant JavaScript codes]&lt;br /&gt;
&lt;br /&gt;
====Refactor Redandent Variables====&lt;br /&gt;
&lt;br /&gt;
We create a hash table to cover all the created instance variables.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/fab8468a296f0abcb336869283bd6acb282bff61 Refactor instance variables]&lt;br /&gt;
&lt;br /&gt;
====Callback setup for github token====&lt;br /&gt;
&lt;br /&gt;
we set the callback URL as: ./auth/github/callback&lt;br /&gt;
&lt;br /&gt;
[[File:callback.png]]&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128911</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128911"/>
		<updated>2019-11-12T01:26:08Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Use Case Diagram Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
'''Expertiza''' provides '''teammate reviews''' to gauge how much each team member contributed, this information could be generated from data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*Arshdeep Singh Syal (asyal)&lt;br /&gt;
*Akshay Saxena (asaxena5)&lt;br /&gt;
*Piyush Tiwari (ptiwari)&lt;br /&gt;
*Tushar Kundra (tkundra)&lt;br /&gt;
&lt;br /&gt;
===Mentor===&lt;br /&gt;
*Suraj Siddharudh&lt;br /&gt;
*Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
=='''Design Principles'''==&lt;br /&gt;
&lt;br /&gt;
* MVC – The project is implemented in Ruby on Rails that uses MVC architecture.  It separates an application’s data model, user interface, and control logic into three distinct components (model, view and controller, respectively). We intend to follow the same when implementing our end-point for pulling GitHub data.&lt;br /&gt;
&lt;br /&gt;
* Dry Principle – We are trying to reuse the existing functionalities in Expertiza, thus avoiding code duplication.  Whenever possible, code modification based on the existing classes, controllers, or tables will be done instead of creating the new one.&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existing test, we need to mock roles:&lt;br /&gt;
&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new RSpec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our RSpec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller and moving javascript codes.&lt;br /&gt;
&lt;br /&gt;
Management -&amp;gt; Assignment -&amp;gt; Github Metrics&lt;br /&gt;
&lt;br /&gt;
You can see the test result in [https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
We added and changed the new controller '''github_metrics controller''' and some ralated files.&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/controllers/github_metrics_controller.rb github_metrics controller.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/helpers/github_metrics_helper.rb github_metrics_helper.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb github_metrics_controller_spec.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/config/routes.rb routes.rb]&lt;br /&gt;
&lt;br /&gt;
The GitHub metrics part is separated into the new files.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
&lt;br /&gt;
Previous work includes JavaScript code. After carefully testing and examination, we found these JavaScript code were another version of the implementation of our task. So we remove those redundant codes to make our code clean.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/02de332e9d1c2fc463ef0120dca70360b6356eda Remove redundant JavaScript codes]&lt;br /&gt;
&lt;br /&gt;
====Refactor Redandent Variables====&lt;br /&gt;
&lt;br /&gt;
We create a hash table to cover all the created instance variables.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/fab8468a296f0abcb336869283bd6acb282bff61 Refactor instance variables]&lt;br /&gt;
&lt;br /&gt;
====Callback setup for github token====&lt;br /&gt;
&lt;br /&gt;
we set the callback URL as: ./auth/github/callback&lt;br /&gt;
&lt;br /&gt;
[[File:callback.png]]&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128878</id>
		<title>CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1983._Refactor_E1858,_Github_metrics_integration_view&amp;diff=128878"/>
		<updated>2019-11-12T00:42:52Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: Created page with &amp;quot;=='''Introduction'''==  ===Problem Statement=== '''Expertiza''' provides '''teammate reviews''' to gauge how much each team member contributed, this information could be generate...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
'''Expertiza''' provides '''teammate reviews''' to gauge how much each team member contributed, this information could be generated from data from external tools like Github (for example, number of commits, number of lines of code modified, number of lines added, number of lines deleted.) from each group’s submitted repo link.  Currently, Expertiza provides '''Teammate Reviews''' under '''View Scores''' functionality for each assignment.&lt;br /&gt;
&lt;br /&gt;
:1. '''Teammate Reviews''' functionality in the View Scores page gauges teammate views on how much other team members contributed to the project. We need to augment this data with data from external tools like GitHub in order to validate that feedback. New metrics will be appended under each student data under the same functionality.&lt;br /&gt;
:2. '''Github Metrics''' under '''View Submissions''' page should include a bar chart that shows the number of commits by the team throughout the assignment timeline. This will help instructors to get a team overview, and aid grading process.&lt;br /&gt;
&lt;br /&gt;
While this data will not have marks associated directly, it will prove useful to the instructor in differentiating the performance of team members and hence awarding marks as per contribution. Overall data for the team, like the number of committers and number of commits may also help instructors to predict which projects are likely to be merged.&lt;br /&gt;
&lt;br /&gt;
The link for our project PR is [https://github.com/expertiza/expertiza/pull/1455 here]&lt;br /&gt;
&lt;br /&gt;
===Project Task===&lt;br /&gt;
Extract Github metadata of the submitted repos and pull requests.&lt;br /&gt;
#The metadata should be stored in the local Expertiza DB. For each participant, record should include at least:&lt;br /&gt;
#*Committer id&lt;br /&gt;
#*Total number of commits&lt;br /&gt;
#*Number of files changed&lt;br /&gt;
#*Lines of code changed&lt;br /&gt;
#*Lines of code added&lt;br /&gt;
#*Lines of code removed&lt;br /&gt;
#*Lines of code added that survived until final submission [if available from Github]&lt;br /&gt;
#The code should sync the data with Github whenever someone (student or instructor) looks at a view that shows Github data.&lt;br /&gt;
#The data for teams should be shown in the instructor’s View Scores window, in a new tab, probably between Reviews and Author Feedback.&lt;br /&gt;
#*Design a good view for showing data on individuals.  Please discuss this with the project mentor(s).&lt;br /&gt;
#*It seems to me that this should be on the Teammate Reviews tab, right below the grid for teammate reviews. The reason for this is that we’d like to see all the data on an individual in a single view.  For teams, by contrast, there is already a pretty large grid, and potentially multiple grids for multiple rounds, so adding a new grid is more likely to clutter the display.&lt;br /&gt;
#Create a bar chart for the # of lines changed for each assignment team on “view_submissions” page. The x-axis should be the time starting from the assignment creation time, till the last deadline of the assignment, or current time, whichever is earlier.&lt;br /&gt;
&lt;br /&gt;
This task has been partially implemented by another group for project''' E1858. Github Metrics Integration''' in 2018 Fall semester. Detailed document about project E1858 on framework design and implementation can be found in [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration here] and the PR for Project E1858 is shown in [https://github.com/expertiza/expertiza/pull/1179 Here]. However, their work has been rejected with the feedback &amp;quot;They have integrated the github metrics into expertiza to show the number of commits, pull requests status, etc against every project. They have also integrated it into the metrics.  Looks like they covered the edge cases. The code looks good but needs comments as it is pretty complex. The documentation feels like it is flooded with code, if there was a description of the changes, it would have been better. Extensive tests, but it might be good to see if additions to existing tests really belong in those same tests&amp;quot;. The goal of our current project is to resolve issues existing in their previous work, refactor codes they created and modify their code following &amp;quot;DRY&amp;quot; principles. The ultimate goal is to have the '''Github Metric Integration''' work in Expertiza.&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
*swang28 (Shuai Wang)&lt;br /&gt;
*zwu17 (Ziwei Wu)&lt;br /&gt;
*hlu6 (Hao Lu)&lt;br /&gt;
*ychen239( Yuhan Chen)&lt;br /&gt;
*zhu6 (Zhewei Hu, mentor)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Plan of Work'''==&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
[[File:UC_1.png|none|frame|1. Use Case diagram of two approaches to append 'GitHub contribution metric' in teammate review. 2. Use Case diagram explaining approach to add new column 'GitHub contribution metric' in 'View submission]]&lt;br /&gt;
&lt;br /&gt;
====Use Case Diagram Details====&lt;br /&gt;
'''Actors:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor: This actor is responsible for viewing GitHub metrics of teams and team members of an assignment. &lt;br /&gt;
&lt;br /&gt;
'''Pre-Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*The Team should have submitted the assignment with a PR link or GitHub repository.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&lt;br /&gt;
&lt;br /&gt;
*The instructor should login.&lt;br /&gt;
&lt;br /&gt;
*The instructor should browse teams for an assignment.&lt;br /&gt;
&lt;br /&gt;
'''Post Conditions:'''&lt;br /&gt;
&lt;br /&gt;
*Instructor will be able to see the team contribution done by each team member in 'View Submissions' page using graph diagrams, as shown in the figure.&lt;br /&gt;
*Instructor will be able to see the work done by each student in 'Teammate Review Tab' with new metrics table appended at the end, as shown in the figure.&lt;br /&gt;
&lt;br /&gt;
===Github Metrics Features===&lt;br /&gt;
&lt;br /&gt;
Github Metrics Features can be accessed from manage content UI&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow1.png]]&lt;br /&gt;
&lt;br /&gt;
Then click the 'view submissions'&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow2.png]]&lt;br /&gt;
&lt;br /&gt;
Then we can see 'Github Metrics button' in each project submission&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow3.png]]&lt;br /&gt;
&lt;br /&gt;
Below is the bar chart of commit numbers.&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow4.png]]&lt;br /&gt;
&lt;br /&gt;
We can see the details in the following part.&lt;br /&gt;
&lt;br /&gt;
[[File:Githubflow5.png]]&lt;br /&gt;
&lt;br /&gt;
===Our Improvements===&lt;br /&gt;
&lt;br /&gt;
After understanding the project E1851, We found some issues in this project and give our solutions below.&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
'''Problem:''' The related codes for Github related functionalities are most implemented under &amp;quot;Grades_Controller&amp;quot;. This design obviously violates a good design pattern because Grade_Controller involves too many functions. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' To improve it, we should create a separate &amp;quot;Github_Metrics_Controller&amp;quot; which is specifically responsible for functions related to Github Metrics. Following the MVC architecture, we will also need to create corresponding '''Models''' and '''Views''' for the new controller.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
'''Problem:''' There are some JavaScript codes in inappropriate positions. For example:&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
   toggle_tag_prompt = function() {&lt;br /&gt;
     $('.tag_prompt_container').toggle();&lt;br /&gt;
   };&lt;br /&gt;
   $( document ).ready(function() {&lt;br /&gt;
     $('#tag_prompt_toggler').click(function () {&lt;br /&gt;
       if ($('#tag_prompt_toggler').text() == &amp;quot;hide tags&amp;quot;)&lt;br /&gt;
         $('#tag_prompt_toggler').text(&amp;quot;show tags&amp;quot;)&lt;br /&gt;
       else&lt;br /&gt;
         $('#tag_prompt_toggler').text(&amp;quot;hide tags&amp;quot;)&lt;br /&gt;
     });&lt;br /&gt;
   });&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We need to replace JavaScript codes to 'assets' fold.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Dry&amp;quot; the Redundant Code====&lt;br /&gt;
'''Problem:''' Lots of codes in their current implementation violate ruby's &amp;quot;DRY&amp;quot; principles, such as redundant codes, meaningless names, long coding block and so on. &lt;br /&gt;
&lt;br /&gt;
'''Solution:''' We will refactor their code and fix code smells with the help of code climate platform.&lt;br /&gt;
&lt;br /&gt;
For example, some code like the format below can be rewritten in the shorter line.&lt;br /&gt;
&lt;br /&gt;
''' &lt;br /&gt;
    @head_refs = {}&lt;br /&gt;
    @parsed_data = {}&lt;br /&gt;
    @authors = {}&lt;br /&gt;
    @dates = {}&lt;br /&gt;
    @total_additions = 0&lt;br /&gt;
    @total_deletions = 0&lt;br /&gt;
    @total_commits = 0&lt;br /&gt;
    @total_files_changed = 0&lt;br /&gt;
    @merge_status = {}&lt;br /&gt;
    @check_statuses = {}&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
The solution to the example: create a hash table for all of the instance variables and refactor all the usage of the variables. &lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
   @gitVariable = {&lt;br /&gt;
        :head_refs =&amp;gt; {},&lt;br /&gt;
        :parsed_data =&amp;gt; {},&lt;br /&gt;
        :authors =&amp;gt; {},&lt;br /&gt;
        :dates =&amp;gt; {},&lt;br /&gt;
        :total_additions =&amp;gt; 0,&lt;br /&gt;
        :total_deletions =&amp;gt; 0,&lt;br /&gt;
        :total_commits =&amp;gt; 0,&lt;br /&gt;
        :total_files_changed =&amp;gt; 0,&lt;br /&gt;
        :merge_status =&amp;gt; {},&lt;br /&gt;
        :check_statuses =&amp;gt; {}&lt;br /&gt;
    }&lt;br /&gt;
'''&lt;br /&gt;
Some code like the format below can be rewritten and shorten by putting } in one line.&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 &lt;br /&gt;
 def get_github_repository_details(hyperlink_data)&lt;br /&gt;
    data = {&lt;br /&gt;
      query: &amp;quot;query {&lt;br /&gt;
        repository(owner: \&amp;quot;&amp;quot; + hyperlink_data[&amp;quot;owner_name&amp;quot;] + &amp;quot;\&amp;quot;, name: \&amp;quot;&amp;quot; + hyperlink_data[&amp;quot;repository_name&amp;quot;] + &amp;quot;\&amp;quot;) {&lt;br /&gt;
          ref(qualifiedName: \&amp;quot;master\&amp;quot;) {&lt;br /&gt;
            target {&lt;br /&gt;
              ... on Commit {&lt;br /&gt;
                id&lt;br /&gt;
                  history(first: 100) {&lt;br /&gt;
                    edges {&lt;br /&gt;
                      node {&lt;br /&gt;
                        id author {&lt;br /&gt;
                          name email date&lt;br /&gt;
                        }&lt;br /&gt;
                      }&lt;br /&gt;
                    }&lt;br /&gt;
                  }&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        }&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
Also, there are many useless spaces make the code look less elegant.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
To make sure the refactor code can work correctly, we need to run the original rspec test code and add some new test. Besides, we are plaining to test from UI to make sure all the features work. The test results are shown below.&lt;br /&gt;
&lt;br /&gt;
*Run and pass existing RSpec Tests after refactoring&lt;br /&gt;
*Develop New RSpec Tests for the new features&lt;br /&gt;
*UI testing on the deployed project&lt;br /&gt;
&lt;br /&gt;
===Rspec Test===&lt;br /&gt;
For the existting test, we need to mock roles:&lt;br /&gt;
'''&lt;br /&gt;
  let(:review_response) { build(:response) }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, questionnaires: [review_questionnaire], is_penalty_calculated: true) }&lt;br /&gt;
  let(:assignment_questionnaire) { build(:assignment_questionnaire, used_in_round: 1, assignment: assignment) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, assignment: assignment, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id: 2, assignment: assignment, user_id: 1) }&lt;br /&gt;
  let(:review_questionnaire) { build(:questionnaire, id: 1, questions: [question]) }&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:question) { build(:question) }&lt;br /&gt;
  let(:team) { build(:assignment_team, id: 1, assignment: assignment, users: [instructor]) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
  let(:review_response_map) { build(:review_response_map, id: 1) }&lt;br /&gt;
  let(:assignment_due_date) { build(:assignment_due_date) }&lt;br /&gt;
 '''&lt;br /&gt;
All the test can be found in &amp;quot;expertiza/spec/controllers/grades_controller_spec.rb&amp;quot; now, we will refactor it since we need to build new controller.&lt;br /&gt;
&lt;br /&gt;
We test several conditions :&lt;br /&gt;
*Views&lt;br /&gt;
**when user has logged into to GitHub&lt;br /&gt;
**when user hasn\'t logged in to GitHub&lt;br /&gt;
**when current assignment does not vary rubric by round&lt;br /&gt;
*view_my_scores&lt;br /&gt;
**when view_my_scores page is not allow to access&lt;br /&gt;
**when view_my_scores page is allow to access&lt;br /&gt;
*view_team&lt;br /&gt;
*edit&lt;br /&gt;
*instructor_review&lt;br /&gt;
**when review exists&lt;br /&gt;
**when review does not exist&lt;br /&gt;
*update&lt;br /&gt;
**when total is not equal to participant\'s grade&lt;br /&gt;
**when total is equal to participant\'s grade&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*get_statuses_for_pull_request&lt;br /&gt;
*etrieve_pull_request_data&lt;br /&gt;
*retrieve_repository_data&lt;br /&gt;
*retrieve_github_data&lt;br /&gt;
**when pull request links have been submitted&lt;br /&gt;
**when pull request links have not been submitted&lt;br /&gt;
*retrieve_check_run_statuses&lt;br /&gt;
*view_github_metrics&lt;br /&gt;
**when user has logged in to GitHub&lt;br /&gt;
*authorize_github&lt;br /&gt;
*get_github_repository_details&lt;br /&gt;
*get_pull_request_details&lt;br /&gt;
*process_github_authors_and_dates&lt;br /&gt;
*parse_github_pull_request_data&lt;br /&gt;
*parse_github_repository_data&lt;br /&gt;
*make_github_graphql_request&lt;br /&gt;
*get_query&lt;br /&gt;
*team_statistics&lt;br /&gt;
*organize_commit_dates&lt;br /&gt;
&lt;br /&gt;
The new rspec test file is [https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb here]. You can run the following code&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
rspec spec/controllers/github_metrics_controller_spec.rb&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
to test the result. Our rspec test coverage is 100. The test video is [https://www.youtube.com/watch?v=1pOVQzHT7jg here]&lt;br /&gt;
&lt;br /&gt;
===UI Test===&lt;br /&gt;
For this project, we add an API from the GitHub, all we need to do is to test whether the API can work appropriately after changing codes to another controller and moving javascript codes.&lt;br /&gt;
&lt;br /&gt;
Management -&amp;gt; Assignment -&amp;gt; Github Metrics&lt;br /&gt;
&lt;br /&gt;
You can see the test result in [https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
&lt;br /&gt;
====Add New Controller====&lt;br /&gt;
We added and changed the new controller '''github_metrics controller''' and some ralated files.&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/controllers/github_metrics_controller.rb github_metrics controller.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/app/helpers/github_metrics_helper.rb github_metrics_helper.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/spec/controllers/github_metrics_controller_spec.rb github_metrics_controller_spec.rb]&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/blob/master/config/routes.rb routes.rb]&lt;br /&gt;
&lt;br /&gt;
The GitHub metrics part is separated into the new files.&lt;br /&gt;
&lt;br /&gt;
====Move JavaScript Code====&lt;br /&gt;
&lt;br /&gt;
Previous work includes JavaScript code. After carefully testing and examination, we found these JavaScript code were another version of the implementation of our task. So we remove those redundant codes to make our code clean.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/02de332e9d1c2fc463ef0120dca70360b6356eda Remove redundant JavaScript codes]&lt;br /&gt;
&lt;br /&gt;
====Refactor Redandent Variables====&lt;br /&gt;
&lt;br /&gt;
We create a hash table to cover all the created instance variables.&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/HohoCoco/expertiza/commit/fab8468a296f0abcb336869283bd6acb282bff61 Refactor instance variables]&lt;br /&gt;
&lt;br /&gt;
====Callback setup for github token====&lt;br /&gt;
&lt;br /&gt;
we set the callback URL as: ./auth/github/callback&lt;br /&gt;
&lt;br /&gt;
[[File:callback.png]]&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=QMVXceN7XFg Project E1925 Video]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=1pOVQzHT7jg&amp;amp;feature=youtu.be rspec test]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/Main_Page Expertiza_wiki]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018-_Project_E1858._Github_metrics_integration Project E1858 wiki]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/1179 Project E1858 PR Link]&lt;br /&gt;
&lt;br /&gt;
[https://developer.github.com/v3/ GitHub API documentation]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019&amp;diff=128877</id>
		<title>CSC/ECE 517 Fall 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019&amp;diff=128877"/>
		<updated>2019-11-12T00:41:40Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2019 - Project E1947. Refactor quiz_questionnaire_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - Project E1965. Review report should link to the usual view for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1972. OSS project J. Skellington: Accessing Assignment Rubrics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1961. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1971. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1953. Tagging report for student]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1955.Write  unit tests for student_task.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1954. Auto-generate submission directory names based on assignment names]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1958. Two issues related to assignment management]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1948. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1959. Intelligent copying of assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1968. Fixes for adding members to teams]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1969. Fixes for reviews not being available]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1951. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1957. Time travel Not Allowed..!!! Restrict TAs’ ability to change their own grade + limit file-size upload]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1963. Changing assignment participant role]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1941. Issues related to topic deadlines]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1966. Tabbed_reviews partial file refactor for displaying the alternate view of reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1962. Email notification upon account creation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1967. Fix glitches in author feedback]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1960. Create new late policy successfully and fixing &amp;quot;Back&amp;quot; link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1939. OSS Project Juniper: Bookmark enhancements]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1950. Support Asynchronous Web Assembly Compilation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1938. OSS project Duke Blue: Fix import glitches]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1985. Let course staff and students do reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1951. Implement missing OffscreenCanvas APIs]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1940. Improving email notification]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1942. Refactor stage deadlines in assignment.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1952. Missing DOM features project]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1945. Refactor users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1964. Export review scores for projects]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1949. Write Unit Tests for Importing assignment participants and import glitches]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1944. Refactor review mapping controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1982. Regulate changing of rubrics while projects are in progress]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1989. Track the time students look at other submissions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1990. Integrate suggestion detection algorithm]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1995. Tests for email functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1979. Completion/Progress view]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1980. Sort instructor reports by name, ID, score, etc.]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1983. Refactor E1858, Github metrics integration view]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1984. Improve self-review  Link peer review &amp;amp; self-review to derive grades]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1994. Mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1997. Issues related to meta-reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1981. Student-generated questions added to rubric]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1996. Enhancements to review grader]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1991. Improvements to anonymized view]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1998. Weights in grade calculation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1986. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 -E1988 Allow reviewer to say review can be shown to class as an example]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1975. Generalize Review Versioning]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1976. Issues Related to Assignment Creation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1991. Improvements to anonymized view]]&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127717</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127717"/>
		<updated>2019-11-07T01:21:21Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* DB Schema */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== DB Schema ==&lt;br /&gt;
Below are the tables that are related ti student task functionality&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg DB Schema]&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
The following functions were tested:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage using the participant id&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
This function return the list of all the students that the logged on user has teamed up until now.&lt;br /&gt;
* started?&lt;br /&gt;
Checks if the current stage is &amp;quot;incomplete&amp;quot; and  content_submitted_in_current_stage? reviews_given_in_current_stage? || metareviews_given_in_current_stage? and return true and false&lt;br /&gt;
* topic_name&lt;br /&gt;
Return the name of the topic&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below are some of the functions tested&lt;br /&gt;
* Function: teamed_students - Write a test case to find teamed up students.&lt;br /&gt;
This method is an instance method, having a user passed to it. It return the list of students that the current user has teamed up. It does not consider the teammates that are from calibration assignments&lt;br /&gt;
The test cases described check for the following scenarios: &lt;br /&gt;
1. When not in any team returns empty&lt;br /&gt;
2. When assigned in a cource_team returns empty&lt;br /&gt;
3. When assigned in a assignment_team return the list of teammates&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Function: get_due_date_data - Write a test case to get the due dates of the assignment.&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_peer_review_data - Write a test case to get the peer review data.===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_author_feedback_data - Write a test case to get the feedback response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_submission_data - Write a test case to import participants&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127671</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127671"/>
		<updated>2019-11-07T00:54:16Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Description of the current project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== DB Schema ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg Full DB Schema]&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
The following functions were tested:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage using the participant id&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
This function return the list of all the students that the logged on user has teamed up until now.&lt;br /&gt;
* started?&lt;br /&gt;
Checks if the current stage is &amp;quot;incomplete&amp;quot; and  content_submitted_in_current_stage? reviews_given_in_current_stage? || metareviews_given_in_current_stage? and return true and false&lt;br /&gt;
* topic_name&lt;br /&gt;
Return the name of the topic&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below are some of the functions tested&lt;br /&gt;
* Function: teamed_students - Write a test case to find teamed up students.&lt;br /&gt;
This method is an instance method, having a user passed to it. It return the list of students that the current user has teamed up. It does not consider the teammates that are from calibration assignments&lt;br /&gt;
The test cases described check for the following scenarios: &lt;br /&gt;
1. When not in any team returns empty&lt;br /&gt;
2. When assigned in a cource_team returns empty&lt;br /&gt;
3. When assigned in a assignment_team return the list of teammates&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Function: get_due_date_data - Write a test case to get the due dates of the assignment.&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_peer_review_data - Write a test case to get the peer review data.===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_author_feedback_data - Write a test case to get the feedback response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_submission_data - Write a test case to import participants&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127670</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127670"/>
		<updated>2019-11-07T00:53:34Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Description of the current project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg Full DB Schema]&lt;br /&gt;
&lt;br /&gt;
The following functions were tested:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage using the participant id&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
This function return the list of all the students that the logged on user has teamed up until now.&lt;br /&gt;
* started?&lt;br /&gt;
Checks if the current stage is &amp;quot;incomplete&amp;quot; and  content_submitted_in_current_stage? reviews_given_in_current_stage? || metareviews_given_in_current_stage? and return true and false&lt;br /&gt;
* topic_name&lt;br /&gt;
Return the name of the topic&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below are some of the functions tested&lt;br /&gt;
* Function: teamed_students - Write a test case to find teamed up students.&lt;br /&gt;
This method is an instance method, having a user passed to it. It return the list of students that the current user has teamed up. It does not consider the teammates that are from calibration assignments&lt;br /&gt;
The test cases described check for the following scenarios: &lt;br /&gt;
1. When not in any team returns empty&lt;br /&gt;
2. When assigned in a cource_team returns empty&lt;br /&gt;
3. When assigned in a assignment_team return the list of teammates&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Function: get_due_date_data - Write a test case to get the due dates of the assignment.&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_peer_review_data - Write a test case to get the peer review data.===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_author_feedback_data - Write a test case to get the feedback response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_submission_data - Write a test case to import participants&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127659</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127659"/>
		<updated>2019-11-07T00:47:18Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg Full DB Schema]&lt;br /&gt;
&lt;br /&gt;
 tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage using the participant id&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
This function return the list of all the students that the logged on user has teamed up until now.&lt;br /&gt;
* started?&lt;br /&gt;
Checks if the current stage is &amp;quot;incomplete&amp;quot; and  content_submitted_in_current_stage? reviews_given_in_current_stage? || metareviews_given_in_current_stage? and return true and false&lt;br /&gt;
* topic_name&lt;br /&gt;
Return the name of the topic&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below are some of the functions tested&lt;br /&gt;
* Function: teamed_students - Write a test case to find teamed up students.&lt;br /&gt;
This method is an instance method, having a user passed to it. It return the list of students that the current user has teamed up. It does not consider the teammates that are from calibration assignments&lt;br /&gt;
The test cases described check for the following scenarios: &lt;br /&gt;
1. When not in any team returns empty&lt;br /&gt;
2. When assigned in a cource_team returns empty&lt;br /&gt;
3. When assigned in a assignment_team return the list of teammates&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Function: get_due_date_data - Write a test case to get the due dates of the assignment.&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_peer_review_data - Write a test case to get the peer review data.===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_author_feedback_data - Write a test case to get the feedback response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_submission_data - Write a test case to import participants&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127642</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127642"/>
		<updated>2019-11-07T00:42:32Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Description of the current project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg Full DB Schema]&lt;br /&gt;
&lt;br /&gt;
 tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
This function return the StudentTask from the participant with assignment, topic, current_stage using the participant id&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
This function return the list of all the students that the logged on user has teamed up until now.&lt;br /&gt;
* started?&lt;br /&gt;
Checks if the current stage is &amp;quot;incomplete&amp;quot; and  content_submitted_in_current_stage? reviews_given_in_current_stage? || metareviews_given_in_current_stage? and return true and false&lt;br /&gt;
* topic_name&lt;br /&gt;
Return the name of the topic&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below are some of the functions tested&lt;br /&gt;
* Function: teamed_students - Write a test case to find teamed up students.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Function: get_due_date_data - Write a test case to get the due dates of the assignment.&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_peer_review_data - Write a test case to get the peer review data.===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_author_feedback_data - Write a test case to get the feedback response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_submission_data - Write a test case to import participants&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ExpertizaDbSchema.jpg&amp;diff=127625</id>
		<title>File:ExpertizaDbSchema.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ExpertizaDbSchema.jpg&amp;diff=127625"/>
		<updated>2019-11-07T00:33:04Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: uploaded a new version of &amp;amp;quot;File:ExpertizaDbSchema.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127609</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127609"/>
		<updated>2019-11-07T00:27:26Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg DB Schema]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below are some of the functions tested&lt;br /&gt;
* Function: teamed_students - Write a test case to find teamed up students.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Function: get_due_date_data - Write a test case to get the due dates of the assignment.&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_peer_review_data - Write a test case to get the peer review data.===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_author_feedback_data - Write a test case to get the feedback response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Function: get_submission_data - Write a test case to import participants&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127595</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127595"/>
		<updated>2019-11-07T00:20:23Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Description of the current project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/7/7a/ExpertizaDbSchema.jpg DB Schema]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Task 1. Write a test case to . ===&lt;br /&gt;
* teamed_students&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 2. Write a test case to .===&lt;br /&gt;
* get_due_date_data&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 3. Write a test case to .===&lt;br /&gt;
* get_peer_review_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 4. Write a test case to .===&lt;br /&gt;
* get_author_feedback_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 5. Write a test case to import participants.===&lt;br /&gt;
* get_submission_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ExpertizaDbSchema.jpg&amp;diff=127591</id>
		<title>File:ExpertizaDbSchema.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ExpertizaDbSchema.jpg&amp;diff=127591"/>
		<updated>2019-11-07T00:19:14Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127583</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127583"/>
		<updated>2019-11-07T00:06:05Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Description of the current project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Task 1. Write a test case to . ===&lt;br /&gt;
* teamed_students&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 2. Write a test case to .===&lt;br /&gt;
* get_due_date_data&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 3. Write a test case to .===&lt;br /&gt;
* get_peer_review_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 4. Write a test case to .===&lt;br /&gt;
* get_author_feedback_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 5. Write a test case to import participants.===&lt;br /&gt;
* get_submission_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127582</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127582"/>
		<updated>2019-11-07T00:05:27Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Task 1. Write a test case to . ===&lt;br /&gt;
* teamed_students&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 2. Write a test case to .===&lt;br /&gt;
* get_due_date_data&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 3. Write a test case to .===&lt;br /&gt;
* get_peer_review_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 4. Write a test case to .===&lt;br /&gt;
* get_author_feedback_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 5. Write a test case to import participants.===&lt;br /&gt;
* get_submission_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127581</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127581"/>
		<updated>2019-11-07T00:04:43Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
The following mock objects were created/built before the commencement of automated testing for student_task.rb (model) code. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Task 1. Write a test case to . ===&lt;br /&gt;
* teamed_students&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 2. Write a test case to .===&lt;br /&gt;
* get_due_date_data&lt;br /&gt;
This method is an instance method, having an assignment and timeline_list list passed to it. The test cases described check for the following scenarios: &lt;br /&gt;
1. When an assignment passed to the method has no assignment attributes.&lt;br /&gt;
2. When an assignment passed to the method has some attributes but not the attribute due_at&lt;br /&gt;
3. When an assignment passed to the method has some attributes along with due_at&lt;br /&gt;
&lt;br /&gt;
due_at attribute is checked, upon which the timeline_list is populated with the updated_at and label values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 3. Write a test case to .===&lt;br /&gt;
* get_peer_review_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 4. Write a test case to .===&lt;br /&gt;
* get_author_feedback_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 5. Write a test case to import participants.===&lt;br /&gt;
* get_submission_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
&lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127403</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127403"/>
		<updated>2019-11-06T21:23:32Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Task 1. Write a test case to . ===&lt;br /&gt;
* teamed_students&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#teamed_students&amp;quot; do&lt;br /&gt;
    context 'when not in any team' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        expect(StudentTask.teamed_students(user3)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a cource_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([course_team])&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when assigned in a assignment_team ' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        allow(user).to receive(:teams).and_return([team])&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: assignment.id).and_return(participant)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).with(user_id: 5, parent_id: assignment.id).and_return(participant2)&lt;br /&gt;
        allow(Assignment).to receive(:find_by).with(id: team.parent_id).and_return(assignment)&lt;br /&gt;
        # allow(Team).to receive(:find).with(team.id).and_return(team)&lt;br /&gt;
        expect(StudentTask.teamed_students(user)).to eq({assignment.course_id =&amp;gt; [user2.fullname]})&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 2. Write a test case to .===&lt;br /&gt;
* get_due_date_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_due_date_data&amp;quot; do&lt;br /&gt;
    context 'when called with assignment having empty due dates' do&lt;br /&gt;
      it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
        timeline_list = []&lt;br /&gt;
        StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called with assignment having due date' do&lt;br /&gt;
      context 'and due_at value nil' do&lt;br /&gt;
        it &amp;quot;return empty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          due_date.due_at=nil;&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      context 'and due_at value not nil' do&lt;br /&gt;
        it &amp;quot;return iiiempty time_list array&amp;quot; do&lt;br /&gt;
          allow(due_date).to receive(:deadline_type).and_return(deadline_type)&lt;br /&gt;
          timeline_list = []&lt;br /&gt;
          assignment.due_dates = [due_date]&lt;br /&gt;
          StudentTask.get_due_date_data(assignment, timeline_list)&lt;br /&gt;
          expect(timeline_list).to eq([{&lt;br /&gt;
            :label=&amp;gt;(due_date.deadline_type.name + ' Deadline').humanize,&lt;br /&gt;
            :updated_at=&amp;gt;due_date.due_at.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
          }])&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 3. Write a test case to .===&lt;br /&gt;
* get_peer_review_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_peer_review_data&amp;quot; do&lt;br /&gt;
    context 'when no review response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_peer_review_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to review response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(ReviewResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:round).and_return(1)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_peer_review_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Round 1 peer review&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 4. Write a test case to .===&lt;br /&gt;
* get_author_feedback_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;#get_author_feedback_data&amp;quot; do&lt;br /&gt;
    context 'when no feedback response mapped' do&lt;br /&gt;
      it 'returns empty' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        StudentTask.get_author_feedback_data(user2,timeline_list)&lt;br /&gt;
        expect(timeline_list).to eq([])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when mapped to feedback response map' do&lt;br /&gt;
      it 'returns timeline array' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(FeedbackResponseMap).to receive_message_chain(:where, :find_each).with(reviewer_id: 1).with(no_args).and_yield(review_response_map)&lt;br /&gt;
        allow(review_response_map).to receive(:id).and_return(1)&lt;br /&gt;
        allow(Response).to receive_message_chain(:where, :last).with(map_id: 1).with(no_args).and_return(response)&lt;br /&gt;
        allow(response).to receive(:updated_at).and_return(Time.now)&lt;br /&gt;
        timevalue = Time.now.strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_author_feedback_data(1,timeline_list)).to eq([{:id=&amp;gt;1, :label=&amp;gt;&amp;quot;Author feedback&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
===Task 5. Write a test case to import participants.===&lt;br /&gt;
* get_submission_data&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#get_submission_data' do&lt;br /&gt;
    context 'when no submission data mapped' do&lt;br /&gt;
      it 'returns nil' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq(nil)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and not submit hyperlink or Remove hyperlink' do&lt;br /&gt;
      it 'returns timeline_list' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('testing_label')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Testing label&amp;quot;, :updated_at=&amp;gt;timevalue}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is submit_hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Submit Hyperlink')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Submit hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when submission data mapped and operation is Remove Hyperlink' do&lt;br /&gt;
      it 'returns timeline_list with link' do&lt;br /&gt;
        timeline_list=[]&lt;br /&gt;
        allow(SubmissionRecord).to receive_message_chain(:where, :find_each).with(team_id: 1, assignment_id: 1).with(no_args).and_yield(submission_record)&lt;br /&gt;
        allow(submission_record).to receive(:operation).and_return('Remove Hyperlink')&lt;br /&gt;
        timevalue = Time.new(2019).strftime('%a, %d %b %Y %H:%M')&lt;br /&gt;
        allow(submission_record).to receive(:updated_at).and_return(Time.new(2019))&lt;br /&gt;
        expect(StudentTask.get_submission_data(1,1,timeline_list)).to eq([{:label=&amp;gt;&amp;quot;Remove hyperlink&amp;quot;, :updated_at=&amp;gt;timevalue, :link=&amp;gt;&amp;quot;www.wolfware.edu&amp;quot;}])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lorem Ipsum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
&lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127395</id>
		<title>CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1955.Write_unit_tests_for_student_task.rb&amp;diff=127395"/>
		<updated>2019-11-06T21:14:23Z</updated>

		<summary type="html">&lt;p&gt;Tkundra: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[https://expertiza.ncsu.edu/ Expertiza] is an open source project based on [https://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About RSpec ==&lt;br /&gt;
&lt;br /&gt;
RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the &amp;quot;behavior&amp;quot; of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a [https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests Pull Request].&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added. The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.&lt;br /&gt;
&lt;br /&gt;
There are few tests for student_task.rb. We had to test the following functions:&lt;br /&gt;
&lt;br /&gt;
* complete?&lt;br /&gt;
This function returns true if the participant stage deadline is &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* content_submitted_in_current_stage?&lt;br /&gt;
This function returns true if the participant has submitted hyperlinks in the current stage and the stage is in &amp;quot;submission&amp;quot;&lt;br /&gt;
* hyperlinks&lt;br /&gt;
This function returns all the hyperlinks submitted by the participant team&lt;br /&gt;
* in_work_stage?&lt;br /&gt;
A assignment is said to be in work stage if its stage is any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot;&lt;br /&gt;
* incomplete?&lt;br /&gt;
This function returns true if the participant stage deadline is not &amp;quot;complete&amp;quot; or else return false.&lt;br /&gt;
* metareviews_given? * reviews_given?&lt;br /&gt;
A participant can review other people's work and add comments.&lt;br /&gt;
Also a user can review a review, called &amp;quot;metareview&amp;quot; that is given to him.&lt;br /&gt;
A review comment is mapped to assignments or other reviews by the table response_tags via the reviewed_object_id.&lt;br /&gt;
This method checks if the participant has given any metareview and return true otherwise.&lt;br /&gt;
* metareviews_given_in_current_stage?&lt;br /&gt;
This function checks if the assignment is in &amp;quot;metareview&amp;quot; stage and metareviews. &lt;br /&gt;
* not_started?&lt;br /&gt;
This function checks if the assignment is in any of &amp;quot;submission&amp;quot;, &amp;quot;review&amp;quot; or &amp;quot;metareview&amp;quot; stage &lt;br /&gt;
* relative_deadline&lt;br /&gt;
* reviews_given_in_current_stage?&lt;br /&gt;
* revision?&lt;br /&gt;
* from_participant(participant)&lt;br /&gt;
* from_participant_id(id)&lt;br /&gt;
* from_user(user)&lt;br /&gt;
* get_author_feedback_data(participant_id, timeline_list)&lt;br /&gt;
* get_due_date_data(assignment, timeline_list)&lt;br /&gt;
* get_peer_review_data(participant_id, timeline_list)&lt;br /&gt;
* get_submission_data(assignment_id, team_id, timeline_list)&lt;br /&gt;
* get_timeline_data(assignment, participant, team)&lt;br /&gt;
* teamed_students(user, ip_address = nil)&lt;br /&gt;
* started?&lt;br /&gt;
* topic_name&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
* Mock Objects&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) }&lt;br /&gt;
let(:participant3) { build(:participant, id: 3, user_id: user3.id, parent_id: assignment2.id) }&lt;br /&gt;
let(:user) { create(:student) }&lt;br /&gt;
let(:user2) { create(:student, name: &amp;quot;qwertyui&amp;quot;, id: 5) }&lt;br /&gt;
let(:user3) { create(:student, name: &amp;quot;qwertyui1234&amp;quot;, id: 6) }&lt;br /&gt;
let(:course) { build(:course) }&lt;br /&gt;
let(:assignment) { build(:assignment, name: 'assignment 1') }&lt;br /&gt;
let(:assignment2) { create(:assignment, name: 'assignment 2', is_calibrated: true) }&lt;br /&gt;
let(:team) { create(:assignment_team, id: 1, name: 'team 1', parent_id: assignment.id, users: [user, user2]) }&lt;br /&gt;
let(:team2) { create(:assignment_team, id: 2, name: 'team 2', parent_id: assignment2.id, users: [user3]) }&lt;br /&gt;
let(:team_user) { create(:team_user, id: 3, team_id: team.id, user_id: user.id) }&lt;br /&gt;
let(:team_user2) { create(:team_user, id: 4, team_id: team.id, user_id: user2.id) }&lt;br /&gt;
let(:team2_user3) { create(:team_user, id: 5, team_id: team2.id, user_id: user3.id) }&lt;br /&gt;
let(:course_team) { create(:course_team, id: 3, name: 'course team 1', parent_id: course.id) }&lt;br /&gt;
let(:cource_team_user) { create(:team_user, id: 6, team_id: course_team.id, user_id: user.id) }&lt;br /&gt;
let(:cource_team_user2) { create(:team_user, id: 7, team_id: course_team.id, user_id: user2.id) }&lt;br /&gt;
let(:topic) { build(:topic) }&lt;br /&gt;
let(:topic2) { create(:topic, topic_name: &amp;quot;TestReview&amp;quot;) }&lt;br /&gt;
let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
let(:deadline_type) { build(:deadline_type, id: 1) }&lt;br /&gt;
let(:review_response_map) { build(:review_response_map, assignment: assignment, reviewer: participant, reviewee: team2) }&lt;br /&gt;
let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) }&lt;br /&gt;
let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:response2) { build(:response, id: 2, map_id: 1, response_map: review_response_map) }&lt;br /&gt;
let(:submission_record) {build(:submission_record, id:1, team_id: 1, assignment_id: 1) }    #added for submission_record method call test.&lt;br /&gt;
let(:student_task) do&lt;br /&gt;
  StudentTask.new(&lt;br /&gt;
    participant: participant,&lt;br /&gt;
    assignment: participant.assignment,&lt;br /&gt;
    topic: participant.topic,&lt;br /&gt;
    current_stage: participant.current_stage,&lt;br /&gt;
    stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)&lt;br /&gt;
  )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Team ===&lt;br /&gt;
&lt;br /&gt;
Carmen Bentley,Mentor&lt;br /&gt;
&lt;br /&gt;
* Tushar Kundra,tkundra&lt;br /&gt;
&lt;br /&gt;
* Ram Chavali,ramlohith&lt;br /&gt;
&lt;br /&gt;
* Ayushi Rungta,Rungta1001&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.&lt;br /&gt;
&lt;br /&gt;
You can run RSpec tests by executing the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/models/student_task_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you can see the detailed coverage information by opening this file in your Expertiza folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
coverage/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Our work====&lt;br /&gt;
The code we created can be found below. We have also linked the video of our tests running with coverage to showcase the work we have done.&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1549 Pull request]&lt;br /&gt;
*[https://drive.google.com/file/d/1O-1k3mqo1yRMp0yxgTIuM3P5cegB5DCy/view?usp=sharing Video of tests running]&lt;br /&gt;
&lt;br /&gt;
Test Coverage:  [http://wiki.expertiza.ncsu.edu/images/b/b0/E1955before.png Initial]  [http://wiki.expertiza.ncsu.edu/images/0/05/E1955after.png Final]&lt;br /&gt;
&lt;br /&gt;
== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Complete the insufficient unit tests for student_task.rb. &lt;br /&gt;
&lt;br /&gt;
* Increase path coverage from only 31.91% with 30 lines covered to above 92.55% with 87 lines covered.&lt;br /&gt;
&lt;br /&gt;
* Cover edge cases.&lt;br /&gt;
&lt;br /&gt;
* High branch coverage to be achieved.&lt;br /&gt;
&lt;br /&gt;
There are different tasks that a student can perform. &lt;br /&gt;
* He can see all the assignments that he has been assigned to.&lt;br /&gt;
* He can see details of each assignment like marks, his team, send invitation to student to join a team&lt;br /&gt;
* Review other students' work&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4c/StudentTaskHomePage.png Student Task Home Page]&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/images/4/4d/StudentTaskAssignmentTasks.png Assignment Submission Tasks]&lt;br /&gt;
&lt;br /&gt;
== Running the Project Locally ==&lt;br /&gt;
The project could be run locally by cloning the Github repository [https://github.com/tusharkundra/expertiza Expertiza] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues/Erros During Testing ==&lt;br /&gt;
* While creating the test for &amp;quot;reviews_given?&amp;quot;, given below, it seems the function is returning string value instead of boolean value as &amp;quot;j.class.to_s[/Review/]&amp;quot; gives a string when the class of &amp;quot;j&amp;quot; starts with &amp;quot;Review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def reviews_given?&lt;br /&gt;
    response_maps.inject(nil) {|i, j| i || (j.response &amp;amp;&amp;amp; j.class.to_s[/Review/]) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tkundra</name></author>
	</entry>
</feed>