New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
endless survey loop #5
Comments
on a per survey basis |
In order to stop the endless loop I modified the following files. controllers/surveying_controller.rb In the Surveying controller I modified the update action to the following(this code has redirect to url paths specific to my application): def update finished = false if params[:responses] or params[:response_groups] saved = @response_set.update_attributes(:response_attributes => (params[:responses] || {}).dup , :response_group_attributes => (params[:response_groups] || {}).dup) #copy (dup) to preserve params because we manipulate params in the response_set methods if (saved && params[:finish]) @response_set.complete! saved = @response_set.save! finished = true end end respond_to do |format| format.html do if (finished && saved) flash[:notice] = "Completed survey" redirect_to user_path(current_user) else flash[:notice] = saved ? "" : "Unable to update survey" unless saved.nil? # Saved is nil if there are no questions on the page (ie if it only contains a label) redirect_to :action => "edit", :anchor => @anchor, :params => {:section => @section.id} end end # No redirect needed if we're talking to the page via json format.json do dependent_hash = dependents(@response_set) @dependents = dependent_hash[:show] render :json => {:show => dependent_hash[:show].map{|q| question_id_helper(q)}, :hide => dependent_hash[:hide].map{|q| question_id_helper(q)} }.to_json end end end I modified edit.html.haml to give the submit button a name of "finish" if there is not a next section like so: = @section.next ? section_next_helper(@section.next) : submit_tag("Click here to finish", :name => "finish") |
fix for endless survey loop, allowing customizing surveyor default finish page. cleanup of extra controllers. thanks mgurley. closed by adb972c |
welcome page, finishing page
The text was updated successfully, but these errors were encountered: