Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 5c3db5f

Browse files
committed
added challenge preview survey
1 parent e6cc97c commit 5c3db5f

File tree

7 files changed

+190
-4
lines changed

7 files changed

+190
-4
lines changed

Diff for: app/controllers/challenges_controller.rb

+29-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
include ActionView::Helpers::NumberHelper
99

1010
class ChallengesController < ApplicationController
11-
before_filter :check_if_challenge_exists, :only => [:register, :submission, :submission_view_only, :cal, :preview, :show, :registrants, :results, :participant_submissions, :participant_scorecard, :scorecard, :survey]
11+
before_filter :check_if_challenge_exists, :only => [:register, :submission, :submission_view_only, :cal, :preview, :preview_survey, :show, :registrants, :results, :participant_submissions, :participant_scorecard, :scorecard, :survey]
1212
before_filter :valid_challenge, :only => [:submission, :show, :registrants, :results, :scorecard, :register, :survey]
13-
before_filter :must_be_signed_in, :only => [:preview, :review, :register, :watch, :register_agree_to_tos, :submission, :submission_view_only, :new_comment, :toggle_discussion_email, :participant_submissions]
13+
before_filter :must_be_signed_in, :only => [:preview, :preview_survey, :review, :register, :watch, :register_agree_to_tos, :submission, :submission_view_only, :new_comment, :toggle_discussion_email, :participant_submissions]
1414
before_filter :must_be_open, :only => [:submission_file_upload, :submission_url_upload]
1515
before_filter :admin_only, :only => [:all_submissions, :cal, :preview]
1616
before_filter :redirect_to_http
@@ -291,13 +291,39 @@ def scorecard
291291
@scorecard_group = Challenges.scorecard_questions(current_access_token, params[:id].strip)
292292
@participation_status = challenge_participation_status
293293
end
294+
295+
def preview_survey
296+
if params["survey"]
297+
post_results = Surveys.save_pre_challenge(current_access_token, params[:id].strip, params["survey"])
298+
logger.info post_results
299+
flash.now[:notice] = "Submitted! Thanks for contributing to the community by helping us launch better challenges."
300+
end
301+
302+
@preview_challenge = SfdcConnection.dbdc_client(current_access_token)
303+
.query("select name, description__c, requirements__c, comments__c, start_date__c, end_date__c,
304+
top_prize__c, submission_details__c, additional_info__c, challenge_type__c, status__c
305+
from challenge__c where challenge_id__c = '#{params[:id].strip}'").first
306+
307+
@prizes = SfdcConnection.dbdc_client(current_access_token)
308+
.query("select Place__c, Prize__c from Challenge_Prize__c
309+
where challenge__r.challenge_id__c = '#{params[:id].strip}' order by place__c")
310+
311+
@categories = SfdcConnection.dbdc_client(current_access_token)
312+
.query("select Display_Name__c from Challenge_Category__c
313+
where challenge__r.challenge_id__c = '#{params[:id].strip}'")
314+
315+
@assets = SfdcConnection.admin_dbdc_client
316+
.query("select Filename__c from Asset__c
317+
where challenge__r.challenge_id__c = '#{params[:id].strip}'")
318+
319+
end
294320

295321
def survey
296322
@challenge_detail = current_challenge
297323
determine_page_title
298324
@participation_status = challenge_participation_status
299325
if params["survey"]
300-
post_results = Surveys.save(current_access_token, params[:id].strip, params["survey"])
326+
post_results = Surveys.save_post_challenge(current_access_token, params[:id].strip, params["survey"])
301327
flash[:notice] = "Thanks for completing the survey!"
302328
redirect_to challenge_path
303329
end

Diff for: app/views/challenges/preview_survey.html.erb

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<div class="page-heading">
2+
<h2 class="melbourne">Challenge Preview Survey</h2>
3+
</div>
4+
5+
<div class="content-wrapper">
6+
7+
<%= flash_messages %>
8+
9+
<p style="padding-top:10px">Thanks for taking the time to preview this challenge before it's posted to the
10+
community. Your feedback is extremely valuable and we appreciate your effort! Our goal is to prevent launching challenges that are poorly written, confusing or have bad timeline/prize money. Your feedback will help us launch better challenges to the community.</p>
11+
12+
<p>Some challenge are better written than other and are a work in progress. We apologize if some info is missing but
13+
please provide your feedback with the current information at hand. Again, we appreciate your effort.</p><br/>
14+
15+
<h1 style="font-size: 20pt; padding-bottom:15px"><%= @preview_challenge.Name %></h1>
16+
17+
<% if @preview_challenge['Status__c'].eql?('Planned') %>
18+
19+
Starts: <%= @preview_challenge["Start_Date__c"] %><br/>
20+
Ends: <%= @preview_challenge["End_Date__c"] %><br/>
21+
Type: <%= @preview_challenge["Challenge_Type__c"] %><br/>
22+
<% unless @preview_challenge["Comments__c"].nil? %>
23+
Comments: <%= @preview_challenge["Comments__c"] %><br/>
24+
<% end %>
25+
26+
<% if @prizes.count > 0 %>
27+
Prizes:<br/>
28+
<% @prizes.each do |record| %>
29+
&nbsp;&nbsp;<%= record["Place__c"].to_i.ordinalize %> <%= record["Prize__c"] %><br />
30+
<% end %>
31+
<% end %>
32+
33+
<% if @categories.count > 0 %>
34+
Categories:<br/>
35+
<% @categories.each do |record| %>
36+
&nbsp;&nbsp;<%= record["Display_Name__c"] %><br />
37+
<% end %>
38+
<% end %>
39+
40+
<% if @assets.count > 0 %>
41+
Assets:<br/>
42+
<% @assets.each do |record| %>
43+
&nbsp;&nbsp;<a href="https://s3.amazonaws.com/<%= ENV['AMAZON_S3_DEFAULT_BUCKET'] %>/challenges/<%= params[:id] %>/<%= record["Filename__c"] %>" target="_blank"><%= record["Filename__c"] %></a><br />
44+
<% end %>
45+
<% end %>
46+
47+
<h3 style="padding-top: 15px">Description</h3>
48+
<p><%= raw(@preview_challenge["Description__c"])%></p>
49+
50+
<h3 style="padding-top: 15px">Requirements</h3>
51+
<p><%= raw(@preview_challenge["Requirements__c"])%></p>
52+
53+
<h3 style="padding-top: 15px">Submission Details</h3>
54+
<p><%= raw(@preview_challenge["Submission_Details__c"]) %></p>
55+
56+
<% unless @preview_challenge["Additional_Info__c"].nil? %>
57+
<h3 style="padding-top: 15px">Additional Info</h3>
58+
<p><%= raw(@preview_challenge["Additional_Info__c"]) %></p>
59+
<% end %>
60+
61+
<hr style="margin-bottom:15px">
62+
63+
<div id="survey">
64+
<%= form_for survey_path, :name => "survey", :method => "post" do |f| %>
65+
<input type="hidden" name="survey[membername]" value="<%= current_user.username %>">
66+
67+
<label>1. Are the challenge description and requirements clearly stated and achievable?</label>
68+
<div class="holder">
69+
<input type="radio" name="survey[requirements]" value="Yes" />
70+
<%= label_tag("Yes") %><br/>
71+
<input type="radio" name="survey[requirements]" value="No" />
72+
<%= label_tag("No") %><br/>
73+
<input type="radio" name="survey[requirements]" value="Requirements may not be possible" />
74+
<%= label_tag("Requirements may not be possible") %><br/>
75+
<input type="radio" name="survey[requirements]" value="The description needs to be written better" />
76+
<%= label_tag("The description needs to be written better") %><br/>
77+
<input type="radio" name="survey[requirements]" value="The requirements are not clear" />
78+
<%= label_tag("The requirements are not clear") %><br/>
79+
<input type="radio" name="survey[requirements]" value="I don't understand the description nor the requirements" />
80+
<%= label_tag("I don't understand the description nor the requirements") %>
81+
82+
</div>
83+
<div class="spacer"></div>
84+
85+
<label>2. If there is a problem with the description and/or requirements what needs to be fixed or addressed? How can we make it better?</label>
86+
<div class="holder"><textarea name="survey[requirements_feedback]" rows="8" cols="40"></textarea></div>
87+
<div class="spacer"></div>
88+
89+
<label>3. Is this enough time to complete the challenge?</label>
90+
<div class="holder">
91+
<input type="radio" name="survey[timeframe]" value="Yes" />
92+
<%= label_tag("Yes") %><br/>
93+
<input type="radio" name="survey[timeframe]" value="No" />
94+
<%= label_tag("No") %><br/>
95+
<input type="radio" name="survey[timeframe]" value="Too much time" />
96+
<%= label_tag("Too much time") %>
97+
</div>
98+
<div class="spacer"></div>
99+
100+
<label>4. If the prize money is specified, is it adequate for the effort and time allotted?</label>
101+
<div class="holder">
102+
<input type="radio" name="survey[prize_money]" value="Yes" />
103+
<%= label_tag("Yes") %><br/>
104+
<input type="radio" name="survey[prize_money]" value="No" />
105+
<%= label_tag("No") %><br/>
106+
<input type="radio" name="survey[prize_money]" value="Too much money" />
107+
<%= label_tag("Too much money") %><br/>
108+
<input type="radio" name="survey[prize_money]" value="Not enough money" />
109+
<%= label_tag("Not enough money") %> <br/>
110+
<input type="radio" name="survey[prize_money]" value="I don't see the prize money" />
111+
<%= label_tag("I don't see the prize money") %>
112+
</div>
113+
<div class="spacer"></div>
114+
115+
<label>5. How would you participate in this challenge?</label>
116+
<div class="holder">
117+
<input type="radio" name="survey[participation]" value="Possibly submit a solution" />
118+
<%= label_tag("Possibly submit a solution") %><br/>
119+
<input type="radio" name="survey[participation]" value="Probably submit a solution" />
120+
<%= label_tag("Probably submit a solution") %><br/>
121+
<input type="radio" name="survey[participation]" value="Would like to be a reviewer" />
122+
<%= label_tag("Would like to be a reviewer") %><br/>
123+
<input type="radio" name="survey[participation]" value="This doesn't interest me at all" />
124+
<%= label_tag("This doesn't interest me at all") %>
125+
</div>
126+
<div class="spacer"></div>
127+
128+
<label>6. What can we do to make this challenge better?</label>
129+
<div class="holder"><textarea name="survey[improvements]" rows="8" cols="40"></textarea></div>
130+
131+
<% end %>
132+
133+
<a class="button" style="margin-left:25px; margin-top:10px" onclick="document.forms[0].submit();"> <span>Submit</span></a>
134+
135+
</div>
136+
137+
<% else %>
138+
Sorry... this challenge is not available for preview. Looks like it has already been launched.
139+
<% end %>
140+
141+
</div>

Diff for: config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
match 'challenges/:id/agree_to_tos', :to => 'challenges#register_agree_to_tos', :as => :agree_tos
6464
match 'challenges/:id/results', :to => 'challenges#results', :as => :results
6565
match 'challenges/:id/survey', :to => 'challenges#survey', :as => :survey
66+
match 'challenges/:id/preview_survey', :to => 'challenges#preview_survey', :as => :preview_survey
6667
match 'challenges/:id/submissions/:participant', :to => 'challenges#participant_submissions', :as => :participant_submissions
6768
match 'challenges/:id/scorecard/:scorecard/:reviewer/:username', :to => 'challenges#participant_scorecard', :as => :participant_scorecard
6869
match 'challenges/:id/watch', :to => 'challenges#watch', :as => :watch

Diff for: db/development.sqlite3

0 Bytes
Binary file not shown.

Diff for: dump.rdb

-4 Bytes
Binary file not shown.

Diff for: lib/surveys.rb

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class Surveys < Cloudspokes
44

5-
def self.save(access_token, id, params)
5+
def self.save_post_challenge(access_token, id, params)
66

77
options = {
88
:body => {
@@ -19,5 +19,23 @@ def self.save(access_token, id, params)
1919
results = post(ENV['SFDC_REST_API_URL']+'/surveys', options)
2020
end
2121

22+
def self.save_pre_challenge(access_token, id, params)
23+
24+
options = {
25+
:body => {
26+
:challenge => id,
27+
:membername => params[:membername],
28+
:requirements => params[:requirements],
29+
:requirements_feedback => params[:requirements_feedback],
30+
:timeframe => params[:timeframe],
31+
:prize_money => params[:prize_money],
32+
:participation => params[:participation],
33+
:improvements => params[:improvements]
34+
}
35+
}
36+
37+
post(ENV['SFDC_REST_API_URL']+'/preview-surveys', options)
38+
end
39+
2240
end
2341

Diff for: temp-19425.rdb

Whitespace-only changes.

0 commit comments

Comments
 (0)