Skip to content

Commit

Permalink
Added handling for question types "W" and "Z"
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@1260 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Nov 16, 2004
1 parent 8b26c0f commit 997a660
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion admin/dumpgroup.php
Expand Up @@ -126,7 +126,7 @@ function BuildOutput($Query)
$cdump = BuildOutput($cquery);

//4: Labelsets Table
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.lid, label_name FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type='F' AND gid=$gid";
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.lid, label_name FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type in ('F', 'H', 'W', 'Z') AND gid=$gid";
$lsdump = BuildOutput($lsquery);

//5: Labels Table
Expand Down
2 changes: 1 addition & 1 deletion admin/dumpquestion.php
Expand Up @@ -111,7 +111,7 @@ function BuildOutput($Query)
$lsdump = BuildOutput($lsquery);

//4: Labels Table
$lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type='F' AND qid=$qid";
$lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type in ('F', 'H', 'Z', 'W') AND qid=$qid";
$ldump = BuildOutput($lquery);

//5: Question Attributes
Expand Down
2 changes: 1 addition & 1 deletion admin/dumpsurvey.php
Expand Up @@ -131,7 +131,7 @@ function BuildOutput($Query)
$lsdump = BuildOutput($lsquery);

//7: Labels
$lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type='F' AND sid=$sid";
$lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type in ('F', 'W', 'H', 'Z') AND sid=$sid";
$ldump = BuildOutput($lquery);

//8: Question Attributes
Expand Down
54 changes: 54 additions & 0 deletions admin/printablesurvey.php
Expand Up @@ -178,6 +178,8 @@
}
case "F":
case "H":
case "W":
case "L":
$value=substr($conrow['cfieldname'], strpos($conrow['cfieldname'], "X".$conrow['cqid'])+strlen("X".$conrow['cqid']), strlen($conrow['cfieldname']));
$fquery = "SELECT * FROM {$dbprefix}labels\n"
. "WHERE lid='{$conrow['lid']}'\n"
Expand Down Expand Up @@ -276,6 +278,58 @@
echo "\t\t\t<input type='checkbox' name='$fieldname' value='F' readonly='readonly' />"._FEMALE."<br />\n";
echo "\t\t\t<input type='checkbox' name='$fieldname' value='M' readonly='readonly' />"._MALE."<br />\n";
break;
case "W": //Flexible List
case "Z":
$qidattributes=getQuestionAttributes($deqrow['qid']);
if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1))
{
$dcols=$displaycols['value'];
}
else
{
$dcols=0;
}
echo "\t\t\t$setfont<u>"._PS_CHOOSEONE."</u><br />\n";
$deaquery = "SELECT * FROM {$dbprefix}labels WHERE lid={$deqrow['lid']} ORDER BY sortorder, title";
$dearesult = mysql_query($deaquery) or die("ERROR: $deaquery<br />\n".mysql_error());
$deacount=mysql_num_rows($dearesult);
if ($deqrow['other'] == "Y") {$deacount++;}
if ($dcols > 0 && $deacount > $dcols)
{
$width=sprintf("%0d", 100/$dcols);
$maxrows=ceil(100*($meacount/$dcols)/100); //Always rounds up to nearest whole number
$divider=" </td>\n <td valign='top' width='$width%' nowrap>";
$upto=0;
echo "<table class='question'><tr>\n <td valign='top' width='$width%' nowrap>";
while ($dearow = mysql_fetch_array($dearesult))
{
if ($upto == $maxrows)
{
echo $divider;
$upto=0;
}
echo "\t\t\t<input type='checkbox' name='$fieldname' value='{$dearow['code']}' readonly='readonly' />{$dearow['title']}<br />\n";
$upto++;
}
if ($deqrow['other'] == "Y")
{
echo "\t\t\t<input type='checkbox' readonly='readonly' />"._OTHER." <input type='text' size='30' readonly='readonly' /><br />\n";
}
echo "</td></tr></table>\n";
//Let's break the presentation into columns.
}
else
{
while ($dearow = mysql_fetch_array($dearesult))
{
echo "\t\t\t<input type='checkbox' name='$fieldname' value='{$dearow['code']}' readonly='readonly' />{$dearow['title']}<br />\n";
}
if ($deqrow['other'] == "Y")
{
echo "\t\t\t<input type='checkbox' readonly='readonly' />"._OTHER." <input type='text' size='30' readonly='readonly' /><br />\n";
}
}
break;
case "L": //LIST
case "!":
$qidattributes=getQuestionAttributes($deqrow['qid']);
Expand Down

0 comments on commit 997a660

Please sign in to comment.