<?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=Ywei8</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=Ywei8"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ywei8"/>
	<updated>2026-07-21T15:24:52Z</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_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106661</id>
		<title>CSC/ECE 517 Fall 2016 E1633. Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106661"/>
		<updated>2016-12-07T19:26:24Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About Expertiza ===&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication. Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
=== Motivation ===&lt;br /&gt;
This project provides an opportunity for students with likeminded interests to collaborate and work as a team to enhance the existing source code of expertiza so as to improve functionality, remove bugs and implement altogether new features. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
&lt;br /&gt;
=== What it does ===&lt;br /&gt;
Currently, Expertiza has a quizzing feature which allow student authors to create quiz questions and “test&amp;quot; the peer-reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires.&lt;br /&gt;
&lt;br /&gt;
=== Problems with it ===&lt;br /&gt;
The number one reason that we plan to refactor the quizzing feature is that its design is not consistent with the current questions and questionnaires.&lt;br /&gt;
Repetition of source code can be observed in quite a few areas of the system, which can be avoided. The system does not adhere to the Rails principle of Convention over Configuration and Ruby naming conventions are violated in certain segments of the code.&lt;br /&gt;
There are 4 methods which are “edit”, “view_question_text”, “complete” and “view_completed_question” to implement for student_quiz. We need to focus on these for methods.&lt;br /&gt;
&lt;br /&gt;
=== What needs to be done: ===&lt;br /&gt;
*There are 3 different types of questions supported in quizzing feature: multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
*Change the views (creating quizzes, viewing quizzes, filling in quizzes and viewing finished quizzes) to call your new model methods accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
The picture below shows our logic of the project.&lt;br /&gt;
[[File:E1633.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
Before the refactoring the &amp;quot;edit&amp;quot;,&amp;quot;complete&amp;quot;,&amp;quot;view_completed_question&amp;quot; method is written in some view files such as questionnaires and student_quizzes. But all we have to do is to rewrite it in the three models such as multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
The code below is our truefalse.rb file. There is three methods in this file. Every method will be called if it is needed instead of a new method written in view.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class TrueFalse &amp;lt; QuizQuestion&lt;br /&gt;
  def edit&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;textarea cols=&amp;quot;100&amp;quot; name=&amp;quot;question[' + self.id.to_s + '][txt]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;question_' + self.id.to_s + '_txt&amp;quot;&amp;gt;' + self.txt + '&amp;lt;/textarea&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;True&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[0].iscorrect&lt;br /&gt;
    html += '/&amp;gt;True'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;False&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[1].iscorrect&lt;br /&gt;
    html += '/&amp;gt;False'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html.html_safe&lt;br /&gt;
  end&lt;br /&gt;
  def complete&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = &amp;quot;&amp;quot;&lt;br /&gt;
    for i in 0..1&lt;br /&gt;
      txt = quiz_question_choices[i].txt&lt;br /&gt;
      html += &amp;quot;&amp;lt;input name = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;id = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}&amp;quot; + &amp;quot;_&amp;quot; + &amp;quot;#{i + 1}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;value = &amp;quot; + &amp;quot;\&amp;quot;#{quiz_question_choices[i].txt}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;type=\&amp;quot;radio\&amp;quot;/&amp;gt;&amp;quot;&lt;br /&gt;
      if i == 0&lt;br /&gt;
        html += &amp;quot;True&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        html += &amp;quot;False&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      html += &amp;quot;&amp;lt;/br&amp;gt;&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  def view_completed_question(user_answer)&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = ''&lt;br /&gt;
    html += 'Correct Answer is: &amp;lt;b&amp;gt;'&lt;br /&gt;
    if quiz_question_choices[0].iscorrect&lt;br /&gt;
      html+='True&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html+='False&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html += 'Your answer is: &amp;lt;b&amp;gt;' + user_answer.first.comments.to_s&lt;br /&gt;
    if user_answer.first.answer==1&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html +='&amp;lt;/b&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;hr&amp;gt;'&lt;br /&gt;
    html.html_safe&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;
== Testing the User Interface ==&lt;br /&gt;
Since this project involved code refactoring, no new functionality was added. But here are tests for each method to verify they are working correctly.&lt;br /&gt;
&lt;br /&gt;
view_question_text&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a quiz assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*First you will have to create a quiz by clicking on the link &amp;quot;Create Quiz&amp;quot;.&lt;br /&gt;
*Select &amp;quot;View quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in Bold.&lt;br /&gt;
&lt;br /&gt;
'''edit'''&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a Quiz Assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Edit quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices, each in an editable text field. The correct choice(s) will be checked.&lt;br /&gt;
&lt;br /&gt;
'''complete'''&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Take Quizzes&amp;quot;.&lt;br /&gt;
*Click 'Begin'.&lt;br /&gt;
*You should see each question, followed by the choices. You can record your answers for each questions and then click 'submit'. Your answers will be saved.&lt;br /&gt;
view_completed_question&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created/taken a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link and take the quiz.&lt;br /&gt;
*Find a finished quiz and click on 'View'.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in bold and your recorded answer will be shown.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106660</id>
		<title>CSC/ECE 517 Fall 2016 E1633. Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106660"/>
		<updated>2016-12-07T19:25:14Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About Expertiza ===&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication. Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
=== Motivation ===&lt;br /&gt;
This project provides an opportunity for students with likeminded interests to collaborate and work as a team to enhance the existing source code of expertiza so as to improve functionality, remove bugs and implement altogether new features. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
&lt;br /&gt;
=== What it does ===&lt;br /&gt;
Currently, Expertiza has a quizzing feature which allow student authors to create quiz questions and “test&amp;quot; the peer-reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires.&lt;br /&gt;
&lt;br /&gt;
=== Problems with it ===&lt;br /&gt;
The number one reason that we plan to refactor the quizzing feature is that its design is not consistent with the current questions and questionnaires.&lt;br /&gt;
Repetition of source code can be observed in quite a few areas of the system, which can be avoided. The system does not adhere to the Rails principle of Convention over Configuration and Ruby naming conventions are violated in certain segments of the code.&lt;br /&gt;
There are 4 methods which are “edit”, “view_question_text”, “complete” and “view_completed_question” to implement for student_quiz. We need to focus on these for methods.&lt;br /&gt;
&lt;br /&gt;
=== What needs to be done: ===&lt;br /&gt;
*There are 3 different types of questions supported in quizzing feature: multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
*Change the views (creating quizzes, viewing quizzes, filling in quizzes and viewing finished quizzes) to call your new model methods accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
The picture below shows our logic of the project.&lt;br /&gt;
[[File:E1633.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
Before the refactoring the &amp;quot;edit&amp;quot;,&amp;quot;complete&amp;quot;,&amp;quot;view_completed_question&amp;quot; method is written in some view files such as questionnaires and student_quizzes. But all we have to do is to rewrite it in the three models such as multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
The code below is our truefalse.rb file. There is three methods in this file. Every method will be called if it is needed instead of a new method written in view.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class TrueFalse &amp;lt; QuizQuestion&lt;br /&gt;
  def edit&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;textarea cols=&amp;quot;100&amp;quot; name=&amp;quot;question[' + self.id.to_s + '][txt]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;question_' + self.id.to_s + '_txt&amp;quot;&amp;gt;' + self.txt + '&amp;lt;/textarea&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;True&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[0].iscorrect&lt;br /&gt;
    html += '/&amp;gt;True'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;False&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[1].iscorrect&lt;br /&gt;
    html += '/&amp;gt;False'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html.html_safe&lt;br /&gt;
  end&lt;br /&gt;
  def complete&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = &amp;quot;&amp;quot;&lt;br /&gt;
    for i in 0..1&lt;br /&gt;
      txt = quiz_question_choices[i].txt&lt;br /&gt;
      html += &amp;quot;&amp;lt;input name = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;id = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}&amp;quot; + &amp;quot;_&amp;quot; + &amp;quot;#{i + 1}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;value = &amp;quot; + &amp;quot;\&amp;quot;#{quiz_question_choices[i].txt}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;type=\&amp;quot;radio\&amp;quot;/&amp;gt;&amp;quot;&lt;br /&gt;
      if i == 0&lt;br /&gt;
        html += &amp;quot;True&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        html += &amp;quot;False&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      html += &amp;quot;&amp;lt;/br&amp;gt;&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  def view_completed_question(user_answer)&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = ''&lt;br /&gt;
    html += 'Correct Answer is: &amp;lt;b&amp;gt;'&lt;br /&gt;
    if quiz_question_choices[0].iscorrect&lt;br /&gt;
      html+='True&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html+='False&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html += 'Your answer is: &amp;lt;b&amp;gt;' + user_answer.first.comments.to_s&lt;br /&gt;
    if user_answer.first.answer==1&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html +='&amp;lt;/b&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;hr&amp;gt;'&lt;br /&gt;
    html.html_safe&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;
== Testing the User Interface ==&lt;br /&gt;
Since this project involved code refactoring, no new functionality was added. But here are tests for each method to verify they are working correctly.&lt;br /&gt;
'''view_question_text'''&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a quiz assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*First you will have to create a quiz by clicking on the link &amp;quot;Create Quiz&amp;quot;.&lt;br /&gt;
*Select &amp;quot;View quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in Bold.&lt;br /&gt;
'''edit'''&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a Quiz Assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Edit quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices, each in an editable text field. The correct choice(s) will be checked.&lt;br /&gt;
'''complete'''&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Take Quizzes&amp;quot;.&lt;br /&gt;
*Click 'Begin'.&lt;br /&gt;
*You should see each question, followed by the choices. You can record your answers for each questions and then click 'submit'. Your answers will be saved.&lt;br /&gt;
view_completed_question&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created/taken a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link and take the quiz.&lt;br /&gt;
*Find a finished quiz and click on 'View'.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in bold and your recorded answer will be shown.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106659</id>
		<title>CSC/ECE 517 Fall 2016 E1633. Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106659"/>
		<updated>2016-12-07T19:24:31Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About Expertiza ===&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication. Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
=== Motivation ===&lt;br /&gt;
This project provides an opportunity for students with likeminded interests to collaborate and work as a team to enhance the existing source code of expertiza so as to improve functionality, remove bugs and implement altogether new features. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
&lt;br /&gt;
=== What it does ===&lt;br /&gt;
Currently, Expertiza has a quizzing feature which allow student authors to create quiz questions and “test&amp;quot; the peer-reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires.&lt;br /&gt;
&lt;br /&gt;
=== Problems with it ===&lt;br /&gt;
The number one reason that we plan to refactor the quizzing feature is that its design is not consistent with the current questions and questionnaires.&lt;br /&gt;
Repetition of source code can be observed in quite a few areas of the system, which can be avoided. The system does not adhere to the Rails principle of Convention over Configuration and Ruby naming conventions are violated in certain segments of the code.&lt;br /&gt;
There are 4 methods which are “edit”, “view_question_text”, “complete” and “view_completed_question” to implement for student_quiz. We need to focus on these for methods.&lt;br /&gt;
&lt;br /&gt;
=== What needs to be done: ===&lt;br /&gt;
*There are 3 different types of questions supported in quizzing feature: multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
*Change the views (creating quizzes, viewing quizzes, filling in quizzes and viewing finished quizzes) to call your new model methods accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
The picture below shows our logic of the project.&lt;br /&gt;
[[File:E1633.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
Before the refactoring the &amp;quot;edit&amp;quot;,&amp;quot;complete&amp;quot;,&amp;quot;view_completed_question&amp;quot; method is written in some view files such as questionnaires and student_quizzes. But all we have to do is to rewrite it in the three models such as multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
The code below is our truefalse.rb file. There is three methods in this file. Every method will be called if it is needed instead of a new method written in view.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class TrueFalse &amp;lt; QuizQuestion&lt;br /&gt;
  def edit&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;textarea cols=&amp;quot;100&amp;quot; name=&amp;quot;question[' + self.id.to_s + '][txt]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;question_' + self.id.to_s + '_txt&amp;quot;&amp;gt;' + self.txt + '&amp;lt;/textarea&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;True&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[0].iscorrect&lt;br /&gt;
    html += '/&amp;gt;True'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;False&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[1].iscorrect&lt;br /&gt;
    html += '/&amp;gt;False'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html.html_safe&lt;br /&gt;
  end&lt;br /&gt;
  def complete&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = &amp;quot;&amp;quot;&lt;br /&gt;
    for i in 0..1&lt;br /&gt;
      txt = quiz_question_choices[i].txt&lt;br /&gt;
      html += &amp;quot;&amp;lt;input name = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;id = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}&amp;quot; + &amp;quot;_&amp;quot; + &amp;quot;#{i + 1}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;value = &amp;quot; + &amp;quot;\&amp;quot;#{quiz_question_choices[i].txt}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;type=\&amp;quot;radio\&amp;quot;/&amp;gt;&amp;quot;&lt;br /&gt;
      if i == 0&lt;br /&gt;
        html += &amp;quot;True&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        html += &amp;quot;False&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      html += &amp;quot;&amp;lt;/br&amp;gt;&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  def view_completed_question(user_answer)&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = ''&lt;br /&gt;
    html += 'Correct Answer is: &amp;lt;b&amp;gt;'&lt;br /&gt;
    if quiz_question_choices[0].iscorrect&lt;br /&gt;
      html+='True&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html+='False&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html += 'Your answer is: &amp;lt;b&amp;gt;' + user_answer.first.comments.to_s&lt;br /&gt;
    if user_answer.first.answer==1&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html +='&amp;lt;/b&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;hr&amp;gt;'&lt;br /&gt;
    html.html_safe&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;
== Testing the User Interface ==&lt;br /&gt;
Since this project involved code refactoring, no new functionality was added. But here are tests for each method to verify they are working correctly.&lt;br /&gt;
view_question_text&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a quiz assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*First you will have to create a quiz by clicking on the link &amp;quot;Create Quiz&amp;quot;.&lt;br /&gt;
*Select &amp;quot;View quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in Bold.&lt;br /&gt;
edit&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a Quiz Assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Edit quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices, each in an editable text field. The correct choice(s) will be checked.&lt;br /&gt;
complete&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Take Quizzes&amp;quot;.&lt;br /&gt;
*Click 'Begin'.&lt;br /&gt;
*You should see each question, followed by the choices. You can record your answers for each questions and then click 'submit'. Your answers will be saved.&lt;br /&gt;
view_completed_question&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created/taken a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link and take the quiz.&lt;br /&gt;
*Find a finished quiz and click on 'View'.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in bold and your recorded answer will be shown.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106658</id>
		<title>CSC/ECE 517 Fall 2016 E1633. Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106658"/>
		<updated>2016-12-07T19:23:43Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About Expertiza ===&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication. Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
=== Motivation ===&lt;br /&gt;
This project provides an opportunity for students with likeminded interests to collaborate and work as a team to enhance the existing source code of expertiza so as to improve functionality, remove bugs and implement altogether new features. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
&lt;br /&gt;
=== What it does ===&lt;br /&gt;
Currently, Expertiza has a quizzing feature which allow student authors to create quiz questions and “test&amp;quot; the peer-reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires.&lt;br /&gt;
&lt;br /&gt;
=== Problems with it ===&lt;br /&gt;
The number one reason that we plan to refactor the quizzing feature is that its design is not consistent with the current questions and questionnaires.&lt;br /&gt;
Repetition of source code can be observed in quite a few areas of the system, which can be avoided. The system does not adhere to the Rails principle of Convention over Configuration and Ruby naming conventions are violated in certain segments of the code.&lt;br /&gt;
There are 4 methods which are “edit”, “view_question_text”, “complete” and “view_completed_question” to implement for student_quiz. We need to focus on these for methods.&lt;br /&gt;
&lt;br /&gt;
=== What needs to be done: ===&lt;br /&gt;
*There are 3 different types of questions supported in quizzing feature: multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
*Change the views (creating quizzes, viewing quizzes, filling in quizzes and viewing finished quizzes) to call your new model methods accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
The picture below shows our logic of the project.&lt;br /&gt;
[[File:E1633.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
Before the refactoring the &amp;quot;edit&amp;quot;,&amp;quot;complete&amp;quot;,&amp;quot;view_completed_question&amp;quot; method is written in some view files such as questionnaires and student_quizzes. But all we have to do is to rewrite it in the three models such as multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
The code below is our truefalse.rb file. There is three methods in this file. Every method will be called if it is needed instead of a new method written in view.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class TrueFalse &amp;lt; QuizQuestion&lt;br /&gt;
  def edit&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;textarea cols=&amp;quot;100&amp;quot; name=&amp;quot;question[' + self.id.to_s + '][txt]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;question_' + self.id.to_s + '_txt&amp;quot;&amp;gt;' + self.txt + '&amp;lt;/textarea&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;True&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[0].iscorrect&lt;br /&gt;
    html += '/&amp;gt;True'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;quiz_question_choices[' + self.id.to_s + '][TrueFalse][1][iscorrect]&amp;quot; '&lt;br /&gt;
    html += 'id=&amp;quot;quiz_question_choices_' + self.id.to_s + '_TrueFalse_1_iscorrect_True&amp;quot; value=&amp;quot;False&amp;quot; '&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot; ' if quiz_question_choices[1].iscorrect&lt;br /&gt;
    html += '/&amp;gt;False'&lt;br /&gt;
    html += '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;br /&gt;
    html.html_safe&lt;br /&gt;
  end&lt;br /&gt;
  def complete&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = &amp;quot;&amp;quot;&lt;br /&gt;
    for i in 0..1&lt;br /&gt;
      txt = quiz_question_choices[i].txt&lt;br /&gt;
      html += &amp;quot;&amp;lt;input name = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;id = &amp;quot; + &amp;quot;\&amp;quot;#{self.id}&amp;quot; + &amp;quot;_&amp;quot; + &amp;quot;#{i + 1}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;value = &amp;quot; + &amp;quot;\&amp;quot;#{quiz_question_choices[i].txt}\&amp;quot; &amp;quot;&lt;br /&gt;
      html += &amp;quot;type=\&amp;quot;radio\&amp;quot;/&amp;gt;&amp;quot;&lt;br /&gt;
      if i == 0&lt;br /&gt;
        html += &amp;quot;True&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        html += &amp;quot;False&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      html += &amp;quot;&amp;lt;/br&amp;gt;&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  def view_completed_question(user_answer)&lt;br /&gt;
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)&lt;br /&gt;
    html = ''&lt;br /&gt;
    html += 'Correct Answer is: &amp;lt;b&amp;gt;'&lt;br /&gt;
    if quiz_question_choices[0].iscorrect&lt;br /&gt;
      html+='True&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html+='False&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html += 'Your answer is: &amp;lt;b&amp;gt;' + user_answer.first.comments.to_s&lt;br /&gt;
    if user_answer.first.answer==1&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    else&lt;br /&gt;
      html += '&amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;'&lt;br /&gt;
    end&lt;br /&gt;
    html +='&amp;lt;/b&amp;gt;'&lt;br /&gt;
    html += '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;hr&amp;gt;'&lt;br /&gt;
    html.html_safe&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;
== Testing the User Interface ==&lt;br /&gt;
Since this project involved code refactoring, no new functionality was added. But here are tests for each method to verify they are working correctly.&lt;br /&gt;
[edit] view_question_text&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a quiz assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*First you will have to create a quiz by clicking on the link &amp;quot;Create Quiz&amp;quot;.&lt;br /&gt;
*Select &amp;quot;View quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in Bold.&lt;br /&gt;
[edit] edit&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select a Quiz Assignment.&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Edit quiz&amp;quot;.&lt;br /&gt;
*You should see each question, followed by the choices, each in an editable text field. The correct choice(s) will be checked.&lt;br /&gt;
[edit] complete&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
*Select &amp;quot;Take Quizzes&amp;quot;.&lt;br /&gt;
*Click 'Begin'.&lt;br /&gt;
*You should see each question, followed by the choices. You can record your answers for each questions and then click 'submit'. Your answers will be saved.&lt;br /&gt;
[edit] view_completed_question&lt;br /&gt;
*Login as a student.&lt;br /&gt;
*Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
*Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
*If you haven't created/taken a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link and take the quiz.&lt;br /&gt;
*Find a finished quiz and click on 'View'.&lt;br /&gt;
*You should see each question, followed by the choices. The correct choice(s) will be in bold and your recorded answer will be shown.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E1633.png&amp;diff=106641</id>
		<title>File:E1633.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E1633.png&amp;diff=106641"/>
		<updated>2016-12-07T19:02:35Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: 111&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;111&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106638</id>
		<title>CSC/ECE 517 Fall 2016 E1633. Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1633._Refactor_different_question_types_from_quiz_feature&amp;diff=106638"/>
		<updated>2016-12-07T18:59:30Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: Created page with &amp;quot;== Introduction == === About Expertiza === Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tool...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About Expertiza ===&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication. Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
=== Motivation ===&lt;br /&gt;
This project provides an opportunity for students with likeminded interests to collaborate and work as a team to enhance the existing source code of expertiza so as to improve functionality, remove bugs and implement altogether new features. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
&lt;br /&gt;
=== What it does ===&lt;br /&gt;
Currently, Expertiza has a quizzing feature which allow student authors to create quiz questions and “test&amp;quot; the peer-reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires.&lt;br /&gt;
&lt;br /&gt;
=== Problems with it ===&lt;br /&gt;
The number one reason that we plan to refactor the quizzing feature is that its design is not consistent with the current questions and questionnaires.&lt;br /&gt;
Repetition of source code can be observed in quite a few areas of the system, which can be avoided. The system does not adhere to the Rails principle of Convention over Configuration and Ruby naming conventions are violated in certain segments of the code.&lt;br /&gt;
There are 4 methods which are “edit”, “view_question_text”, “complete” and “view_completed_question” to implement for student_quiz. We need to focus on these for methods.&lt;br /&gt;
&lt;br /&gt;
=== What needs to be done: ===&lt;br /&gt;
*There are 3 different types of questions supported in quizzing feature: multiple choice checkbox, multiple choice radio, true/false.&lt;br /&gt;
*Change the views (creating quizzes, viewing quizzes, filling in quizzes and viewing finished quizzes) to call your new model methods accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
The picture below shows our logic of the project.&lt;br /&gt;
[[File:E1633.jpg]]&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E1633.jpg&amp;diff=106636</id>
		<title>File:E1633.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E1633.jpg&amp;diff=106636"/>
		<updated>2016-12-07T18:50:43Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105530</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105530"/>
		<updated>2016-11-14T01:29:23Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
[[File:hello1234.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Schedule ==&lt;br /&gt;
11/07  - 11/15    Design work&lt;br /&gt;
&lt;br /&gt;
11/14                 Discuss with instructor&lt;br /&gt;
   &lt;br /&gt;
11/14  - 11/20    Write first version&lt;br /&gt;
&lt;br /&gt;
11/20 - 11/25     Debug and test&lt;br /&gt;
&lt;br /&gt;
11/25 - 12/02     Final deployment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workload Assignment ==&lt;br /&gt;
&lt;br /&gt;
Refactor: Yi Wei &lt;br /&gt;
&lt;br /&gt;
Test: JunYi Liu(Last 2 bullets), Zhongzhi Qi(First 2 bullets)&lt;br /&gt;
&lt;br /&gt;
Deployment: Lei Zhang&lt;br /&gt;
&lt;br /&gt;
Document Writing: Everyone&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105529</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105529"/>
		<updated>2016-11-14T01:28:24Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
[[File:hello1234.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Schedule ==&lt;br /&gt;
11/07  - 11/15    Design work&lt;br /&gt;
&lt;br /&gt;
11/14                 Talk with instructor&lt;br /&gt;
   &lt;br /&gt;
11/14  - 11/20    Write first version&lt;br /&gt;
&lt;br /&gt;
11/20 - 11/25     Debug and test&lt;br /&gt;
&lt;br /&gt;
11/25 - 12/02     Final deployment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workload Assignment ==&lt;br /&gt;
&lt;br /&gt;
Refactor: Yi Wei &lt;br /&gt;
&lt;br /&gt;
Test: JunYi Liu(Last 2 bullets), Zhongzhi Qi(First 2 bullets)&lt;br /&gt;
&lt;br /&gt;
Deployment: Lei Zhang&lt;br /&gt;
&lt;br /&gt;
Document Writing: Everyone&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105528</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105528"/>
		<updated>2016-11-14T01:28:03Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
[[File:hello1234.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Schedule ==&lt;br /&gt;
11/07  - 11/15    Design work&lt;br /&gt;
&lt;br /&gt;
11/14                 Talk with instructor&lt;br /&gt;
   &lt;br /&gt;
11/14  - 11/20    Write first version&lt;br /&gt;
&lt;br /&gt;
11/20 - 11/25     Debug and test&lt;br /&gt;
&lt;br /&gt;
11/25 - 12/02     Final deployment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workload Assignment ==&lt;br /&gt;
&lt;br /&gt;
Refactor: Yi Wei &lt;br /&gt;
&lt;br /&gt;
Test: JunYi Liu(Last 2 bullets), Zhongzhi Qi(First 2 bullets)&lt;br /&gt;
&lt;br /&gt;
Deployment: Lei Zhang&lt;br /&gt;
&lt;br /&gt;
Document Writing: Everyone&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105527</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105527"/>
		<updated>2016-11-14T01:26:56Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
[[File:hello1234.png]]&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
== Schedule ==&lt;br /&gt;
11/07  - 11/15    Design work&lt;br /&gt;
&lt;br /&gt;
11/14                 Talk with instructor&lt;br /&gt;
   &lt;br /&gt;
11/14  - 11/20    Write first version&lt;br /&gt;
&lt;br /&gt;
11/20 - 11/25     Debug and test&lt;br /&gt;
&lt;br /&gt;
11/25 - 12/02     Final deployment&lt;br /&gt;
&lt;br /&gt;
== Workload Assignment ==&lt;br /&gt;
&lt;br /&gt;
Refactor: Yi Wei &lt;br /&gt;
&lt;br /&gt;
Test: JunYi Liu(Last 2 bullets), Zhongzhi Qi(First 2 bullets)&lt;br /&gt;
&lt;br /&gt;
Deployment: Lei Zhang&lt;br /&gt;
&lt;br /&gt;
Document Writing: Everyone&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105526</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105526"/>
		<updated>2016-11-14T01:25:37Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
== Workflow ==&lt;br /&gt;
[[File:hello1234.png]]&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
== Schedule ==&lt;br /&gt;
11/07  - 11/15    Design work&lt;br /&gt;
11/14                 Talk with instructor    &lt;br /&gt;
11/14  - 11/20    Write first version&lt;br /&gt;
11/20 - 11/25     Debug and test&lt;br /&gt;
11/25 - 12/02     Final deployment&lt;br /&gt;
&lt;br /&gt;
== Workload Assignment ==&lt;br /&gt;
&lt;br /&gt;
Refactor: Yi Wei &lt;br /&gt;
Test: JunYi Liu(Last 2 bullets), Zhongzhi Qi(First 2 bullets)&lt;br /&gt;
Deployment: Lei Zhang&lt;br /&gt;
Document Writing: Everyone&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105516</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105516"/>
		<updated>2016-11-14T01:13:34Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Testing: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing:===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Gg.jpg&amp;diff=105515</id>
		<title>File:Gg.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Gg.jpg&amp;diff=105515"/>
		<updated>2016-11-14T01:11:53Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: uploaded a new version of &amp;amp;quot;File:Gg.jpg&amp;amp;quot;: ggg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;GGG&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Gg.jpg&amp;diff=105514</id>
		<title>File:Gg.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Gg.jpg&amp;diff=105514"/>
		<updated>2016-11-14T01:07:16Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: GGG&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;GGG&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105513</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105513"/>
		<updated>2016-11-14T01:04:38Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task description ==&lt;br /&gt;
Student-generated quizzes is the feature that students use for writing quizzes for the Wikipedia contribution assignment. In this project, we need to do refactoring and create functional tests for this feature. We need to refactor questionnaires_controller.rb and write the Rspec tests file in /specs/ folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
===Refactoring:===&lt;br /&gt;
There is some problems in valid_quiz method which is in questionnaires_controller. For now, this method checks the questions one by one. We will refactor it to make it able to create the quiz_question objects and quiz_choice objects. Then we need to call “quiz_question.valid?” to check whether the question is valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing:===&lt;br /&gt;
We will test the following functionalities:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*The instructor can set up an assignment which supports quizzing feature by&lt;br /&gt;
**Checking the “has quiz” box&lt;br /&gt;
**Setting the # of question for each set of quiz&lt;br /&gt;
**Setting in which deadline can student reviewers take the quizzes &lt;br /&gt;
*Student authors can create quizzes and edit them:&lt;br /&gt;
**They can create quizzes on the “Your work” page&lt;br /&gt;
**They can edit the quiz questions.&lt;br /&gt;
**They can view the quiz questions.&lt;br /&gt;
**If the quiz question has something missing, the system will flash an error message, either:&lt;br /&gt;
***The name of quiz is missing.&lt;br /&gt;
***The question text is missing for one or more questions.&lt;br /&gt;
***The choices are missing for one or more questions.&lt;br /&gt;
***The correct answer(s) have not been provided.&lt;br /&gt;
*Student reviewers can take the quizzes on the work they have reviewed/they need to review&lt;br /&gt;
**They need to request the artifact to review first. If this artifact has a quiz associated, they can take the quiz in the round which quiz-taking is allowed.&lt;br /&gt;
**They can click “take quiz” then request quizzes to take.&lt;br /&gt;
**They can fill in their choices on the quizzes.&lt;br /&gt;
**After taking the quizzes, and submitting, they will see their grade on the “Take quizzes” page&lt;br /&gt;
**On the “take quizzes” page, they can see their question-by-question scores for finished quizzes by clicking “view”&lt;br /&gt;
*Instructor can view the quiz questions and quiz scores on the tree display by clicking “view quiz questions” icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105512</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105512"/>
		<updated>2016-11-14T00:43:37Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Project Name */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction==&lt;br /&gt;
Expertiza is an online system that is used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations. The project is funded by the National Software Foundation (NSF), NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
Expertiza is an open-source project with the source code available as a public repository on GitHub. It is developed using Ruby on Rails and is increasingly becoming robust thanks to the innumerable bugs being fixed by the community. The project has a micro-blog on SourceForge where the developer community report bugs and document updates.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105511</id>
		<title>CSC/ECE 517 Fall 2016/E1681.Refactor and test the quizzing feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1681.Refactor_and_test_the_quizzing_feature&amp;diff=105511"/>
		<updated>2016-11-14T00:10:10Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: Created page with &amp;quot; == Project Name ==&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Name ==&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104481</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104481"/>
		<updated>2016-11-04T21:31:23Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Additional */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page, why we did work in this way and our work for the unit tests and the refactor part.&lt;br /&gt;
&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104480</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104480"/>
		<updated>2016-11-04T21:30:21Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104478</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104478"/>
		<updated>2016-11-04T21:18:21Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104477</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104477"/>
		<updated>2016-11-04T21:17:19Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
[[Media:Expertiza]] is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104475</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104475"/>
		<updated>2016-11-04T21:16:03Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Use [snake_case] for method names. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104474</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104474"/>
		<updated>2016-11-04T21:15:48Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Use snake_case for method names. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use [snake_case] for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104473</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104473"/>
		<updated>2016-11-04T21:15:13Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;br /&gt;
&lt;br /&gt;
==References ==&lt;br /&gt;
1. https://en.wikipedia.org/wiki/Snake_case&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104472</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104472"/>
		<updated>2016-11-04T21:07:34Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. To explain our work in a further step, we did a video on Youtube to show the broken leaderboard page and out work for the unit tests.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104465</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104465"/>
		<updated>2016-11-04T20:49:40Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* `end` at 148, 1 is not aligned with `def` at 129, 2. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in the line of 148.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104464</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104464"/>
		<updated>2016-11-04T20:49:21Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* `end` at 148, 1 is not aligned with `def` at 129, 2. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
A space is needed to be added in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104463</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104463"/>
		<updated>2016-11-04T20:48:51Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Avoid more than 3 levels of block nesting. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104462</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104462"/>
		<updated>2016-11-04T20:48:42Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Avoid more than 3 levels of block nesting. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104461</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104461"/>
		<updated>2016-11-04T20:48:31Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Avoid more than 3 levels of block nesting. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104460</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104460"/>
		<updated>2016-11-04T20:47:39Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter is usually lowercased within the compound and the first letter is either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104459</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104459"/>
		<updated>2016-11-04T20:46:52Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in which elements are separated with one underscore character and no spaces. Each element's initial letter usually lowercased within the compound and the first letter either upper or lower case.&lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104076</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=104076"/>
		<updated>2016-10-30T20:43:47Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103834</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103834"/>
		<updated>2016-10-29T03:53:43Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only in this project, and the next step is to make the page work.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103830</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103830"/>
		<updated>2016-10-29T03:52:59Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. As the guide of the director, we need to do the refactor and test only. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103829</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103829"/>
		<updated>2016-10-29T03:51:36Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
Currently in this web application the leaderboard page does not work. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files. We also ended up using the 'rspec/collection_matchers' class of rspec which allows us to match the number of items in a collection for an object. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
The Leaderboard Class did not have any unit tests associated with it coming into this project so we have to create unit tests from scratch. Upon analysis of this class, we noticed that Leaderboard did not hold any variables and was only made up of static methods. So the first round of unit tests that were created made sure that each method could be called from the Leaderboard class with the correct number of arguments. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;Leaderboard responds to get_assignment_mapping&amp;quot; do&lt;br /&gt;
    expect(Leaderboard).to respond_to(:get_assignment_mapping).with(3).argument&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Next we needed to go through the methods and create tests for them. But in order to do this we had to make objects that this class depended on since this class takes the values from other classes to output arrays and hashes. Factories were used to create these objects with a few variables being overridden &lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    @student1 = create(:student, name: &amp;quot;Student1&amp;quot;, fullname: &amp;quot;Student1 Test&amp;quot;, email: &amp;quot;student1@mail.com&amp;quot; )&lt;br /&gt;
    @student2 = create(:student, name: &amp;quot;Student2&amp;quot;, fullname: &amp;quot;Student2 Test&amp;quot;, email: &amp;quot;student2@mail.com&amp;quot; )&lt;br /&gt;
    @instructor = create(:instructor)&lt;br /&gt;
    @course = create(:course)&lt;br /&gt;
    @assignment = create(:assignment, name: &amp;quot;Assign1&amp;quot;, course: nil)&lt;br /&gt;
    @assignment2 = create(:assignment, name: &amp;quot;Assign2&amp;quot;)&lt;br /&gt;
    @participant = create(:participant, parent_id: @assignment.id, user_id: @student1.id)&lt;br /&gt;
    @participant2 = create(:participant, parent_id: @assignment2.id, user_id: @student2.id)&lt;br /&gt;
    @questionnaire=create(:questionnaire)&lt;br /&gt;
    @assignment_questionnaire1 =create(:assignment_questionnaire, user_id: @student1.id, assignment: @assignment)&lt;br /&gt;
    @assignment_questionnaire2 =create(:assignment_questionnaire, user_id: @student2.id, assignment: @assignment2)&lt;br /&gt;
    @assignment_team = create(:assignment_team, name: &amp;quot;TestTeam&amp;quot;, parent_id: @assignment2.id)&lt;br /&gt;
    @team_user = create(:team_user, team_id: @assignment_team.id, user_id: @student2.id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We tested the methods by seeing whether if we got the right amount of elements in our arrays/hashes like the following. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;getAssignmentsInCourses should return an assignment&amp;quot; do&lt;br /&gt;
    expect(Leaderboard.get_assignments_in_courses(1)).to have(1).items&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also tested whether the code could handle invalid arguments like such. &lt;br /&gt;
&lt;br /&gt;
  it &amp;quot;leaderboard_heading should return No Entry with invalid input&amp;quot; do    &lt;br /&gt;
    expect(Leaderboard.leaderboard_heading(&amp;quot;Invalid&amp;quot;)).to eq(&amp;quot;No Entry&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;br /&gt;
&lt;br /&gt;
During the rspec testing we noticed that the methods get_participant_entries_in_assignment_list and find_by_qtype were being called but where not created in the program. &lt;br /&gt;
&lt;br /&gt;
There was also no declaration of ScoreCache anywhere in the program which caused other methods to fail.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103048</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103048"/>
		<updated>2016-10-28T21:16:56Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. The rate of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103046</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103046"/>
		<updated>2016-10-28T21:16:11Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. The rate of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103045</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103045"/>
		<updated>2016-10-28T21:15:35Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. The rate of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103043</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103043"/>
		<updated>2016-10-28T21:14:16Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. The rate of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we use the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also search through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103041</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103041"/>
		<updated>2016-10-28T21:13:18Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Thoughts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. The rate of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and IDE will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103038</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103038"/>
		<updated>2016-10-28T21:11:47Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, we use snake_case for method names. There are also some useless assignments to several variables. The rate of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103034</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103034"/>
		<updated>2016-10-28T21:10:18Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. And students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103032</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103032"/>
		<updated>2016-10-28T21:09:21Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Avoid more than 3 levels of block nesting. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). Instructor adds and edits assignments to Expertiza. And students can be assigned in team based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4-levels loop has been changed to 3-levels one.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103029</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103029"/>
		<updated>2016-10-28T21:06:07Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). Instructor adds and edits assignments to Expertiza. And students can be assigned in team based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the name of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved.&lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4 levels loop has been changed to 3 levels.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103027</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103027"/>
		<updated>2016-10-28T21:05:09Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Modified File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). Instructor adds and edits assignments to Expertiza. And students can be assigned in team based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the names of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved. &lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* Refactor the leaderboard.rb&lt;br /&gt;
* Create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4 levels loop has been changed to 3 levels.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103026</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103026"/>
		<updated>2016-10-28T21:04:55Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Modified File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). Instructor adds and edits assignments to Expertiza. And students can be assigned in team based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the names of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved. &lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* refactor the leaderboard.rb&lt;br /&gt;
* create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4 levels loop has been changed to 3 levels.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103022</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103022"/>
		<updated>2016-10-28T21:03:34Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). Instructor adds and edits assignments to Expertiza. And students can be assigned in team based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the names of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved. &lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* leaderboard.rb&lt;br /&gt;
* create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4 levels loop has been changed to 3 levels.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103020</id>
		<title>CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1674.Refactor_leaderboard.rb_and_write_unit_tests&amp;diff=103020"/>
		<updated>2016-10-28T21:02:43Z</updated>

		<summary type="html">&lt;p&gt;Ywei8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page give a description of the changes made for the leaderboard.rb of Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
==Expertiza Background ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). Instructor adds and edits assignment to Expertiza. And students can be assigned in team based on their selection of the topics. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The task of the project is to refactor leaderboard.rb and write unit tests for it. As the names of the methods are not in a standard style, so we used snake_case for method names. There are also some useless assignments to several variables. The code climate rating of leaderboard.rb is D, which is needed to be improved. &lt;br /&gt;
&lt;br /&gt;
== Modified File == &lt;br /&gt;
* leaderboard.rb&lt;br /&gt;
* create a RSpec file in /spec/models/ foler which contains unit test for leaderboard.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Thoughts ==&lt;br /&gt;
What we need to do is to deal with the problems listed by the code climate. And we also need to write a new test file to test the functionality of leaderboard.rb. However, the leaderboard itself has some problems and it will report some problems when we want to run it. So we need to know which method in this file is broken first and just test others instead.&lt;br /&gt;
&lt;br /&gt;
== Tools==&lt;br /&gt;
As for this project, we used the code climate plugin to test if our code is good enough. This plugin will obviously help us with the refactor part because it can show which part of the original codes have some problems. We also searched through the internet and get to know how to write the Rspec files.&lt;br /&gt;
&lt;br /&gt;
== Refactor ==&lt;br /&gt;
We will list each kind of problems we solved below.&lt;br /&gt;
=== Use snake_case for method names. ===&lt;br /&gt;
As we all know the snake_case means we need to name the methods and variables in this way. &lt;br /&gt;
For example, we changed this method.&lt;br /&gt;
&lt;br /&gt;
  def self.getIndependantAssignments(user_id)&lt;br /&gt;
    assignmentIds = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
Both variable names and method names are not in a good manner. We changed it to the version below.&lt;br /&gt;
&lt;br /&gt;
  def self.get_independant_assignments(user_id)&lt;br /&gt;
    assignment_ids = AssignmentParticipant.where(user_id: user_id).pluck(:parent_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `noCourseAssignments`.===&lt;br /&gt;
We just commented these useless variables.&lt;br /&gt;
&lt;br /&gt;
=== Useless assignment to variable - `assignmentList`. ===&lt;br /&gt;
We just comment this useless variable.&lt;br /&gt;
&lt;br /&gt;
=== Prefer `each` over `for`. ===&lt;br /&gt;
We know that 'each' function is more in ruby style for loops. So we would like to change all our 'for' to 'each'.&lt;br /&gt;
  for scoreEntry in scores&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
We changed this loop to:&lt;br /&gt;
  scores.each do |scoreEntry|&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And the problem would be fixed.&lt;br /&gt;
&lt;br /&gt;
=== Avoid more than 3 levels of block nesting.===&lt;br /&gt;
  if qTypeHash.fetch(questionnaireType, {}).fetch(courseId, nil).nil?&lt;br /&gt;
     if qTypeHash.fetch(questionnaireType, nil).nil?&lt;br /&gt;
        ...&lt;br /&gt;
     end&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This is the third and fourth level of the block nesting. We need to merge them together.&lt;br /&gt;
&lt;br /&gt;
  if q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  elseif  q_type_hash.fetch(questionnaire_type, {}).fetch(course_id, nil).nil? &amp;amp;&amp;amp; !q_type_hash.fetch(questionnaire_type, nil).nil?&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
Then the 4 levels loop has been changed to 3 levels.&lt;br /&gt;
&lt;br /&gt;
=== `end` at 148, 1 is not aligned with `def` at 129, 2.''' ===&lt;br /&gt;
We just need to add a space in 148 line.&lt;br /&gt;
&lt;br /&gt;
== Rspec Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional ==&lt;br /&gt;
There are still some problems we need to figure out.  &lt;br /&gt;
For the code revising part, there are some methods with this problem: Assignment Branch Condition size for get_participants_score is too high.&lt;br /&gt;
&lt;br /&gt;
I think we cannot make too many functions in one method so that we need to make some of these be executed outside of this method.&lt;br /&gt;
Also, some of the code lines are too long so that it is not clear enough.&lt;/div&gt;</summary>
		<author><name>Ywei8</name></author>
	</entry>
</feed>