CSC/ECE 517 Spring 2017/Use Ajax to add Participants,TA and Edit Questionnaire: Difference between revisions
Line 23: | Line 23: | ||
*_questionnaire.html.erb | *_questionnaire.html.erb | ||
Adding questions is | Adding questions feature is performed in the following method of ''questionnaire_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 | |||
==UI Testing== | ==UI Testing== | ||
==Project Deployment== | ==Project Deployment== | ||
==Future work== | ==Future work== |
Revision as of 23:59, 23 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 questionnaire_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