CSC/ECE 517 Spring 2017/Use Ajax to add Participants,TA and Edit Questionnaire: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 23: Line 23:
*_questionnaire.html.erb
*_questionnaire.html.erb


Adding questions feature is performed in the following method of ''questionnaire_controller.rb'' class
Adding questions feature is performed in the following method of ''questionnaires_controller.rb'' class


def add_new_questions
def add_new_questions
Line 47: Line 47:
     redirect_to edit_questionnaire_path(questionnaire_id.to_sym)
     redirect_to edit_questionnaire_path(questionnaire_id.to_sym)
   end
   end
This method invokes ''question.create'' method in ''questions_cotroller.rb'' and saves the created question to the database. Then it redirects to the ''edit.html.erb'' page which causes page refresh while adding questions.
'''Solution:''' This problem was tried to solve using ajax by changing or adding the following classes and pages
* _question.html.erb (added)
  Consists of table format to display question
* add_new_questions.js.erb (added)
 
* edit.html.erb (modified)
* questionnaires_controller.rb


==UI Testing==
==UI Testing==
==Project Deployment==
==Project Deployment==
==Future work==
==Future work==

Revision as of 00:11, 24 March 2017

Introduction

Expertiza is an opensource software developed to assist people in education institutions to perform peer reviews and group projects. It is exceptionally helpful to the students and instructors. The software is designed in MVC (Model-View-Controller) architecture using ruby on rails.

Problem Statement

Expertiza provides many categories to manage by instructor. Few of them are assignments,courses and questionnaires Adding of records like participants, Teaching assistants and questions in these pages is done by submitting the entire page. This requires loading of entire page to add a record and loading of entire page again to save it.

Proposed Solution

This project proposes use of ajax for the required pages to avoid page reloading at the time of adding and saving records. This solution will make sure that adding or saving of record is taken care in the browser it self. It can be achieved by calling corresponding controller method , adding/saving the record and rendering it back to java script pages instead of redirecting it to the same page. Javascript pages will append the added record functionality to the initial page . Thus page refresh is avoided.

Tasks

  • Add participant in the assignments section using ajax
  • Add TA in the courses section using ajax
  • Edit Questionnaire by using ajax for adding questions in the Questionnaire section.

Implementation

Adding participant

Adding TA

Edit Questionnaire

Current scenario : page consists of different subsections for creating questionnaire,adding questions to the questionnaire and saving the questionnaire i.e.

  • _questionnaire.html.erb

Adding questions feature is performed in the following method of questionnaires_controller.rb class

def add_new_questions

   questionnaire_id = params[:id] unless params[:id].nil?
   num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size
   ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|
     question = Object.const_get(params[:question][:type]).create(txt: , questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)
     if question.is_a? ScoredQuestion
       question.weight = 1
       question.max_label = 'Strongly agree'
       question.min_label = 'Strongly disagree'
     end
     question.size = '50, 3' if question.is_a? Criterion
     question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown
     question.size = '60, 5' if question.is_a? TextArea
     question.size = '30' if question.is_a? TextField
     begin
       question.save
     rescue
       flash[:error] = $ERROR_INFO
     end
   end
   redirect_to edit_questionnaire_path(questionnaire_id.to_sym)
 end


This method invokes question.create method in questions_cotroller.rb and saves the created question to the database. Then it redirects to the edit.html.erb page which causes page refresh while adding questions.

Solution: This problem was tried to solve using ajax by changing or adding the following classes and pages

  • _question.html.erb (added)
  Consists of table format to display question
  • add_new_questions.js.erb (added)
  • edit.html.erb (modified)
  • questionnaires_controller.rb

UI Testing

Project Deployment

Future work