Skip to content
This repository was archived by the owner on Oct 1, 2019. It is now read-only.

Commit 95e412a

Browse files
several scaffolds generated and trying to hook up the highchart.js for generating a graph
1 parent 786e228 commit 95e412a

33 files changed

+633
-4
lines changed

app/controllers/application_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class ApplicationController < ActionController::Base
2-
before_filter :authenticate_admin!
2+
before_filter :authenticate_admin!
33
protect_from_forgery
44

55
def sign_out_and_redirect(resource_or_scope)

app/controllers/reports_controller.rb

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
class ReportsController < ApplicationController
2+
# GET /reports
3+
# GET /reports.xml
4+
def index
5+
@reports = Report.all
6+
7+
respond_to do |format|
8+
format.html # index.html.erb
9+
format.xml { render :xml => @reports }
10+
end
11+
end
12+
13+
# GET /reports/1
14+
# GET /reports/1.xml
15+
def show
16+
@report = Report.find(params[:id])
17+
18+
respond_to do |format|
19+
format.html # show.html.erb
20+
format.xml { render :xml => @report }
21+
end
22+
end
23+
24+
# GET /reports/new
25+
# GET /reports/new.xml
26+
def new
27+
@report = Report.new
28+
29+
respond_to do |format|
30+
format.html # new.html.erb
31+
format.xml { render :xml => @report }
32+
end
33+
end
34+
35+
# GET /reports/1/edit
36+
def edit
37+
@report = Report.find(params[:id])
38+
end
39+
40+
# POST /reports
41+
# POST /reports.xml
42+
def create
43+
@report = Report.new(params[:report])
44+
45+
respond_to do |format|
46+
if @report.save
47+
format.html { redirect_to(@report, :notice => 'Report was successfully created.') }
48+
format.xml { render :xml => @report, :status => :created, :location => @report }
49+
else
50+
format.html { render :action => "new" }
51+
format.xml { render :xml => @report.errors, :status => :unprocessable_entity }
52+
end
53+
end
54+
end
55+
56+
# PUT /reports/1
57+
# PUT /reports/1.xml
58+
def update
59+
@report = Report.find(params[:id])
60+
61+
respond_to do |format|
62+
if @report.update_attributes(params[:report])
63+
format.html { redirect_to(@report, :notice => 'Report was successfully updated.') }
64+
format.xml { head :ok }
65+
else
66+
format.html { render :action => "edit" }
67+
format.xml { render :xml => @report.errors, :status => :unprocessable_entity }
68+
end
69+
end
70+
end
71+
72+
# DELETE /reports/1
73+
# DELETE /reports/1.xml
74+
def destroy
75+
@report = Report.find(params[:id])
76+
@report.destroy
77+
78+
respond_to do |format|
79+
format.html { redirect_to(reports_url) }
80+
format.xml { head :ok }
81+
end
82+
end
83+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
class SurveyQuestionResultsController < ApplicationController
2+
# GET /survey_question_results
3+
# GET /survey_question_results.xml
4+
def index
5+
@survey_question_results = SurveyQuestionResult.all
6+
7+
respond_to do |format|
8+
format.html # index.html.erb
9+
format.xml { render :xml => @survey_question_results }
10+
end
11+
end
12+
13+
# GET /survey_question_results/1
14+
# GET /survey_question_results/1.xml
15+
def show
16+
@survey_question_result = SurveyQuestionResult.find(params[:id])
17+
18+
respond_to do |format|
19+
format.html # show.html.erb
20+
format.xml { render :xml => @survey_question_result }
21+
end
22+
end
23+
24+
# GET /survey_question_results/new
25+
# GET /survey_question_results/new.xml
26+
def new
27+
@survey_question_result = SurveyQuestionResult.new
28+
29+
respond_to do |format|
30+
format.html # new.html.erb
31+
format.xml { render :xml => @survey_question_result }
32+
end
33+
end
34+
35+
# GET /survey_question_results/1/edit
36+
def edit
37+
@survey_question_result = SurveyQuestionResult.find(params[:id])
38+
end
39+
40+
# POST /survey_question_results
41+
# POST /survey_question_results.xml
42+
def create
43+
@survey_question_result = SurveyQuestionResult.new(params[:survey_question_result])
44+
45+
respond_to do |format|
46+
if @survey_question_result.save
47+
format.html { redirect_to(@survey_question_result, :notice => 'Survey question result was successfully created.') }
48+
format.xml { render :xml => @survey_question_result, :status => :created, :location => @survey_question_result }
49+
else
50+
format.html { render :action => "new" }
51+
format.xml { render :xml => @survey_question_result.errors, :status => :unprocessable_entity }
52+
end
53+
end
54+
end
55+
56+
# PUT /survey_question_results/1
57+
# PUT /survey_question_results/1.xml
58+
def update
59+
@survey_question_result = SurveyQuestionResult.find(params[:id])
60+
61+
respond_to do |format|
62+
if @survey_question_result.update_attributes(params[:survey_question_result])
63+
format.html { redirect_to(@survey_question_result, :notice => 'Survey question result was successfully updated.') }
64+
format.xml { head :ok }
65+
else
66+
format.html { render :action => "edit" }
67+
format.xml { render :xml => @survey_question_result.errors, :status => :unprocessable_entity }
68+
end
69+
end
70+
end
71+
72+
# DELETE /survey_question_results/1
73+
# DELETE /survey_question_results/1.xml
74+
def destroy
75+
@survey_question_result = SurveyQuestionResult.find(params[:id])
76+
@survey_question_result.destroy
77+
78+
respond_to do |format|
79+
format.html { redirect_to(survey_question_results_url) }
80+
format.xml { head :ok }
81+
end
82+
end
83+
end

