{**
* XS2:
*
* This file is developed by Solutecs, LLC for the purpose of the company
* and is provided together with XS2 Framework as and inherent part of the
* system. This file can be used on the terms of License Agreement.
*
* +7 (495) 585-0833 / 13 Rusakovskaya street, Moscow 107140 Russia
*
* @link http://www.solutecs.com
* @copyright ©1998-2007 Solutecs, LLC
* @version 1.XX
*}
<SCRIPT language="Javascript">
{literal}
function s_question(a,l) {
var f,j,i,el;
if (l==0) return;
f=a.form;
j = 0;
for(i=0; i<f.elements.length; i++) {
el = f.elements[i];
if((el.getAttribute('q') == a.getAttribute('q')) && (el.checked) && (el.id!=a.id)) {
j++;
t=el;
}
}
if ((j+1)>l) {
if (l==1){
t.checked = false;
if (t.getAttribute('t')=='answer_ext') {
document.getElementById("e"+t.id).disabled = "true";
}
}
else a.checked = false;
}
}
function s_question_ext(a,l) {
s_question(a,l);
var t = document.getElementById("e"+a.id);
t.disabled = !a.checked;
}
function sq_question(a,l) {
var f,j,i,el,t;
if (l==0) return;
f=a.form;
j = 0;
for(var i=0; i<f.elements.length; i++) {
el = f.elements[i];
if((el.getAttribute('q') == a.getAttribute('q')) && (el.checked) && (el.id!=a.id)) {
j++;
t = el;
}
}
if ((j+1)>l) {
if (l==1) {
t.checked = false;
}
else a.checked = false;
}
}
function r_question(a) {
var f,g,el,i,o,q;
f=a.form;
g = new Array();
el;
for(i=0; i<f.elements.length; i++) {
el = f.elements[i];
if(el.getAttribute('q') == a.getAttribute('q')) {
if ((el.id!=a.id) && (el.value==a.value) && el.value!=0) {
a.selectedIndex = 0;
return;
}
if (el.value>0) {
g[el.value] = true;
}
}
}
for(i=0; i<f.elements.length; i++) {
el = f.elements[i];
if(el.getAttribute('q') == a.getAttribute('q')) {
o = el.options;
for (q=0; q<o.length; q++) {
if (o[q].getAttribute('value')!=el.value && g[o[q].getAttribute('value')]) {
o[q].style.color = "#c6c6c6";
}
else {
o[q].style.color = "";
}
}
}
}
}
{/literal}
</SCRIPT>
{* Вывод опроса *}
{if $_THE.PARAMS[0]}
{xs2GetNode NodId=$_THE.PARAMS[0] var="poll"}
{else}
{xs2GetNodes NType="poll" var="polls"}
{assign var="poll" value=$polls[0]}
{/if}
{xs2GetChildren ParId=$poll.NodId var="questions"}
<H1>{$poll.NName}</H1>
<FORM action="{xs2Href mod="polls" obj="poll" met="submit"}" method="POST">
<INPUT type="hidden" name="poll" value="{$poll.NodId}">
{assign var="qCount" value=1}
{foreach name="pl" from=$questions item="question"}
{if $question.NType!="results"}
{xs2GetChildren ParId=$question.NodId var="answers" NType="answer_var,answer_ext"}
{xs2GetChildren ParId=$question.NodId var="subquestions" NType="subquestion"}
<DIV><STRONG>{$qCount}. {$question.NName}</STRONG></DIV>
{if $question.NType=="s_question"}
{* Если это вопрос типа "Вопрос с выбором" *}
{if $subquestions}
{* Если вопрос состоит из нескольких подвопросов *}
<TABLE border="1">
<TR>
<TH></TH>
{foreach from=$answers item="answer"}
<TH>{$answer.NName}</TH>
{/foreach}
</TR>
{foreach from=$subquestions item="subquestion"}
<TR>
<TD>{$subquestion.NName}</TD>
{foreach name="al" from=$answers item="answer"}
<TD>
{if $answer.NType=="answer_var"}
<DIV>
<INPUT type="checkbox"
name="q[{$question.NodId}][{$subquestion.NodId}][{$answer.NodId}]"
t="{$answer.NType}"
q="{$subquestion.NodId}"
id="{$subquestion.NodId}_{$answer.NodId}"
value="1"
onClick="s_question(this,{$question.AnswersLimit})"/>
</DIV>
{elseif $answer.NType=="answer_ext"}
<DIV>
<DIV>
<INPUT type="checkbox"
name="q[{$question.NodId}][{$subquestion.NodId}][{$answer.NodId}]"
t="{$answer.NType}"
q="{$subquestion.NodId}"
id="{$subquestion.NodId}_{$answer.NodId}"
value="1"
onClick="s_question_ext(this,{$question.AnswersLimit})">
{$answer.NName}
</DIV>
<DIV>{$answer.Alt}:</DIV>
<DIV>
<TEXTAREA name="exts[{$subquestion.NodId}][{$answer.NodId}]"
id="e{$subquestion.NodId}_{$answer.NodId}"
disabled="true"></TEXTAREA>
</DIV>
</DIV>
{/if}
</TD>
{/foreach}
</TR>
{/foreach}
</TABLE>
{else}
{* Если в вопросе нет подвопросов *}
<DIV style="margin-left:20px;">
{foreach name="al" from=$answers item="answer"}
{if $answer.NType=="answer_var"}
<DIV>
<INPUT type="checkbox"
name="q[{$question.NodId}][0][{$answer.NodId}]"
t="{$answer.NType}"
q="{$question.NodId}"
id="{$answer.NodId}"
value="1"
onClick="s_question(this,{$question.AnswersLimit})">
{$answer.NName}
</DIV>
{elseif $answer.NType=="answer_ext"}
<DIV>
<DIV>
<INPUT type="checkbox"
name="q[{$question.NodId}][0][{$answer.NodId}]"
t="{$answer.NType}"
q="{$question.NodId}"
id="{$answer.NodId}"
value="1"
onClick="s_question_ext(this,{$question.AnswersLimit})">
{$answer.NName}
</DIV>
<DIV>{$answer.Alt}:</DIV>
<DIV>
<TEXTAREA name="exts[{$question.NodId}][{$answer.NodId}]"
id="e{$answer.NodId}"
disabled="true"></TEXTAREA>
</DIV>
</DIV>
{/if}
{/foreach}
</DIV>
{/if}
{elseif $question.NType=="sv_question"}
{* Если это вопрос типа "Вопрос с оценкой по шкалам *}
{if $subquestions}
{* Если вопрос состоит из нескольких подвопросов *}
<TABLE border="1">
<TR>
<TH></TH>
{foreach from=$answers item="answer"}
<TH>{$answer.NName}</TH>
{/foreach}
</TR>
{foreach from=$subquestions item="subquestion"}
<TR>
<TD>{$subquestion.NName}</TD>
{foreach name="al" from=$answers item="answer"}
<TD>
{section loop=$question.Scale name="svs"}
<INPUT type="radio"
name="q[{$question.NodId}][{$subquestion.NodId}][{$answer.NodId}]"
value="{$smarty.section.svs.iteration}">{$smarty.section.svs.iteration}
{/section}
</TD>
{/foreach}
</TR>
{/foreach}
</TABLE>
{else}
{* Если в вопросе нет подвопросов *}
<TABLE style="margin-left:20px;">
{foreach name="al" from=$answers item="answer"}
<TR>
<TD>{$answer.NName}</TD>
<TD>
{section loop=$question.Scale name="svs"}
<INPUT type="radio"
name="q[{$question.NodId}][0][{$answer.NodId}]"
value="{$smarty.section.svs.iteration}">{$smarty.section.svs.iteration}
{/section}
</TD>
</TR>
{/foreach}
</TABLE>
{/if}
{elseif $question.NType=="r_question"}
{* Если это вопрос типа "Вопрос с ранжированием *}
<DIV style="margin-left:20px;">
{foreach name="al" from=$answers item="answer"}
<DIV>
<SELECT onchange="r_question(this)"
name="q[{$question.NodId}][0][{$answer.NodId}]"
q="{$question.NodId}"
id="{$answer.NodId}">
<OPTION value="0"></OPTION>
{section loop=$answers|@count name="rs"}
<OPTION value="{$smarty.section.rs.iteration}">{$smarty.section.rs.iteration}</OPTION>
{/section}
</SELECT>
{$answer.NName}
</DIV>
{/foreach}
</DIV>
{elseif $question.NType=="t_question"}
{* Если это вопрос типа "Вопрос текстовый" *}
<DIV style="margin-left:20px;">
<TEXTAREA name="q[{$question.NodId}][0]"></TEXTAREA>
</DIV>
{/if}
{assign var="qCount" value=$qCount+1}
{/if}
{/foreach}
<DIV style="margin-left:20px;margin-top:20px">
<INPUT type="submit" value="Отправить">
</DIV>
</FORM>
{* /Вывод опроса *}
|