<?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=Dpatel12</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=Dpatel12"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Dpatel12"/>
	<updated>2026-06-05T06:23:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1734&amp;diff=108714</id>
		<title>CSC/ECE 517 Spring 2017 E1734</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1734&amp;diff=108714"/>
		<updated>2017-04-29T02:31:44Z</updated>

		<summary type="html">&lt;p&gt;Dpatel12: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Improve survey functionality=&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
&lt;br /&gt;
Expertiza used to have functionality for conducting surveys. However, the existing code is inefficient and needs to be improved. This functionality has rarely been used and so isn't tested very well either. Therefore, there are parts of survey functionality that are broken or are totally unfinished.&lt;br /&gt;
&lt;br /&gt;
So, there are three major problems this project will tackle.&lt;br /&gt;
&lt;br /&gt;
1) Restructure and move around functionality within classes to further streamline the code.&lt;br /&gt;
&lt;br /&gt;
2) Test the existing functionality and catalog what parts work and what do not. As an instance of a broken feature, take survey deployments for example. During initial testing, it is not possible to deploy any kind of survey. There are other features as well that need little fixes to make them work.&lt;br /&gt;
&lt;br /&gt;
3) Fixing the broken features. This involves little bug fixes here and there, as well as finishing the features that are completely unfinished.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
1) A page to show the distribution of results for all types of questionnaires. &lt;br /&gt;
&lt;br /&gt;
2) Use of inheritance so that survey questionnaire is a subclass of the questionnaire class. Also, course evaluation questionnaire and global survey questionnaire should be subclasses of survey questionnaire.&lt;br /&gt;
&lt;br /&gt;
3) Use response_controller to implement the survey functionality. This should be similar to how other questionnaires like the peer review questionnaire, are implemented.&lt;br /&gt;
&lt;br /&gt;
4) Use the same code to display existing survey responses as to display the responses in peer reviews.&lt;br /&gt;
&lt;br /&gt;
5) For each course or assignment, the admin/instructor should be able to create a survey and have some (or all) of the participants receive the survey.  The instructor should have the option to not include some questions from a global survey. The quiz takers can take the global survey and course survey consecutively.&lt;br /&gt;
&lt;br /&gt;
6) An entry in the participants table called a survey_participant record must be added to indicate when a user is assigned to take part in a survey.&lt;br /&gt;
&lt;br /&gt;
7) Tests need to be written for the feature.&lt;br /&gt;
&lt;br /&gt;
Note: Although the requirements document mentions that the existing code needs to be scrapped and rewritten, after discussion with professor it was decided that this is not a strict requirement.&lt;br /&gt;
&lt;br /&gt;
== Types of Surveys ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three kinds of surveys available in the Expertiza application. They are differentiated based on the group of people that can have access to these surveys.&lt;br /&gt;
&lt;br /&gt;
The surveys are as follows:&lt;br /&gt;
&lt;br /&gt;
1) Course Survey:&lt;br /&gt;
&lt;br /&gt;
All the participants in a course can take the course survey.&lt;br /&gt;
	&lt;br /&gt;
File: course_evaluation_questionnaire.rb  &lt;br /&gt;
&lt;br /&gt;
2) Global Survey:&lt;br /&gt;
&lt;br /&gt;
Any Expertiza user can take the global survey.&lt;br /&gt;
	&lt;br /&gt;
