<var _answertypes_explain = DESerializeJSON('{
"Text": ["Open Ended","Users will answer this question by typing in a plain text box.","wax_alert"],
"Autocomplete": ["Specific","Users will type their answer into an auto-completing text box.","wax_maybe"],
"Multiple_Choice": ["Multiple Choice","Users will answer this question by selecting from a list.","wax"]
}')>
<if GLOBAL.Def.iqtpi_age_num LTE 1>
<!--- types of questions that kids can ask --->
<var _answertypes = "Multiple_Choice">
<ensure variable="get.answertype" value="Multiple_Choice">
<else>
<!--- all question types --->
<var _answertypes = "Text,Autocomplete,Multiple_Choice">
<ensure variable="get.answertype" value="">
</if>
<if listFindNoCase(_answertypes,get.answertype) EQ 0>
<h3>What kind of question?</h3>
<ul style="max-width:300px;">
<loop list="#_answertypes#" index="i">
<var _i = replace(i,'_',' ','all')>
<li style="padding-bottom:7px;">
<a style="padding:3px;" class="wax #_answertypes_explain[i][3]#" href="http://#this_domain#/New_Question?&answertype=#i#"><b>#_answertypes_explain[i][1]#</b></a>
<div style="font-size:0.72em; padding:3px; color:#GLOBAL.Def.Style.Color.g2#;">#replace(_answertypes_explain[i][2],"will ","")#</div>
</li>
</loop>
</ul>
<p style="font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#;">
Remember, <b>you can't change questions after you create them</b>.
</p>
<BREAK>
</if>
<ensure variable="get.question_text" value="">
<var _question_text_is_valid = 0>
<if trim(get.question_text) EQ "?">
<var _question_text_is_valid = 0>
<var get.question_text = "">
<elseif reFind("#GLOBAL.Def.question_text_regex#",get.question_text)>
<var _question_text_is_valid = 1>
</if>
<if _question_text_is_valid EQ 0>
<if listLen(_answertypes) GT 1>
<div class="noverflow">
<div style="float:left; font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#; border-bottom:1px dashed #GLOBAL.Def.Style.color.g4#; padding-bottom:2px;">
Answer type: <b>#_answertypes_explain[get.answertype][1]#</b> (<a href="http://#this_domain#/New_Question">back</a>)
</div>
<div style="clear:left;"> </div>
</div>
</if>
<div style="margin-left:2em;">
<h3>Type your question:</h3>
<form id="question_form" action="http://#this_domain#/New_Question" method="get" enctype="application/x-www-form-urlencoded" style="margin:0px;">
<input name="x" value="0" type="hidden" style="display:none;">
<input name="answertype" value="#get.answertype#" type="hidden" style="display:none;">
<div class="noverflow">
<div style="width:2em; float:left; margin-left:1em;">
<img src="http://#this_domain#/file:/icon-simplistica_page_edit?&picwidth=64" border="0"
style="width:100%;">
</div>
<div style="margin-left:3.5em;">
<div><input id="question_text" type="text" name="question_text" value="#escapeDoubleQuotes(escapeMarkup(get.question_text))#"
style="width:70%; font-size:1.36em;"
autocomplete="off"></div>
<div style="padding-top:3px; font-size:0.72em; color:#GLOBAL.Def.Style.color.g2#; <if get.question_text NEQ ''>font-weight:bold;</if>">
Note: questions cannot contain special characters.
</div>
</div>
<div> </div>
<div>
<input type="submit" value="Next Step >" class="wax" style="cursor:pointer;">
</div>
</div>
</form>
<p style="font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#;">
Remember, <b>you can't change questions after you create them</b>.
</p>
</div>
<tag.jquery>
<script type="text/javascript">
$(document).ready(function() {
$('##question_form').submit(function() {
if (!is_question_text_valid()) {
var _tst = jQuery.trim($('##question_text').val());
alert('Question text cannot contain special characters.\n\nUse only letters, numbers, spaces and single quotes.');
return false;
}
return true;
});
$('##question_text').keyup(function(e) {
var _txt = $('##question_text').val();
var _orig_txt = _txt;
var _txt = _txt.replace(/#GLOBAL.Def.question_text_regex_negative#/g,'');
// bonus: get rid of double spaces or double single quotes
var _txt = _txt.replace(/[ ]+/g,' ');
var _txt = _txt.replace(/[']+/g,"'");
// bonus: get rid of anything after the question mark
var _txt = _txt.replace(/\?.*/g,'?');
if (jQuery.trim(_txt) == '?') { var _txt = ''; }
if (_txt !== _orig_txt) {
$('##question_text').val(_txt);
}
});
$('##question_text').focus();
});
function is_question_text_valid() {
var _txt = $('##question_text').val();
if (_txt.match(/#GLOBAL.Def.question_text_regex#/)) {
return true;
}
else {
return false;
}
}
</script>
<BREAK>
</if>
<!--- make get.question_text super clean: --->
<var get.question_text = trim(get.question_text)>
<var get.question_text = reReplace(get.question_text,"[ ]+"," ","all")><!--- no double spaces --->
<var get.question_text = reReplace(get.question_text,"[']+","'","all")><!--- no double single quotes --->
<var get.question_text = reReplace(get.question_text,"[?]+","?","all")><!--- no double question marks --->
<var get.question_text = reReplace(get.question_text,"\?(.)","\1","all")><!--- no question marks except at end --->
<if right(get.question_text,1) NEQ "?"><var get.question_text = get.question_text & "?"></if><!--- make sure it ends with a question mark --->
<var get.question_text = replace(get.question_text," ?","?")><!--- get rid of annoying " ?" --->
<ensure variable="get.duplicates_ok" value="0">
<if get.duplicates_ok NEQ 1>
<var _do_break = 0>
<set j="/question.title:""#get.question_text#"".name:""|/answertype-#get.answertype#|""" maxrows="1">
<setcrawl>
<h3>It's been done...</h3>
<p>
At least one other user has already created a #lcase(replace(get.answertype,'_',' '))# question called <b>#get.question_text#</b>.
</p>
<p>
Do you want to create this question anyway?
</p>
<p>
<a class="wax" href="http://#this_domain#/New_Question"><b>No, create a different question</b></a>
|
<a class="wax wax_maybe" href="http://#this_domain#/New_question?&answertype=#get.answertype#&question_text=#URLEncodedFormat(get.question_text)#&duplicates_ok=1">Yes, create this question anyway</a>
</p>
<var _do_break = 1>
</setcrawl>
<setempty>
<var get.duplicates_ok = 1>
</setempty>
</set>
<if _do_break EQ 1><BREAK></if>
</if>
<var _question_body_ok = 1>
<ensure variable="get.question_body" value="">
<if get.answertype EQ "multiple_choice">
<var get.question_body = trim(reReplace(get.question_body,"[\./#CHR(10)#]+",CHR(10),"all"))>
<if get.question_body EQ "">
<var _question_body_ok = 0>
<else>
<var _new_question_body = "">
<!--- answers must be well formed - also, no duplicates. --->
<loop list="#get.question_body#" index="i" delimiters="#CHR(10)#">
<var _i = trim(reReplace(i,"#GLOBAL.Def.answer_text_regex_negative#","","all"))>
<if _i NEQ "" AND listFindNoCase(_new_question_body,_i,CHR(10)) EQ 0>
<var _new_question_body = _new_question_body & CHR(10) & _i>
</if>
</loop>
<var _new_question_body = trim(_new_question_body)>
<var get.question_body = _new_question_body>
<if get.question_body EQ "">
<var _question_body_ok = 0>
</if>
</if>
</if>
<if _question_body_ok EQ 0>
<if get.answertype EQ "multiple_choice">
<div class="noverflow">
<div style="float:left; font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#; border-bottom:1px dashed #GLOBAL.Def.Style.color.g4#; padding-bottom:2px;">
<if listLen(_answertypes) GT 1>
<div>
Answer type: <b>#_answertypes_explain[get.answertype][1]#</b>
</div>
</if>
<div>
Question text: <b>#get.question_text#</b> (<a href="http://#this_domain#/New_Question?&answertype=#get.answertype#">back</a>)
</div>
</div>
<div style="clear:left;"> </div>
</div>
<div style="margin-left:2em;">
<h3>Define answer choices:</h3>
<form id="question_form" action="http://#this_domain#/New_Question" method="get" enctype="application/x-www-form-urlencoded" style="margin:0px;">
<input name="x" value="0" type="hidden" style="display:none;">
<input name="answertype" value="#get.answertype#" type="hidden" style="display:none;">
<input name="question_text" value="#escapeDoubleQuotes(escapeMarkup(get.question_text))#" type="hidden" style="display:none;">
<input name="duplicates_ok" value="#get.duplicates_ok#" type="hidden" style="display:none;">
<div>
<div style="margin-left:2em;" class="noverflow">
<div style="float:left; width:50%;">
<textarea id="question_body" name="question_body"
style="width:99%; height:8em; font-size:1em;"
autocomplete="off"></textarea>
<div style="padding-top:3px; font-size:0.72em; color:#GLOBAL.Def.Style.color.g2#;">
Answer choices cannot contain special characters.
<br>Be sure to separate each
answer choice by hitting the "enter" key.
</div>
</div>
<div style="margin-left:52%; opacity:0.4; filter:alpha(opacity=40);"
onmouseover="this.style.opacity=1;this.style.filter='alpha(opacity=100)';"
onmouseout="this.style.opacity=0.4;this.style.filter='alpha(opacity=40)';"
onmousedown="return false;"
class="noverflow">
<div style="float:left; width:4em;">Preview:</div>
<div style="margin-left:5em;">
<div id="preview" style="font-size:0.72em; border:1px solid #GLOBAL.Def.Style.Color.g3#; position:relative;">
<div id="preview_underlay" style="z-index:1; position:absolute; left:0px; top:0px; width:100%; height:100%; background:#GLOBAL.Def.Style.color.pri#; opacity:0.4; filter:alpha(opacity=40);"></div>
<div id="preview_overlay" style="z-index:2; position:relative; margin:1.2em; background:#GLOBAL.Def.Style.color.back#;">
<div id="preview_title" style="padding:5px;"><b>#get.question_text#</b></div>
<div id="preview_control" style="padding:5px; padding-bottom:9px; margin-left:1em;">
<select size="3" style="width:80%;">
<option disabled>(no choices)</option>
</select>
</div>
</div>
</div>
<div style="padding-top:3px; color:#GLOBAL.Def.Style.color.g3#; font-size:0.72em;">
This is what people will see when they answer
your question.
</div>
</div>
</div>
</div>
<div> </div>
<div>
<input class="wax" type="submit" value="Next Step >" style="cursor:pointer;">
</div>
</div>
</form>
<p style="font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#;">
Remember, <b>you can't change questions after you create them</b>.
</p>
</div>
<tag.jquery>
<script type="text/javascript">
$(document).ready(function() {
$('##question_form').submit(function() {
make_question_body_valid();
if ($('##question_body').val() == '') {
alert('You must add at least one answer choice.');
$('##question_body').focus();
return false;
}
return true;
});
$('##question_body').keyup(function(e) {
var _tst = make_question_body_valid();
if (e.keyCode == 13 || _tst == false) {
update_question_preview();
}
});
$('##question_body').bind('click focus blur', function() {
update_question_preview();
});
$('##question_body').focus();
});
function make_question_body_valid() {
var _txt = $('##question_body').val();
var _orig_txt = _txt;
// var _txt = _txt.replace(/[\.\/\n]+/g,'\n');
var _does_end_with_newline = 0;
if (_txt.substr(_txt.length-1,1) == '\n') {
var _does_end_with_newline = 1;
}
var _s = _txt.split('\n');
var _new_txt = '';
var i = 0;
while (i < _s.length) {
var _t = _s[i];
if (jQuery.trim(_t) == '') {
var _new_txt = _new_txt + '\n' + _t;
}
else if (_t.match(/#GLOBAL.Def.answer_text_regex#/)) {
var _new_txt = _new_txt + '\n' + _t;
}
else {
var _new_txt = _new_txt + '\n' + _t.replace(/#GLOBAL.Def.answer_text_regex_negative#/g,'');
}
i = i + 1;
}
var _new_txt = _new_txt.replace('\n','');
var _txt = _new_txt;
if (_does_end_with_newline == 1 && _txt.substr(_txt.length-1,1) !== '\n') {
var _txt = _txt + '\n';
}
if (_txt !== _orig_txt) {
$('##question_body').val(_txt);
return false;
}
return true;
}
function update_question_preview() {
var _txt = jQuery.trim($('##question_body').val());
if (_txt == '') {
$('##preview_control').html('<select size="3" style="width:80%;">\
<option disabled>(no choices)</option>\
</select>');
}
else {
var _s = _txt.split('\n');
var _new_html = '<select size="3" style="width:80%;">';
var i = 0;
while (i < _s.length) {
var _t = jQuery.trim(_s[i]);
if (_t !== '') {
var _new_html = _new_html + '<option>' + _t + '</option>';
}
i = i + 1;
}
var _new_html = _new_html + '</select>';
$('##preview_control').html(_new_html);
}
}
</script>
</if>
<BREAK>
</if>
<var _age_num_list = "1">
<if GLOBAL.Def.iqtpi_age_num GT 1>
<var _age_num_list = "1,2">
</if>
<if GLOBAL.Def.iqtpi_age_num GT 2>
<var _age_num_list = "1,2,3">
</if>
<if listLen(_age_num_list) EQ 1>
<var get.iqtpi_age_num_double = listFirst(_age_num_list)>
<else>
<ensure variable="get.iqtpi_age_num_double" value="0">
<if listFind(_age_num_list,get.iqtpi_age_num_double) EQ 0>
<div class="noverflow">
<div style="float:left; font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#; border-bottom:1px dashed #GLOBAL.Def.Style.color.g4#; padding-bottom:2px;">
<if listLen(_answertypes) GT 1>
<div>
Answer type: <b>#_answertypes_explain[get.answertype][1]#</b>
</div>
</if>
<div>
Question text: <b>#get.question_text#</b> <if get.answertype NEQ "multiple_choice"> (<a href="http://#this_domain#/New_Question?&answertype=#get.answertype#">back</a>)</if>
</div>
<if get.answertype EQ "multiple_choice">
<div>
Answer Choices:
<loop list="#get.question_body#" index="i" delimiters="#CHR(10)#">
|#i#|
</loop>
(<a href="http://#this_domain#/New_Question?&answertype=#get.answertype#&question_text=#URLEncodedFormat(get.question_text)#">back</a>)
</div>
</if>
</div>
<div style="clear:left;"> </div>
</div>
<div style="margin-left:2em;">
<h3>Suggest an Age Rating:</h3>
<form id="question_form" action="http://#this_domain#/New_Question" method="get" enctype="application/x-www-form-urlencoded" style="margin:0px;">
<input name="x" value="0" type="hidden" style="display:none;">
<input name="answertype" value="#get.answertype#" type="hidden" style="display:none;">
<input name="question_text" value="#escapeDoubleQuotes(escapeMarkup(get.question_text))#" type="hidden" style="display:none;">
<input name="duplicates_ok" value="#get.duplicates_ok#" type="hidden" style="display:none;">
<input name="question_body" value="#escapeDoubleQuotes(escapeMarkup(get.question_body))#" type="hidden" style="display:none;">
<div class="noverflow">
<div style="width:2em; float:left; margin-left:1em;">
<img src="http://#this_domain#/file:/icon-simplistica_user?&picwidth=64" border="0"
style="width:100%;">
</div>
<div style="margin-left:3.5em;">
<select id="iqtpi_age_num_double" name="iqtpi_age_num_double">
<if GLOBAL.Def.iqtpi_age_num GT 2>
<option value="3">Grown Ups and Way Grown Ups Only</option>
</if>
<if GLOBAL.Def.iqtpi_age_num GT 1>
<option value="2">Teens and older</option>
</if>
<option value="1">All Ages</option>
</select>
<div style="padding-top:3px; font-size:0.72em; color:#GLOBAL.Def.Style.color.g2#;">
Who should be able to view this question?
</div>
</div>
<div> </div>
<div>
<input class="wax" type="submit" value="Next Step >" style="cursor:pointer;">
</div>
</div>
</form>
<p style="font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#;">
Remember, <b>you can't change questions after you create them</b>.
</p>
</div>
<tag.jquery>
<script type="text/javascript">
$(document).ready(function() {
$('##iqtpi_age_num_double').focus();
});
</script>
<BREAK>
</if>
</if>
<ensure variable="get.istimely_unsignedint" value="-1">
<if get.istimely_unsignedint NEQ 0 AND get.istimely_unsignedint NEQ 1>
<div class="noverflow">
<div style="float:left; font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#; border-bottom:1px dashed #GLOBAL.Def.Style.color.g4#; padding-bottom:2px;">
<if listLen(_answertypes) GT 1>
<div>
Answer type: <b>#_answertypes_explain[get.answertype][1]#</b>
</div>
</if>
<div>
Question text: <b>#get.question_text#</b>
</div>
<if get.answertype EQ "multiple_choice">
<div>
Answer Choices:
<loop list="#get.question_body#" index="i" delimiters="#CHR(10)#">
|#i#|
</loop>
</div>
</if>
<div>
Age Rating:
<if get.iqtpi_age_num_double EQ 1>
<b>All Ages</b>
<elseif get.iqtpi_age_num_double EQ 2>
<b>Teens and older</b>
<else>
<b>Grown Ups and Way Grown Ups Only</b>
</if>
(<a href="http://#this_domain#/New_Question?&answertype=#get.answertype#&question_text=#URLEncodedFormat(get.question_text)#&question_body=#URLEncodedFormat(get.question_body)#">back</a>)
</div>
</div>
<div style="clear:left;"> </div>
</div>
<div id="is_this_timely" style="margin-left:2em;">
<h3><tag.fico i="clock" linkback="off" style="height:0.67em;"> Is This a Timely Question?</h3>
<form id="question_form" action="http://#this_domain#/New_Question" method="get" enctype="application/x-www-form-urlencoded" style="margin:0px;">
<input name="x" value="0" type="hidden" style="display:none;">
<input name="answertype" value="#get.answertype#" type="hidden" style="display:none;">
<input name="question_text" value="#escapeDoubleQuotes(escapeMarkup(get.question_text))#" type="hidden" style="display:none;">
<input name="duplicates_ok" value="#get.duplicates_ok#" type="hidden" style="display:none;">
<input name="question_body" value="#escapeDoubleQuotes(escapeMarkup(get.question_body))#" type="hidden" style="display:none;">
<input name="iqtpi_age_num_double" value="#get.iqtpi_age_num_double#" type="hidden" style="display:none;">
<p style="font-size:0.72em; width:380px;">
Is this the kind of question you want to answer every day? Every week? Timely questions
have a little "clock" <tag.fico i="clock" linkback="off" style="height:1em;"> icon. Some people love timely questions, but others think
they are obnoxious. Choose carefully!
</p>
<div style="margin-left:1em; width:360px;">
<div class="radio_container" style="padding:3px;">
<input value="0" class="radio" type="radio" name="istimely_unsignedint" checked> No (default)
</div>
<div class="radio_container" style="padding:3px;">
<input value="1" class="radio" type="radio" name="istimely_unsignedint"> Yes
</div>
</div>
<div> </div>
<div>
<input class="wax" type="submit" value="Next Step >" style="cursor:pointer;">
</div>
<p style="font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#;">
Remember, <b>you can't change questions after you create them</b>.
</p>
</div>
<tag.jquery>
<script type="text/javascript">
$(document).ready(function() {
activate_radio_containers();
});
</script>
<BREAK>
</if>
<ensure variable="get.yes_i_am_sure" value="0">
<if get.yes_i_am_sure EQ 1>
<!--- add the question, redirect. --->
<var _question_body = "">
<loop list="#get.question_body#" index="i" delimiters="#CHR(10)#">
<var _question_body = _question_body & CHR(10) & "|" & i & "|">
</loop>
<var _question_body = trim(_question_body)>
<var _iqtpi_agetype_list = "|grown_up|way_grown_up|">
<if get.iqtpi_age_num_double GT 0 AND get.iqtpi_age_num_double LT 3>
<var _iqtpi_agetype_list = _iqtpi_agetype_list & "teen|">
</if>
<if get.iqtpi_age_num_double GT 0 AND get.iqtpi_age_num_double LT 2>
<var _iqtpi_agetype_list = _iqtpi_agetype_list & "kid|">
</if>
<insert orb="question"
title="#get.question_text#"
name="|/answertype-#get.answertype#|"
body="#_question_body#"
user_key_id="1"
iqtpi_age_num_double="#get.iqtpi_age_num_double#"
iqtpi_agetype_list="#_iqtpi_agetype_list#"
istimely_unsignedint="#get.istimely_unsignedint#"
userid_unsignedint="#client_id#"
is_proxy="1">
<if return NEQ "pants">
<var _idnum = return>
<tag.qa_new_question_sneeze>
<if return NEQ "pants">
<goto url="http://#this_domain#/j:/question-#_idnum#">
</if>
</if>
<else>
<tag.unit_css>
<style type="text/css">
.unit_left { text-align:left; }
</style>
<!--- are you sure? --->
<h3>Create this question?</h3>
<div style="margin-left:2em; max-width:460px;">
<div style="font-size:0.86em;">
<div class="unit">
<div class="unit_left">
Answer Type:
</div>
<div class="unit_right">
<b>#_answertypes_explain[get.answertype][1]#</b>
<div style="padding:2px; font-size:0.86em; color:#GLOBAL.Def.Style.Color.g3#;">
(#_answertypes_explain[get.answertype][2]#)
</div>
</div>
</div>
<div class="unit">
<div class="unit_left">
Question Text:
</div>
<div class="unit_right">
<b>#get.question_text#</b>
</div>
</div>
<if get.answertype EQ "multiple_choice">
<div class="unit">
<div class="unit_left">
Answer Choices:
</div>
<div class="unit_right">
<ul style="margin-top:0px; margin-left:-1em;">
<loop list="#get.question_body#" index="i" delimiters="#CHR(10)#">
<li>#escapeMarkup(i)#</li>
</loop>
</ul>
</div>
</div>
</if>
<div class="unit">
<div class="unit_left">
Age Rating:
</div>
<div class="unit_right">
<if get.iqtpi_age_num_double EQ 1>
<b>All Ages</b>
<elseif get.iqtpi_age_num_double EQ 2>
<b>Teens and older</b>
<else>
<b>Grown Ups and Way Grown Ups Only</b>
</if>
</div>
</div>
<div class="unit">
<div class="unit_left">
Timely:
</div>
<div class="unit_right">
<if get.istimely_unsignedint EQ 1>
<tag.fico i="clock" linkback="off" style="height:0.88em;">
<b>Yes</b>
<else>
<b>No</b>
</if>
</div>
</div>
</div>
<div> </div>
<p>
<a class="wax wax_alert" href="http://#this_domain#/New_Question">No, create a different question</a>
|
<a class="wax" href="http://#this_domain#/New_Question?&answertype=#get.answertype#&question_text=#URLEncodedFormat(get.question_text)#&duplicates_ok=#get.duplicates_ok#&question_body=#URLEncodedFormat(get.question_body)#&iqtpi_age_num_double=#get.iqtpi_age_num_double#&istimely_unsignedint=#get.istimely_unsignedint#&yes_i_am_sure=1"><b>Yes, Create ></b></a>
</p>
<p style="font-size:0.72em; color:#GLOBAL.Def.Style.color.g3#;">
Remember, <b>you can't change questions after you create them</b>.
</p>
</div>
</if>
<!---
don't forget about duplicates_ok!!!
don't forget to wax!!!
--->