app/helpers/reports_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ReportsHelper
2+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module SurveyQuestionResultsHelper
2+
end

app/models/report.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Report < ActiveRecord::Base
2+
belongs_to :survey
3+
end

app/models/survey.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Survey < ActiveRecord::Base
22
has_many :questions
3+
has_many :reports
34
accepts_nested_attributes_for :questions, :allow_destroy => true
45

56
validates :status, :presence => true

app/models/survey_question_result.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class SurveyQuestionResult < ActiveRecord::Base
2+
belongs_to :question
3+
belongs_to :report
4+
5+
end

app/views/layouts/application.html.erb

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
<title><%=h yield(:title)%></title>
66
<%= stylesheet_link_tag :all %>
77
<script type="text/javascript"
8-
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
9-
<%= javascript_include_tag :defaults %>
8+
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
9+
<%= javascript_include_tag :defaults %>
10+
<%= javascript_include_tag "javascripts/highcharts" %>
1011
<%= csrf_meta_tag %>
1112
</head>
1213
<body>

app/views/reports/_form.html.erb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<%= form_for(@report) do |f| %>
2+
<% if @report.errors.any? %>
3+
<div id="error_explanation">
4+
<h2><%= pluralize(@report.errors.count, "error") %> prohibited this report from being saved:</h2>
5+
6+
<ul>
7+
<% @report.errors.full_messages.each do |msg| %>
8+
<li><%= msg %></li>
9+
<% end %>
10+
</ul>
11+
</div>
12+
<% end %>
13+
14+
<div class="field">
15+
<%= f.label :survey_id %><br />
16+
<%= f.text_field :survey_id %>
17+
</div>
18+
<div class="actions">
19+
<%= f.submit %>
20+
</div>
21+
<% end %>

app/views/reports/_graph.html.erb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title></title>
6+
<script type="text/javascript" src="/javascript/graph.js"></script>
7+
<body id="index">
8+
<div id="container">
9+
<div id="chart1" style="width: 100%; height: 400px"></div> </head>
10+
11+
</div>
12+
</body>
13+
</html
14+
15+

app/views/reports/edit.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<h1>Editing report</h1>
2+
3+
<%= render 'form' %>
4+
5+
<%= render %>
6+
7+
<%= link_to 'Show', @report %> |
8+
<%= link_to 'Back', reports_path %>