File: global_survey_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
3) Targeted Survey:&lt;br /&gt;
&lt;br /&gt;
The admin can create a survey targeted to a specific group of people.&lt;br /&gt;
&lt;br /&gt;
File: survey_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
== Class Design ==&lt;br /&gt;
&lt;br /&gt;
=== Existing class structure: ===&lt;br /&gt;
&lt;br /&gt;
[[File:E1734-structure-1.png|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=== Updated class structure: ===&lt;br /&gt;
&lt;br /&gt;
[[File:E1734-structure-2New.jpg|frame|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== New Class Functionality: ===&lt;br /&gt;
&lt;br /&gt;
==== Questionnaire: ====&lt;br /&gt;
&lt;br /&gt;
Contains the basic information and methods required for posing questions to students or users in general.  It is inherited by Classes Quiz, Survey, etc.&lt;br /&gt;
&lt;br /&gt;
We can reuse this class's functionality to create, edit and delete surveys. The functionality for checking if questions have been answered can also be borrowed from this class.&lt;br /&gt;
&lt;br /&gt;
==== Survey: ====&lt;br /&gt;
&lt;br /&gt;
This project will introduce a new class called Survey. &lt;br /&gt;
&lt;br /&gt;
This class will inherit from the Questionnaire class and it will be a superclass for the three different kinds of survey classes.&lt;br /&gt;
&lt;br /&gt;
This class will include the assign_participants() method that can be used by any of the child classes to assign participants for their respective surveys.&lt;br /&gt;
&lt;br /&gt;
This class will also have the statistics_generation functionality to be used to provide statistics for any kind of survey. This is the one that will take care of the requirement for getting the distribution of responses.&lt;br /&gt;
&lt;br /&gt;
==== Global Survey: ==== &lt;br /&gt;
&lt;br /&gt;
This class will inherit from class Survey.&lt;br /&gt;
&lt;br /&gt;
This class will be set the display_type for the survey to be global. So, while assigning participants all the users of Expertiza will be able to see this particular survey.&lt;br /&gt;
&lt;br /&gt;
This kind of survey can only be created by admins of the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
==== Course Evaluation: ====  &lt;br /&gt;
&lt;br /&gt;
This is also another type of survey and will inherit from class Survey.&lt;br /&gt;
&lt;br /&gt;
Surveys of this type, however, will only be available to the class to which this survey would be assigned. Accordingly, the display_type for it will be set to course.&lt;br /&gt;
&lt;br /&gt;
So assign_participants() will create new survey participants for all users in a particular course.&lt;br /&gt;
&lt;br /&gt;
==== Survey Questionnaire: ====&lt;br /&gt;
&lt;br /&gt;
This class will also inherit from the class Survey. The name used for this class may change after further discussions with the professor. &lt;br /&gt;
&lt;br /&gt;
The existing survey_questionnaire class will be repurposed to be used to create surveys that could be targeted to a group of users or be attached to a questionnaire.&lt;br /&gt;
&lt;br /&gt;
It will allow for an association between an assignment and a questionnaire to be established.  Additionally, it maintains the instructor id who will create the association. &lt;br /&gt;
&lt;br /&gt;
A flag for a score outside an acceptable range will also be set.  It could also be used to play a part in the total score calculation for the assignment.&lt;br /&gt;
&lt;br /&gt;
== Database Schema ==&lt;br /&gt;
&lt;br /&gt;
There are database tables that are used to track the deployment of the surveys, that are used to help keep track of the participants for each survey and that keep track of all the responses for the surveys we create. We would not be making any or would make only minimal design changes to these tables. Our main task would be to go in and fix things that are not currently operational given what we already have. &lt;br /&gt;
&lt;br /&gt;
To give an idea about these database tables we have included them below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Deployments&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| course_evaluation_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| start_date&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| end_date&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| num_of_students&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| last_reminder&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| course_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Null: false &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Participants&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| user_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| survey_deployment_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Responses&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| score&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| comments&lt;br /&gt;
| Text&lt;br /&gt;
| Limit: 65535&lt;br /&gt;
|-&lt;br /&gt;
| assignment_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| question_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| survey_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| email&lt;br /&gt;
| String&lt;br /&gt;
| Limit: 255 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====UML Diagram====&lt;br /&gt;
&lt;br /&gt;
[[File:UML600.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Tasks to be performed ==&lt;br /&gt;
&lt;br /&gt;
Given the information at hand, the following list will provide a good summary of the tasks we will have to perform to achieve the goals of this project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1) Change the hierarchical structure of classes. Make survey the child of questionnaire. Global survey, survey_questionnaire and course evaluation to be subclasses of survey.&lt;br /&gt;
&lt;br /&gt;
2) Creation, editing and deletion of questions, is a functionality that would be inherited into class Survey(which is a kind of questionnaire) and so into all its children surveys, from the Questionnaire class.&lt;br /&gt;
&lt;br /&gt;
3) Add new class Survey and include functionality to assign(which is in the survey_controller currently) to this model. &lt;br /&gt;
&lt;br /&gt;
4) In the new class add functionality to generate statistics.&lt;br /&gt;
&lt;br /&gt;
5) The display_type for each of the subclasses of Survey can be set individually in the post_initialization method.&lt;br /&gt;
&lt;br /&gt;
6) The three kinds of surveys can be assigned to some either an assignment, a course, a student or to all the users of Expertiza depending on their display_type.&lt;br /&gt;
&lt;br /&gt;
7) Use the course evaluation tab on the Expertiza homepage to display any pending surveys instead of just the course evaluation surveys. The course evaluation tab’s functionality is currently broken and needs to be fixed.&lt;br /&gt;
&lt;br /&gt;
8) &amp;quot;Survey deployment&amp;quot; functionality is broken. Need to make survey deployment of all forms of surveys functional. This would include the following tasks:&lt;br /&gt;
&lt;br /&gt;
   a) Ability to add new survey deployments.&lt;br /&gt;
   b) View responses to the deployments.&lt;br /&gt;
   c) Delete deployments.&lt;br /&gt;
&lt;br /&gt;
9) &amp;quot;Statistic generation for Survey&amp;quot; functionality is broken. From the drop down menu in survey deployments, we can select Statistical tests and that should take the user to a page where depending on the survey chosen the corresponding statistics would be displayed.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
Testing tool:&lt;br /&gt;
&lt;br /&gt;
RSpec (For the automated tests)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test #&lt;br /&gt;
! Type&lt;br /&gt;
! Description&lt;br /&gt;
! Steps&lt;br /&gt;
|-&lt;br /&gt;
|Test case 1:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test to check whether an instructor can create a survey&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as an instructor.&lt;br /&gt;
&lt;br /&gt;
2. Click Manage… and go to Questionnaire.&lt;br /&gt;
&lt;br /&gt;
3. Select new public/private item of the type of survey you want to create.&lt;br /&gt;
&lt;br /&gt;
4. In the Questionnaire view, create the questionnaire by Clicking Create.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 2:&lt;br /&gt;
|Manual&lt;br /&gt;
|Test to check whether a survey is deployed to the appropriate users&lt;br /&gt;
|&lt;br /&gt;
1. After creation of a survey that a particular student can participate in, login as that student.&lt;br /&gt;
&lt;br /&gt;
2. The student can then participate in the survey by clicking on Pending Surveys.&lt;br /&gt;
&lt;br /&gt;
3. If the survey appears there, that indicates that the survey has been deployed successfully.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 3:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test to check whether the statistics of survey responses is displayed&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as an instructor.&lt;br /&gt;
&lt;br /&gt;
2. Assuming that a survey is created, and students have participated in it, we can check the distribution of results.&lt;br /&gt;
&lt;br /&gt;
3. Click on Survey Deployments in the page header.&lt;br /&gt;
&lt;br /&gt;
4. Click Statistics of a particular survey that was created to view the statistics of responses.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 4:&lt;br /&gt;
|Manual&lt;br /&gt;
|Test to check that only allowed users can participate in the survey&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as a student that is not included as a participant in the survey.&lt;br /&gt;
&lt;br /&gt;
2. By clicking on Surveys, the list of surveys that the student can currently take is displayed.&lt;br /&gt;
&lt;br /&gt;
3. If the survey that was created is not visible, then the user is correctly excluded.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 5:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test to check whether an instructor can view responses of a survey deployment&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as an instructor.&lt;br /&gt;
&lt;br /&gt;
2. Assuming that a survey is created, and students have participated in it, the instructor can check the responses to each question.&lt;br /&gt;
&lt;br /&gt;
3. Click on Survey Deployments in the page header.&lt;br /&gt;
&lt;br /&gt;
4. Click View Responses of a particular survey that was created to view the responses.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Dpatel12</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1734&amp;diff=108713</id>
		<title>CSC/ECE 517 Spring 2017 E1734</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1734&amp;diff=108713"/>
		<updated>2017-04-29T02:28:28Z</updated>

		<summary type="html">&lt;p&gt;Dpatel12: Revised the test plan&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Improve survey functionality=&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
&lt;br /&gt;
Expertiza used to have functionality for conducting surveys. However, the existing code is inefficient and needs to be improved. This functionality has rarely been used and so isn't tested very well either. Therefore, there are parts of survey functionality that are broken or are totally unfinished.&lt;br /&gt;
&lt;br /&gt;
So, there are three major problems this project will tackle.&lt;br /&gt;
&lt;br /&gt;
1) Restructure and move around functionality within classes to further streamline the code.&lt;br /&gt;
&lt;br /&gt;
2) Test the existing functionality and catalog what parts work and what do not. As an instance of a broken feature, take survey deployments for example. During initial testing, it is not possible to deploy any kind of survey. There are other features as well that need little fixes to make them work.&lt;br /&gt;
&lt;br /&gt;
3) Fixing the broken features. This involves little bug fixes here and there, as well as finishing the features that are completely unfinished.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
1) A page to show the distribution of results for all types of questionnaires. &lt;br /&gt;
&lt;br /&gt;
2) Use of inheritance so that survey questionnaire is a subclass of the questionnaire class. Also, course evaluation questionnaire and global survey questionnaire should be subclasses of survey questionnaire.&lt;br /&gt;
&lt;br /&gt;
3) Use response_controller to implement the survey functionality. This should be similar to how other questionnaires like the peer review questionnaire, are implemented.&lt;br /&gt;
&lt;br /&gt;
4) Use the same code to display existing survey responses as to display the responses in peer reviews.&lt;br /&gt;
&lt;br /&gt;
5) For each course or assignment, the admin/instructor should be able to create a survey and have some (or all) of the participants receive the survey.  The instructor should have the option to not include some questions from a global survey. The quiz takers can take the global survey and course survey consecutively.&lt;br /&gt;
&lt;br /&gt;
6) An entry in the participants table called a survey_participant record must be added to indicate when a user is assigned to take part in a survey.&lt;br /&gt;
&lt;br /&gt;
7) Tests need to be written for the feature.&lt;br /&gt;
&lt;br /&gt;
Note: Although the requirements document mentions that the existing code needs to be scrapped and rewritten, after discussion with professor it was decided that this is not a strict requirement.&lt;br /&gt;
&lt;br /&gt;
== Types of Surveys ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three kinds of surveys available in the Expertiza application. They are differentiated based on the group of people that can have access to these surveys.&lt;br /&gt;
&lt;br /&gt;
The surveys are as follows:&lt;br /&gt;
&lt;br /&gt;
1) Course Survey:&lt;br /&gt;
&lt;br /&gt;
All the participants in a course can take the course survey.&lt;br /&gt;
	&lt;br /&gt;
File: course_evaluation_questionnaire.rb  &lt;br /&gt;
&lt;br /&gt;
2) Global Survey:&lt;br /&gt;
&lt;br /&gt;
Any Expertiza user can take the global survey.&lt;br /&gt;
	&lt;br /&gt;