app/views/reports/index.html.erb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<h1>Listing reports</h1>
2+
3+
<table>
4+
<tr>
5+
<th>Survey</th>
6+
<th></th>
7+
<th></th>
8+
<th></th>
9+
</tr>
10+
11+
<% @reports.each do |report| %>
12+
<tr>
13+
<td><%= report.survey_id %></td>
14+
<td><%= link_to 'Show', report %></td>
15+
<td><%= link_to 'Edit', edit_report_path(report) %></td>
16+
<td><%= link_to 'Destroy', report, :confirm => 'Are you sure?', :method => :delete %></td>
17+
</tr>
18+
<% end %>
19+
</table>
20+
21+
<br />
22+
23+
<%= link_to 'New Report', new_report_path %>

app/views/reports/new.html.erb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<h1>New report</h1>
2+
3+
<%= render 'form' %>
4+
5+
<%= link_to 'Back', reports_path %>

app/views/reports/show.html.erb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<p id="notice"><%= notice %></p>
2+
3+
<p>
4+
<b>Survey:</b>
5+
<%= @report.survey_id %>
6+
<%= render :partial => 'graph'%>
7+
</p>
8+
9+
10+
<%= link_to 'Edit', edit_report_path(@report) %> |
11+
<%= link_to 'Back', reports_path %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<%= form_for(@survey_question_result) do |f| %>
2+
<% if @survey_question_result.errors.any? %>
3+
<div id="error_explanation">
4+
<h2><%= pluralize(@survey_question_result.errors.count, "error") %> prohibited this survey_question_result from being saved:</h2>
5+
6+
<ul>
7+
<% @survey_question_result.errors.full_messages.each do |msg| %>
8+
<li><%= msg %></li>
9+
<% end %>
10+
</ul>
11+
</div>
12+
<% end %>
13+
14+
<div class="field">
15+
<%= f.label :report_id %><br />
16+
<%= f.text_field :report_id %>
17+
</div>
18+
<div class="field">
19+
<%= f.label :question_id %><br />
20+
<%= f.text_field :question_id %>
21+
</div>
22+
<div class="field">
23+
<%= f.label :graph %><br />
24+
<%= f.check_box :graph %>
25+
</div>
26+
<div class="field">
27+
<%= f.label :raw_data %><br />
28+
<%= f.check_box :raw_data %>
29+
</div>
30+
<div class="field">
31+
<%= f.label :type_of_graph %><br />
32+
<%= f.text_area :type_of_graph %>
33+
</div>
34+
<div class="actions">
35+
<%= f.submit %>
36+
</div>
37+
<% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h1>Editing survey_question_result</h1>
2+
3+
<%= render 'form' %>
4+
5+
<%= link_to 'Show', @survey_question_result %> |
6+
<%= link_to 'Back', survey_question_results_path %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h1>Listing survey_question_results</h1>
2+
3+
<table>
4+
<tr>
5+
<th>Report</th>
6+
<th>Question</th>
7+
<th>Graph</th>
8+
<th>Raw data</th>
9+
<th>Type of graph</th>
10+
<th></th>
11+
<th></th>
12+
<th></th>
13+
</tr>
14+
15+
<% @survey_question_results.each do |survey_question_result| %>
16+
<tr>
17+
<td><%= survey_question_result.report_id %></td>
18+
<td><%= survey_question_result.question_id %></td>
19+
<td><%= survey_question_result.graph %></td>
20+
<td><%= survey_question_result.raw_data %></td>
21+
<td><%= survey_question_result.type_of_graph %></td>
22+
<td><%= link_to 'Show', survey_question_result %></td>
23+
<td><%= link_to 'Edit', edit_survey_question_result_path(survey_question_result) %></td>
24+
<td><%= link_to 'Destroy', survey_question_result, :confirm => 'Are you sure?', :method => :delete %></td>
25+
</tr>
26+
<% end %>
27+
</table>
28+
29+
<br />
30+
31+
<%= link_to 'New Survey question result', new_survey_question_result_path %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<h1>New survey_question_result</h1>
2+
3+
<%= render 'form' %>
4+
5+
<%= link_to 'Back', survey_question_results_path %>

0 commit comments

Comments
 (0)