File: global_survey_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
3) Targeted Survey:&lt;br /&gt;
&lt;br /&gt;
The admin can create a survey targeted to a specific group of people.&lt;br /&gt;
&lt;br /&gt;
File: survey_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
== Class Design ==&lt;br /&gt;
&lt;br /&gt;
=== Existing class structure: ===&lt;br /&gt;
&lt;br /&gt;
[[File:E1734-structure-1.png|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=== Updated class structure: ===&lt;br /&gt;
&lt;br /&gt;
[[File:E1734-structure-2New.jpg|frame|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== New Class Functionality: ===&lt;br /&gt;
&lt;br /&gt;
==== Questionnaire: ====&lt;br /&gt;
&lt;br /&gt;
Contains the basic information and methods required for posing questions to students or users in general.  It is inherited by Classes Quiz, Survey, etc.&lt;br /&gt;
&lt;br /&gt;
We can reuse this class's functionality to create, edit and delete surveys. The functionality for checking if questions have been answered can also be borrowed from this class.&lt;br /&gt;
&lt;br /&gt;
==== Survey: ====&lt;br /&gt;
&lt;br /&gt;
This project will introduce a new class called Survey. &lt;br /&gt;
&lt;br /&gt;
This class will inherit from the Questionnaire class and it will be a superclass for the three different kinds of survey classes.&lt;br /&gt;
&lt;br /&gt;
This class will include the assign_participants() method that can be used by any of the child classes to assign participants for their respective surveys.&lt;br /&gt;
&lt;br /&gt;
This class will also have the statistics_generation functionality to be used to provide statistics for any kind of survey. This is the one that will take care of the requirement for getting the distribution of responses.&lt;br /&gt;
&lt;br /&gt;
==== Global Survey: ==== &lt;br /&gt;
&lt;br /&gt;
This class will inherit from class Survey.&lt;br /&gt;
&lt;br /&gt;
This class will be set the display_type for the survey to be global. So, while assigning participants all the users of Expertiza will be able to see this particular survey.&lt;br /&gt;
&lt;br /&gt;
This kind of survey can only be created by admins of the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
==== Course Evaluation: ====  &lt;br /&gt;
&lt;br /&gt;
This is also another type of survey and will inherit from class Survey.&lt;br /&gt;
&lt;br /&gt;
Surveys of this type, however, will only be available to the class to which this survey would be assigned. Accordingly, the display_type for it will be set to course.&lt;br /&gt;
&lt;br /&gt;
So assign_participants() will create new survey participants for all users in a particular course.&lt;br /&gt;
&lt;br /&gt;
==== Survey Questionnaire: ====&lt;br /&gt;
&lt;br /&gt;
This class will also inherit from the class Survey. The name used for this class may change after further discussions with the professor. &lt;br /&gt;
&lt;br /&gt;
The existing survey_questionnaire class will be repurposed to be used to create surveys that could be targeted to a group of users or be attached to a questionnaire.&lt;br /&gt;
&lt;br /&gt;
It will allow for an association between an assignment and a questionnaire to be established.  Additionally, it maintains the instructor id who will create the association. &lt;br /&gt;
&lt;br /&gt;
A flag for a score outside an acceptable range will also be set.  It could also be used to play a part in the total score calculation for the assignment.&lt;br /&gt;
&lt;br /&gt;
== Database Schema ==&lt;br /&gt;
&lt;br /&gt;
There are database tables that are used to track the deployment of the surveys, that are used to help keep track of the participants for each survey and that keep track of all the responses for the surveys we create. We would not be making any or would make only minimal design changes to these tables. Our main task would be to go in and fix things that are not currently operational given what we already have. &lt;br /&gt;
&lt;br /&gt;
To give an idea about these database tables we have included them below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Deployments&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| course_evaluation_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| start_date&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| end_date&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| num_of_students&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| last_reminder&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| course_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Null: false &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Participants&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| user_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| survey_deployment_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Responses&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| score&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| comments&lt;br /&gt;
| Text&lt;br /&gt;
| Limit: 65535&lt;br /&gt;
|-&lt;br /&gt;
| assignment_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| question_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| survey_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| email&lt;br /&gt;
| String&lt;br /&gt;
| Limit: 255 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====UML Diagram====&lt;br /&gt;
&lt;br /&gt;
[[File:UML600.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Tasks to be performed ==&lt;br /&gt;
&lt;br /&gt;
Given the information at hand, the following list will provide a good summary of the tasks we will have to perform to achieve the goals of this project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1) Change the hierarchical structure of classes. Make survey the child of questionnaire. Global survey, survey_questionnaire and course evaluation to be subclasses of survey.&lt;br /&gt;
&lt;br /&gt;
2) Creation, editing and deletion of questions, is a functionality that would be inherited into class Survey(which is a kind of questionnaire) and so into all its children surveys, from the Questionnaire class.&lt;br /&gt;
&lt;br /&gt;
3) Add new class Survey and include functionality to assign(which is in the survey_controller currently) to this model. &lt;br /&gt;
&lt;br /&gt;
4) In the new class add functionality to generate statistics.&lt;br /&gt;
&lt;br /&gt;
5) The display_type for each of the subclasses of Survey can be set individually in the post_initialization method.&lt;br /&gt;
&lt;br /&gt;
6) The three kinds of surveys can be assigned to some either an assignment, a course, a student or to all the users of Expertiza depending on their display_type.&lt;br /&gt;
&lt;br /&gt;
7) Use the course evaluation tab on the Expertiza homepage to display any pending surveys instead of just the course evaluation surveys. The course evaluation tab’s functionality is currently broken and needs to be fixed.&lt;br /&gt;
&lt;br /&gt;
8) &amp;quot;Survey deployment&amp;quot; functionality is broken. Need to make survey deployment of all forms of surveys functional. This would include the following tasks:&lt;br /&gt;
&lt;br /&gt;
   a) Ability to add new survey deployments.&lt;br /&gt;
   b) View responses to the deployments.&lt;br /&gt;
   c) Delete deployments.&lt;br /&gt;
&lt;br /&gt;
9) &amp;quot;Statistic generation for Survey&amp;quot; functionality is broken. From the drop down menu in survey deployments, we can select Statistical tests and that should take the user to a page where depending on the survey chosen the corresponding statistics would be displayed.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
Testing tool:&lt;br /&gt;
&lt;br /&gt;
RSpec (For the automated tests)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test #&lt;br /&gt;
! Type&lt;br /&gt;
! Description&lt;br /&gt;
! Steps&lt;br /&gt;
|-&lt;br /&gt;
|Test case 1:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test to check whether an instructor can create a survey&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as an instructor.&lt;br /&gt;
&lt;br /&gt;
2. Click Manage… and go to Questionnaire.&lt;br /&gt;
&lt;br /&gt;
3. Select new public/private item of the type of survey you want to create.&lt;br /&gt;
&lt;br /&gt;
4. In the Questionnaire view, create the questionnaire by Clicking Create.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 2:&lt;br /&gt;
|Manual&lt;br /&gt;
|Test to check whether a survey is deployed to the appropriate users&lt;br /&gt;
|&lt;br /&gt;
1. After creation of a survey that a particular student can participate in, login as that student.&lt;br /&gt;
&lt;br /&gt;
2. The student can then participate in the survey by clicking on Pending Surveys.&lt;br /&gt;
&lt;br /&gt;
3. If the survey appears there, that indicates that the survey has been deployed successfully.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 3:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test to check whether the statistics of survey responses is displayed&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as an instructor.&lt;br /&gt;
&lt;br /&gt;
2. Assuming that a survey is created, and students have participated in it, we can check the distribution of results.&lt;br /&gt;
&lt;br /&gt;
3. Click on Survey Deployments in the page header.&lt;br /&gt;
&lt;br /&gt;
4. Click Statistics of a particular survey that was created to view the statistics of responses.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 4:&lt;br /&gt;
|Manual&lt;br /&gt;
|Test to check that only allowed users can participate in the survey&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as a student that is not included as a participant in the survey.&lt;br /&gt;
&lt;br /&gt;
2. By clicking on Surveys, the list of surveys that the student can currently take is displayed.&lt;br /&gt;
&lt;br /&gt;
3. If the survey that was created is not visible, then the user is correctly excluded.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 5:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test for the display_type after creation of a survey&lt;br /&gt;
|&lt;br /&gt;
1. Create any kind of survey, i.e. Survey Questionnaire, Global Survey Questionnaire, or Course Evaluation Questionnaire.&lt;br /&gt;
&lt;br /&gt;
2. Post_initialization, as the name suggests, is called after the initialization of a survey, so it gets called on creation in the first step.&lt;br /&gt;
&lt;br /&gt;
3. Assert whether the value of display_type is course/survey/global depending on what survey was created.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 6:&lt;br /&gt;
|Automated&lt;br /&gt;
|Test to check whether an instructor can view responses of a survey deployment&lt;br /&gt;
|&lt;br /&gt;
1. Login to Expertiza as an instructor.&lt;br /&gt;
&lt;br /&gt;
2. Assuming that a survey is created, and students have participated in it, the instructor can check the responses to each question.&lt;br /&gt;
&lt;br /&gt;
3. Click on Survey Deployments in the page header.&lt;br /&gt;
&lt;br /&gt;
4. Click View Responses of a particular survey that was created to view the responses.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Dpatel12</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1734&amp;diff=108489</id>
		<title>CSC/ECE 517 Spring 2017 E1734</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1734&amp;diff=108489"/>
		<updated>2017-04-13T02:16:16Z</updated>

		<summary type="html">&lt;p&gt;Dpatel12: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Improve survey functionality=&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
&lt;br /&gt;
Expertiza used to have functionality for conducting surveys. However, the existing code is inefficient and needs to be improved. This functionality has rarely been used and so isn't tested very well either. Therefore, there are parts of survey functionality that are broken or are totally unfinished.&lt;br /&gt;
&lt;br /&gt;
So, there are three major problems this project will tackle.&lt;br /&gt;
&lt;br /&gt;
1) Restructure and move around functionality within classes to further streamline the code.&lt;br /&gt;
&lt;br /&gt;
2) Test the existing functionality and catalog what parts work and what do not. As an instance of a broken feature, take survey deployments for example. During initial testing, it is not possible to deploy any kind of survey. There are other features as well that need little fixes to make them work.&lt;br /&gt;
&lt;br /&gt;
3) Fixing the broken features. This involves little bug fixes here and there, as well as finishing the features that are completely unfinished.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
1) A page to show the distribution of results for all types of questionnaires. &lt;br /&gt;
&lt;br /&gt;
2) Use of inheritance so that survey questionnaire is a subclass of the questionnaire class. Also, course evaluation questionnaire and global survey questionnaire should be subclasses of survey questionnaire.&lt;br /&gt;
&lt;br /&gt;
3) Use response_controller to implement the survey functionality. This should be similar to how other questionnaires like the peer review questionnaire, are implemented.&lt;br /&gt;
&lt;br /&gt;
4) Use the same code to display existing survey responses as to display the responses in peer reviews.&lt;br /&gt;
&lt;br /&gt;
5) For each course or assignment, the admin/instructor should be able to create a survey and have some (or all) of the participants receive the survey.  The instructor should have the option to not include some questions from a global survey. The quiz takers can take the global survey and course survey consecutively.&lt;br /&gt;
&lt;br /&gt;
6) An entry in the participants table called a survey_participant record must be added to indicate when a user is assigned to take part in a survey.&lt;br /&gt;
&lt;br /&gt;
7) Tests need to be written for the feature.&lt;br /&gt;
&lt;br /&gt;
Note: Although the requirements document mentions that the existing code needs to be scrapped and rewritten, after discussion with professor it was decided that this is not a strict requirement.&lt;br /&gt;
&lt;br /&gt;
== Types of Surveys ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three kinds of surveys available in the Expertiza application. They are differentiated based on the group of people that can have access to these surveys.&lt;br /&gt;
&lt;br /&gt;
The surveys are as follows:&lt;br /&gt;
&lt;br /&gt;
1) Course Survey:&lt;br /&gt;
&lt;br /&gt;
All the participants in a course can take the course survey.&lt;br /&gt;
	&lt;br /&gt;
File: course_evaluation_questionnaire.rb  &lt;br /&gt;
&lt;br /&gt;
2) Global Survey:&lt;br /&gt;
&lt;br /&gt;
Any Expertiza user can take the global survey.&lt;br /&gt;
	&lt;br /&gt;
File: global_survey_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
3) Targeted Survey:&lt;br /&gt;
&lt;br /&gt;
The admin can create a survey targeted to a specific group of people.&lt;br /&gt;
&lt;br /&gt;
File: survey_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
== Class Design ==&lt;br /&gt;
&lt;br /&gt;
=== Existing class structure: ===&lt;br /&gt;
&lt;br /&gt;
[[File:E1734-structure-1.png|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=== Updated class structure: ===&lt;br /&gt;
&lt;br /&gt;
[[File:E1734-structure-2New.jpg|frame|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== New Class Functionality: ===&lt;br /&gt;
&lt;br /&gt;
==== Questionnaire: ====&lt;br /&gt;
&lt;br /&gt;
Contains the basic information and methods required for posing questions to students or users in general.  It is inherited by Classes Quiz, Survey, etc.&lt;br /&gt;
&lt;br /&gt;
We can reuse this class's functionality to create, edit and delete surveys. The functionality for checking if questions have been answered can also be borrowed from this class.&lt;br /&gt;
&lt;br /&gt;
==== Survey: ====&lt;br /&gt;
&lt;br /&gt;
This project will introduce a new class called Survey. &lt;br /&gt;
&lt;br /&gt;
This class will inherit from the Questionnaire class and it will be a superclass for the three different kinds of survey classes.&lt;br /&gt;
&lt;br /&gt;
This class will include the assign_participants() method that can be used by any of the child classes to assign participants for their respective surveys.&lt;br /&gt;
&lt;br /&gt;
This class will also have the statistics_generation functionality to be used to provide statistics for any kind of survey. This is the one that will take care of the requirement for getting the distribution of responses.&lt;br /&gt;
&lt;br /&gt;
==== Global Survey: ==== &lt;br /&gt;
&lt;br /&gt;
This class will inherit from class Survey.&lt;br /&gt;
&lt;br /&gt;
This class will be set the display_type for the survey to be global. So, while assigning participants all the users of Expertiza will be able to see this particular survey.&lt;br /&gt;
&lt;br /&gt;
This kind of survey can only be created by admins of the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
==== Course Evaluation: ====  &lt;br /&gt;
&lt;br /&gt;
This is also another type of survey and will inherit from class Survey.&lt;br /&gt;
&lt;br /&gt;
Surveys of this type, however, will only be available to the class to which this survey would be assigned. Accordingly, the display_type for it will be set to course.&lt;br /&gt;
&lt;br /&gt;
So assign_participants() will create new survey participants for all users in a particular course.&lt;br /&gt;
&lt;br /&gt;
==== Survey Questionnaire: ====&lt;br /&gt;
&lt;br /&gt;
This class will also inherit from the class Survey. The name used for this class may change after further discussions with the professor. &lt;br /&gt;
&lt;br /&gt;
The existing survey_questionnaire class will be repurposed to be used to create surveys that could be targeted to a group of users or be attached to a questionnaire.&lt;br /&gt;
&lt;br /&gt;
It will allow for an association between an assignment and a questionnaire to be established.  Additionally, it maintains the instructor id who will create the association. &lt;br /&gt;
&lt;br /&gt;
A flag for a score outside an acceptable range will also be set.  It could also be used to play a part in the total score calculation for the assignment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Database Schema ==&lt;br /&gt;
&lt;br /&gt;
There are database tables that are used to track the deployment of the surveys, that are used to help keep track of the participants for each survey and that keep track of all the responses for the surveys we create. We would not be making any or would make only minimal design changes to these tables. Our main task would be to go in and fix things that are not currently operational given what we already have. &lt;br /&gt;
&lt;br /&gt;
To give an idea about these database tables we have included them below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Deployments&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| course_evaluation_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| start_date&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| end_date&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| num_of_students&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| last_reminder&lt;br /&gt;
| Datetime&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| course_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Null: false &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Participants&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| user_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| survey_deployment_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Table: Survey Responses&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Element&lt;br /&gt;
! Type&lt;br /&gt;
! Attributes&lt;br /&gt;
|-&lt;br /&gt;
| score&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4&lt;br /&gt;
|-&lt;br /&gt;
| comments&lt;br /&gt;
| Text&lt;br /&gt;
| Limit: 65535&lt;br /&gt;
|-&lt;br /&gt;
| assignment_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| question_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| survey_id&lt;br /&gt;
| Integer&lt;br /&gt;
| Limit: 4, Default: 0, Nil: false&lt;br /&gt;
|-&lt;br /&gt;
| email&lt;br /&gt;
| String&lt;br /&gt;
| Limit: 255 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks to be performed ==&lt;br /&gt;
&lt;br /&gt;
Given the information at hand, the following list will provide a good summary of the tasks we will have to perform to achieve the goals of this project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1) Change the hierarchical structure of classes. Make survey the child of questionnaire. Global survey, survey_questionnaire and course evaluation to be subclasses of survey.&lt;br /&gt;
&lt;br /&gt;
2) Creation, editing and deletion of questions, is a functionality that would be inherited into class Survey(which is a kind of questionnaire) and so into all its children surveys, from the Questionnaire class.&lt;br /&gt;
&lt;br /&gt;
3) Add new class Survey and include functionality to assign(which is in the survey_controller currently) to this model. &lt;br /&gt;
&lt;br /&gt;
4) In the new class add functionality to generate statistics.&lt;br /&gt;
&lt;br /&gt;
5) The display_type for each of the subclasses of Survey can be set individually in the post_initialization method.&lt;br /&gt;
&lt;br /&gt;
6) The three kinds of surveys can be assigned to some either an assignment, a course, a student or to all the users of Expertiza depending on their display_type.&lt;br /&gt;
&lt;br /&gt;
7) Use the course evaluation tab on the Expertiza homepage to display any pending surveys instead of just the course evaluation surveys. The course evaluation tab’s functionality is currently broken and needs to be fixed.&lt;br /&gt;
&lt;br /&gt;
8) &amp;quot;Survey deployment&amp;quot; functionality is broken. Need to make survey deployment of all forms of surveys functional. This would include the following tasks:&lt;br /&gt;
&lt;br /&gt;
   a) Ability to add new survey deployments.&lt;br /&gt;
   b) View responses to the deployments.&lt;br /&gt;
   c) Delete deployments.&lt;br /&gt;
&lt;br /&gt;
9) &amp;quot;Statistic generation for Survey&amp;quot; functionality is broken. From the drop down menu in survey deployments, we can select Statistical tests and that should take the user to a page where depending on the survey chosen the corresponding statistics would be displayed.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
Testing tool:&lt;br /&gt;
&lt;br /&gt;
RSpec&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test #&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
|Test case 1:&lt;br /&gt;
|Test to check whether an instructor can create a survey.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 2:&lt;br /&gt;
|Test to check whether a survey is deleted.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 3:&lt;br /&gt;
|Test to check whether a survey is updated.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 4:&lt;br /&gt;
|Test to check whether a survey is deployed to the appropriate users.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 5:&lt;br /&gt;
|Test to check whether the distribution of survey responses is correct.&lt;br /&gt;
|-&lt;br /&gt;
|Test case 6:&lt;br /&gt;
|Test to check whether a survey_participant record is created for the user in the participants table, if the user is assigned to take part in a survey.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Dpatel12</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017/oss_E1713&amp;diff=107632</id>
		<title>CSC/ECE 517 Spring 2017/oss E1713</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017/oss_E1713&amp;diff=107632"/>
		<updated>2017-03-31T03:43:17Z</updated>

		<summary type="html">&lt;p&gt;Dpatel12: /* added changes of Late Policies Controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1713. Refactor penalty_helper.rb and late_policies_controller.rb&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This project is intended to improve the code quality and reduce technical debt within the Expertiza system by refactoring the penalty_helper.rb module, refactoring the late_policies_controller.rb controller, and adding test coverage for both files.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Expertiza===&lt;br /&gt;
Expertiza is an open source web application which allows an instructor to manage assignments. It has various features viz. creating new assignments, customizing existing assignments, automatically allocating submissions for peer review etc. It has been developed using the [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] framework, and the code is available on [https://www.github.com/expertiza/expertiza Github].&lt;br /&gt;
&lt;br /&gt;
===Project Goals===&lt;br /&gt;
In this project, the files [https://github.com/expertiza/expertiza/blob/master/app/controllers/late_policies_controller.rb late_policies_controller.rb] and [https://github.com/expertiza/expertiza/blob/master/app/helpers/penalty_helper.rb penalty_helper.rb] were to be refactored. The methods contained in these files were too long, and needed to be either shortened, or used polymorphically, or deleted altogether if they were not being used. They also were to be refactored semantically if the code did not follow good Ruby coding practices.&lt;br /&gt;
&lt;br /&gt;
==Current Implementation==&lt;br /&gt;
&lt;br /&gt;
===Late policies and penalties functionality===&lt;br /&gt;
After an instructor creates an assignment in Expertiza they will have the ability to edit the details of the assignment by clicking the Edit action icon beside the assignment. From the &amp;quot;Editing Assignment&amp;quot; screen instructors have the ability to set due dates for each round of an assignment on the &amp;quot;Due dates&amp;quot; tab. On this tab, the instructor can elect to apply a late policy to the assignment by checking the &amp;quot;Apply penalty policy&amp;quot; checkbox and selecting a late policy from the adjacent drop down menu. If no late policies exist, or if the instructor wishes to define a new late policy, then they can click the &amp;quot;New late policy&amp;quot; link to define a new late policy.&lt;br /&gt;
&lt;br /&gt;
An instructor can define a late policy with the following fields:&lt;br /&gt;
&lt;br /&gt;
* Late policy name - This name will show up in the drop down menu on the &amp;quot;Due dates&amp;quot; tab when editing the assignment. It is not enforced to be unique.&lt;br /&gt;
* Penalty Unit - With the options of 'Minute', 'Hour', and 'Day' this field will define the frequency with which penalty points are deducted if an assignment is submitted after a due date.&lt;br /&gt;
* Penalty Point Per Unit - This is the amount of points which will be deducted from the student's score for the assignment round every time the Penalty Unit time has elapsed between the due date and the submission date. [Range: &amp;gt; 50]&lt;br /&gt;
* Maximum Penalty - Points will continue to be deducted from the assignment round score for each Penalty Unit time that has elapsed, but the number of points deducted will not exceed the Maximum Penalty [Range: 1..50]&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Change specifics==&lt;br /&gt;
The penalty_helper.rb and late_policies_controller.rb files are central to the creation and maintenance of late policies. Late policies are created by instructors and associated with assignments. The late_policies_controller.rb file is primarily used in the communication with view where late policies are displayed, created, or modified. The penalty_helper.rb file includes many useful methods related to late policies and the penalties which result from their use. For instance, if an assignment is designated as having penalties calculated then when it is graded the PenaltyHelper module will allow the penalties for each assignment to be calculated and applied to the final grade for the assignment. &lt;br /&gt;
&lt;br /&gt;
This effort was initiated with the intent of refactoring some longer methods with redundant subprocedures so that the overall structure of the code is cleaner, concise, and DRYer. This was achieved by performing analysis on the files to identify methods which are not used within the Expertiza code base, methods which are too long, and redundant code which can be extracted from other methods and replaced with a call to a single method.&lt;br /&gt;
&lt;br /&gt;
===Late Policies Controller===&lt;br /&gt;
This is controller class for late policies. It handles all the basic operations on late policies like create/edit/delete policy. The project goal was to refactor the code of create and update methods to make them smaller and more readable. Three helper methods were added in the PenaltyHelper module to make the code shorter. &lt;br /&gt;
There was a common input check in both create and update methods which was separated to write two new methods &amp;quot;check_penalty_points_validity&amp;quot; and &amp;quot;check_policy_with_same_name&amp;quot;, which helped to reuse the code.&lt;br /&gt;
&lt;br /&gt;
  #checking that penalty_per_unit is not exceeding max_penalty&lt;br /&gt;
  def check_penalty_points_validity(max_penalty, penalty_per_unit)&lt;br /&gt;
    if max_penalty &amp;lt; penalty_per_unit&lt;br /&gt;
      flash[:error] = &amp;quot;The maximum penalty cannot be less than penalty per unit.&amp;quot;&lt;br /&gt;
      invalid_penalty_per_unit = true&lt;br /&gt;
    else&lt;br /&gt;
      invalid_penalty_per_unit = false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  #method to check whether the policy name given as a parameter already exists under the current instructor id&lt;br /&gt;
  #it return true if there's another policy with the same name under current instructor else false&lt;br /&gt;
  def check_policy_with_same_name(late_policy_name)&lt;br /&gt;
    @policy = LatePolicy.where(policy_name: late_policy_name)&lt;br /&gt;
    if !@policy.nil? &amp;amp;&amp;amp; !@policy.empty?&lt;br /&gt;
      @policy.each do |p|&lt;br /&gt;
        next unless p.instructor_id == instructor_id&lt;br /&gt;
        return true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    return false&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
In case of update action call, there was a part of code which was updating already calculated penalty objects based on the updated late policy. This part was written as a separate method in the helper class with name &amp;quot;update_calculated_penalty_objects&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
  def update_calculated_penalty_objects(penalty_policy)&lt;br /&gt;
    @penaltyObjs = CalculatedPenalty.all&lt;br /&gt;
    @penaltyObjs.each do |pen|&lt;br /&gt;
      @participant = AssignmentParticipant.find(pen.participant_id)&lt;br /&gt;
      @assignment = @participant.assignment&lt;br /&gt;
      next unless @assignment.late_policy_id == penalty_policy.id&lt;br /&gt;
      @penalties = calculate_penalty(pen.participant_id)&lt;br /&gt;
      @total_penalty = (@penalties[:submission] + @penalties[:review] + @penalties[:meta_review])&lt;br /&gt;
      if pen.deadline_type_id.to_i == 1&lt;br /&gt;
        {penalty_points: @penalties[:submission]}&lt;br /&gt;
        pen.update_attribute(:penalty_points, @penalties[:submission])&lt;br /&gt;
      elsif pen.deadline_type_id.to_i == 2&lt;br /&gt;
        {penalty_points: @penalties[:review]}&lt;br /&gt;
        pen.update_attribute(:penalty_points, @penalties[:review])&lt;br /&gt;
      elsif pen.deadline_type_id.to_i == 5&lt;br /&gt;
        {penalty_points: @penalties[:meta_review]}&lt;br /&gt;
        pen.update_attribute(:penalty_points, @penalties[:meta_review])&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Some variable names were changed in order to make it easier for reader to understand the meaning of code.&lt;br /&gt;
There was some unused commented code which was removed.&lt;br /&gt;
&lt;br /&gt;
===Penalty Helper===&lt;br /&gt;
This is a helper class which contains methods which calculate the different penalties, and are then brought together in one Hash object. The aim was to keep the methods below 25 lines of code if possible. Out of the numerous methods in the file, there were 3 substantial methods, namely calculate_penalty, calculate_submission_penalty, and compute_penalty_on_reviews crossed the 25 line limit.&lt;br /&gt;
&lt;br /&gt;
calculate_penalty is the main method of the PenaltyHelper module. It is called from the [https://github.com/expertiza/expertiza/blob/master/app/controllers/grades_controller.rb GradesController] module. The other methods are called from within the calculate_penalty module. The method mainly contains a few assignment statements, and some method calls. There was no scope for it to be shortened further without risking non-operation of some functionalities.&lt;br /&gt;
&lt;br /&gt;
A particular segment of code converted a time difference into respective unit. This code was inserted into a method with the parameter 'time_difference'. The conversion segment was called in calculate_submission_penalty, as well as compute_penalty_on_reviews. Inserting the conversion logic into a separate method allowed the simplification of both methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # The new method defined to convert time difference into respective unit&lt;br /&gt;
  def calculate_penalty_minutes(time_difference)&lt;br /&gt;
    if @penalty_unit == 'Minute'&lt;br /&gt;
      penalty_minutes = time_difference / 60&lt;br /&gt;
    elsif @penalty_unit == 'Hour'&lt;br /&gt;
      penalty_minutes = time_difference / 3600&lt;br /&gt;
    elsif @penalty_unit == 'Day'&lt;br /&gt;
      penalty_minutes = time_difference / 86_400&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The method was called in two places.&lt;br /&gt;
&lt;br /&gt;
  # Line 44&lt;br /&gt;
  time_difference = last_submission_time - submission_due_date&lt;br /&gt;
  penalty_minutes = calculate_penalty_minutes(time_difference)&lt;br /&gt;
&lt;br /&gt;
  # Line 109&lt;br /&gt;
  time_difference = review_map_created_at_list.at(i) - review_due_date&lt;br /&gt;
  penalty_minutes = calculate_penalty_minutes(time_difference)&lt;br /&gt;
&lt;br /&gt;
Apart from the method which was defined, some other methods which were not being called were removed, extraneous statements which were written and then commented were also removed. Also, minor modifications in places where code did not follow Ruby grammar were made, for eg: a space was added between 'if' and the condition statement.&lt;br /&gt;
&lt;br /&gt;
===Functional and integration testing===&lt;br /&gt;
Motivation behind testing including the technologies used for testing.&lt;br /&gt;
&lt;br /&gt;
====penalty_helper_spec.rb====&lt;br /&gt;
Specific changes identified and made here, including the motivation behind making those changes.&lt;br /&gt;
&lt;br /&gt;
====late_policies_controller_spec.rb====&lt;br /&gt;
Specific changes identified TO BE made here, including the motivation behind making those changes.&lt;br /&gt;
&lt;br /&gt;
==Peer review validation==&lt;br /&gt;
&lt;br /&gt;
===Validating application functionality===&lt;br /&gt;
Instructions on how our reviewers should validate the impacted functionality to ensure that it still works.&lt;br /&gt;
&lt;br /&gt;
===Validating code via RSpec tests===&lt;br /&gt;
&lt;br /&gt;
====Setup Expertiza VCL environment====&lt;br /&gt;
First, setup your Expertiza environment. Navigate to https://vcl.ncsu.edu and click the &amp;quot;Make a Reservation&amp;quot; button. Sign in with your Unity ID. Click the &amp;quot;Reservations&amp;quot; button and then click &amp;quot;New Reservation&amp;quot;. In the environment drop down box select the '	[CSC517, F15] Ruby on Rails / Expertiza' environment, set your session duration, and click the &amp;quot;Create Reservation&amp;quot; button. &lt;br /&gt;
&lt;br /&gt;
One your reservation is ready you should see a Connect! button. Click it and copy the IP address. If you don't have PuTTY then download it. Open PuTTY and paste the IP address in the hostname field and click &amp;quot;Open.&amp;quot; Confirm connection at the security dialog. Log into the server using your Unity ID and password. Once logged in, execute the following commands to setup the Expertiza environment.&lt;br /&gt;
&lt;br /&gt;
   git clone https://github.com/michaelamoran/expertiza.git&lt;br /&gt;
   cd expertiza&lt;br /&gt;
   cp ./config/database.yml.example ./config/database.yml&lt;br /&gt;
   cp ./config/secrets.yml.example ./config/secrets.yml&lt;br /&gt;
   vi ./Gemfile&lt;br /&gt;
   # Search for 'pg' and delete the line and save&lt;br /&gt;
   bundle install&lt;br /&gt;
   rake db:migrate&lt;br /&gt;
   curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash&lt;br /&gt;
   source ~/.bash_profile&lt;br /&gt;
   nvm install v7.7.3&lt;br /&gt;
   npm install -g bower&lt;br /&gt;
   bower install&lt;br /&gt;
   &lt;br /&gt;
   # The following commands will prepare the test database so the tests don't fail.&lt;br /&gt;
   rake db:create RAILS_ENV=test&lt;br /&gt;
   rake db:migrate RAILS_ENV=test&lt;br /&gt;
&lt;br /&gt;
====Executing tests====&lt;br /&gt;
&lt;br /&gt;
Now, to run the tests, make sure you are in the project's root directory (i.e. ~/expertiza/). Run the following command:&lt;br /&gt;
&lt;br /&gt;
   rspec spec/helpers/penalty_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Once it is complete, the output should contain the number of test cases and how man of them passed or failed.&lt;/div&gt;</summary>
		<author><name>Dpatel12</name></author>
	</entry>
</feed>