Skip to content

Commit

Permalink
dev Removed most code for the obsolete W & Z question types
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev_cs@8287 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jan 21, 2010
1 parent ce779c9 commit 9da74e9
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 833 deletions.
29 changes: 4 additions & 25 deletions admin/activate.php
Expand Up @@ -90,7 +90,7 @@
// # ";" -> Array Multi Flexi Text
// # "1" -> MULTI SCALE

$chkquery = "SELECT qid, question, gid, type FROM {$dbprefix}questions WHERE sid={$surveyid}";
$chkquery = "SELECT qid, question, gid, type FROM {$dbprefix}questions WHERE sid={$surveyid} and parent_qid=0";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't get list of questions<br />$chkquery<br />".$connect->ErrorMsg());
while ($chkrow = $chkresult->FetchRow())
{
Expand All @@ -116,7 +116,7 @@
}
}

//NOW CHECK THAT ALL QUESTIONS HAVE A 'QUESTION TYPE' FIELD
//NOW CHECK THAT ALL QUESTIONS HAVE A 'QUESTION TYPE' FIELD SET
$chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type = ''";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing types<br />$chkquery<br />".$connect->ErrorMsg());
while ($chkrow = $chkresult->FetchRow())
Expand All @@ -127,40 +127,21 @@



//CHECK THAT FLEXIBLE LABEL TYPE QUESTIONS HAVE AN "LID" SET
//ChECK THAT certain array question types have answers set
$chkquery = "SELECT q.qid, question, gid FROM {$dbprefix}questions as q WHERE (select count(*) from {$dbprefix}answers as a where a.qid=q.qid and scale_id=1)=0 and sid={$_GET['sid']} AND type IN ('F', 'H', 'W', 'Z', ':', '1')";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing sub-questions<br />$chkquery<br />".$connect->ErrorMsg());
while($chkrow = $chkresult->FetchRow()){
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question requires sub-questions, but none are set."), $chkrow['gid']);
} // while

//CHECK THAT FLEXIBLE LABEL TYPE QUESTIONS HAVE AN "LID1" SET FOR MULTI SCALE
//CHECK THAT FLEXIBLE LABEL TYPE QUESTIONS has answers set
$chkquery = "SELECT q.qid, question, gid FROM {$dbprefix}questions as q WHERE (select count(*) from {$dbprefix}answers as a where a.qid=q.qid and scale_id=2)=0 and sid={$_GET['sid']} AND type='1'";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing LIDs<br />$chkquery<br />".$connect->ErrorMsg());
while($chkrow = $chkresult->FetchRow()){
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("This question requires a second Labelset, but none is set."), $chkrow['gid']);
} // while


//NOW check that all used labelsets have all necessary languages
$chkquery = "SELECT qid, question, gid, lid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type IN ('F', 'H', 'W', 'Z', ':', '1') AND (lid > 0) AND (lid is not null)";
$chkresult = db_execute_assoc($chkquery) or safe_die ("Couldn't check questions for missing LID languages<br />$chkquery<br />".$connect->ErrorMsg());
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($slangs,$baselang);
while ($chkrow = $chkresult->FetchRow())
{
foreach ($slangs as $surveylanguage)
{
$chkquery2 = "SELECT lid FROM {$dbprefix}labels WHERE language='$surveylanguage' AND (lid = {$chkrow['lid']}) ";
$chkresult2 = db_execute_assoc($chkquery2);
if ($chkresult2->RecordCount()==0)
{
$failedcheck[]=array($chkrow['qid'], $chkrow['question'], ": ".$clang->gT("The labelset used in this question does not exists or is missing a translation."), $chkrow['gid']);
}
} //foreach
} //while

//CHECK THAT ALL CONDITIONS SET ARE FOR QUESTIONS THAT PRECEED THE QUESTION CONDITION
//A: Make an array of all the qids in order of appearance
// $qorderquery="SELECT * FROM {$dbprefix}questions, {$dbprefix}groups WHERE {$dbprefix}questions.gid={$dbprefix}groups.gid AND {$dbprefix}questions.sid={$_GET['sid']} ORDER BY {$dbprefix}groups.sortorder, {$dbprefix}questions.title";
Expand Down Expand Up @@ -352,8 +333,6 @@
break;
case "L": //LIST (RADIO)
case "!": //LIST (DROPDOWN)
case "W":
case "Z":
$createsurvey .= " C(5)";
if ($arow['other'] == "Y")
{
Expand Down
4 changes: 2 additions & 2 deletions admin/browse.php
Expand Up @@ -194,7 +194,7 @@
$fnames[] = array("$field{$fnrrow['code']}", "$ftitle ({$fnrrow['code']})", "{$fnrow['question']} ({$fnrrow['answer']})");
if ($fnrow['type'] == "P") {$fnames[] = array("$field{$fnrrow['code']}"."comment", "$ftitle"."comment", "{$fnrow['question']} (".$clang->gT("Comment").")");}
}
if ($fnrow['other'] == "Y" and ($fnrow['type']=="!" or $fnrow['type']=="L" or $fnrow['type']=="M" or $fnrow['type']=="P" || $fnrow['type'] == "Z" || $fnrow['type'] == "W"))
if ($fnrow['other'] == "Y" and ($fnrow['type']=="!" or $fnrow['type']=="L" or $fnrow['type']=="M" or $fnrow['type']=="P" ))
{
$fnames[] = array("$field"."other", "$ftitle"."other", "{$fnrow['question']}(".$clang->gT("Other").")");
if ($fnrow['type'] == "P") {$fnames[] = array("$field{$fnrrow['code']}"."othercomment", "$ftitle"."othercomment", "{$fnrow['question']} (".$clang->gT("Other Comment").")");}
Expand Down Expand Up @@ -280,7 +280,7 @@
else
{
$fnames[] = array("$field", "$ftitle", "{$fnrow['question']}");
if (($fnrow['type'] == "L" || $fnrow['type'] == "!" || $fnrow['type'] == "W" || $fnrow['type'] == "Z") && $fnrow['other'] == "Y")
if (($fnrow['type'] == "L" || $fnrow['type'] == "!") && $fnrow['other'] == "Y")
{
$fnames[] = array("$field"."other", "$ftitle"."other", "{$fnrow['question']}(".$clang->gT("Other").")");
}
Expand Down
25 changes: 0 additions & 25 deletions admin/conditionshandling.php
Expand Up @@ -882,31 +882,6 @@
$canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], " ", $clang->gT("No answer"));
}
break;
case "W": // List Flexibel Label Dropdown
case "Z": // List Flexible Radio Button
$fquery = "SELECT * FROM {$dbprefix}labels\n"
. "WHERE lid={$rows['lid']} AND language='".GetBaseLanguageFromSurveyID($surveyid)."' "
. "ORDER BY sortorder, code";

$fresult = db_execute_assoc($fquery);

if (!isset($arows['code'])) {$arows['code']='';} // for some questions types there is no code
while ($frow=$fresult->FetchRow())
{
$canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['code'], $frow['code'], $frow['title']);
}
// For dropdown questions
// optinnaly add the 'Other' answer
if ($rows['other'] == "Y")
{
$canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], "-oth-", $clang->gT("Other"));
}
// Only Show No-Answer if question is not mandatory
if ($rows['mandatory'] != 'Y')
{
$canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], " ", $clang->gT("No answer"));
}
break;

case "N": // Simple Numerical questions

Expand Down
6 changes: 3 additions & 3 deletions admin/database.php
Expand Up @@ -429,15 +429,15 @@ function get_max_question_order($gid)
$keepsubquestions = ($qtypes[$_POST['type']]['subquestions']>0);

// These are the questions types that have the other option therefore we set everything else to 'No Other'
if (($_POST['type']!= "L") && ($_POST['type']!= "!") && ($_POST['type']!= "P") && ($_POST['type']!="M") && ($_POST['type'] != "W") && ($_POST['type'] != "Z"))
if (($_POST['type']!= "L") && ($_POST['type']!= "!") && ($_POST['type']!= "P") && ($_POST['type']!="M"))
{
$_POST['other']='N';
}

// These are the questions types that have no validation - so zap it accordingly

if ($_POST['type']== "!" || $_POST['type']== "L" || $_POST['type']== "M" || $_POST['type']== "P" || $_POST['type']== "W" ||
$_POST['type']== "Z" || $_POST['type']== "F" || $_POST['type']== "H" || $_POST['type']== ":" || $_POST['type']== ";" ||
if ($_POST['type']== "!" || $_POST['type']== "L" || $_POST['type']== "M" || $_POST['type']== "P" ||
$_POST['type']== "F" || $_POST['type']== "H" || $_POST['type']== ":" || $_POST['type']== ";" ||
$_POST['type']== "X" || $_POST['type']== "")
{
$_POST['preg']='';
Expand Down
78 changes: 5 additions & 73 deletions admin/dataentry.php
Expand Up @@ -262,9 +262,8 @@
$insertqr .= "'" . auto_escape($_POST[$fieldname]) . "', \n";
}
}
// if "!" "L" "W" "Z", and Other ==> add other fieldname
if ($irow['type'] == "!" || $irow['type'] == "L" ||
$irow['type'] == "W" || $irow['type'] == "Z")
// if "!" "L" and Other ==> add other fieldname
if ($irow['type'] == "!" || $irow['type'] == "L")
{
$fieldname2=$fieldname."other";
if (isset($_POST[$fieldname2]) && isset($_POST[$fieldname]) && $_POST[$fieldname] == '-oth-' && $_POST[$fieldname2]!= "")
Expand Down Expand Up @@ -361,7 +360,7 @@
while ($i2row = $i2result->FetchRow())
{
$otherexists = "";
if ($i2row['other'] == "Y" and ($irow['type']=="!" or $irow['type']=="L" or $irow['type']=="M" or $irow['type']=="P" or $irow['type'] == "W" or $irow['type'] == "Z")) {$otherexists = "Y";}
if ($i2row['other'] == "Y" and ($irow['type']=="!" or $irow['type']=="L" or $irow['type']=="M" or $irow['type']=="P")) {$otherexists = "Y";}
$fieldname = "{$irow['sid']}X{$irow['gid']}X{$irow['qid']}{$i2row['code']}";
if (isset($_POST[$fieldname]))
{
Expand Down Expand Up @@ -723,7 +722,7 @@
{
if (!isset($fnrrow)) {$fnrrow=array("code"=>"", "answer"=>"");}
$fnames[] = array("$field", "$ftitle", "{$fnrow['question']}", "{$fnrow['type']}", "$field", "{$fnrrow['code']}", "{$fnrrow['answer']}", "{$fnrow['qid']}", "{$fnrow['lid']}");
if (($fnrow['type'] == "L" || $fnrow['type'] == "!" || $fnrow['type'] == "Z" || $fnrow['type'] == "W") && $fnrow['other'] =="Y")
if (($fnrow['type'] == "L" || $fnrow['type'] == "!") && $fnrow['other'] =="Y")
{
$fnames[] = array("$field"."other", "$ftitle"."other", "{$fnrow['question']}(other)", "{$fnrow['type']}", "$field", "{$fnrrow['code']}", "{$fnrrow['answer']}", "{$fnrow['qid']}", "{$fnrow['lid']}");
}
Expand Down Expand Up @@ -884,44 +883,6 @@
$dataentryoutput .= ">".$clang->gT("Male")."</option>\n"
."\t</select>\n";
break;
case "W":
case "Z":
if (substr($fnames[$i][0], -5) == "other")
{
$dataentryoutput .= "\t<input type='text' name='{$fnames[$i][0]}' value='"
.htmlspecialchars($idrow[$fnames[$i][0]], ENT_QUOTES) . "' />\n";
}
else
{
$lquery = "SELECT * FROM ".db_table_name("labels")
." WHERE lid={$fnames[$i][8]} AND ".db_table_name("labels").".language = '{$language}' ORDER BY sortorder, code";
$lresult = db_execute_assoc($lquery);
$dataentryoutput .= "\t<select name='{$fnames[$i][0]}'>\n"
."<option value=''";
if ($idrow[$fnames[$i][0]] == "") {$dataentryoutput .= " selected='selected'";}
$dataentryoutput .= ">".$clang->gT("Please choose")."..</option>\n";

while ($llrow = $lresult->FetchRow())
{
$dataentryoutput .= "<option value='{$llrow['code']}'";
if ($idrow[$fnames[$i][0]] == $llrow['code']) {$dataentryoutput .= " selected='selected'";}
$dataentryoutput .= ">{$llrow['title']}</option>\n";
}
$oquery="SELECT other FROM ".db_table_name("questions")." WHERE qid={$fnames[$i][7]} AND ".db_table_name("questions").".language = '{$language}'";
$oresult=db_execute_assoc($oquery) or safe_die("Couldn't get other for list question<br />".$oquery."<br />".$connect->ErrorMsg());
while($orow = $oresult->FetchRow())
{
$fother=$orow['other'];
}
if ($fother =="Y")
{
$dataentryoutput .= "<option value='-oth-'";
if ($idrow[$fnames[$i][0]] == "-oth-"){$dataentryoutput .= " selected='selected'";}
$dataentryoutput .= ">".$clang->gT("Other")."</option>\n";
}
$dataentryoutput .= "\t</select>\n";
}
break;
case "L": //LIST drop-down
case "!": //List (Radio)
$qidattributes=getQuestionAttributes($fnames[$i][7]);
Expand Down Expand Up @@ -1678,7 +1639,7 @@ function saveshow(value)
}
unset($thisvalue);
// handle ! other
if (($irow['type'] == "!" || $irow['type'] == "W" || $irow['type'] == "Z" || $irow['type'] == "L") && $irow['other'] == "Y")
if (($irow['type'] == "!" || $irow['type'] == "L") && $irow['other'] == "Y")
{
$fieldname = "{$irow['sid']}X{$irow['gid']}X{$irow['qid']}other";
if (isset($_POST[$fieldname])) {$thisvalue=$_POST[$fieldname];} else {$thisvalue="";}
Expand Down Expand Up @@ -2170,36 +2131,7 @@ function saveshow(value)
}
$dataentryoutput .= "\t</table>\n";
break;
case "W": //Flexible List drop-down/radio-button
case "Z":
$deaquery = "SELECT * FROM ".db_table_name("labels")." WHERE lid={$deqrow['lid']} AND language='{$language}' ORDER BY sortorder, code";
$dearesult = db_execute_assoc($deaquery);
$dataentryoutput .= "\t<select name='$fieldname'>\n";
$dataentryoutput .= "<option selected='selected' value=''>".$blang->gT("Please choose")."..</option>\n";
while ($dearow = $dearesult->FetchRow())
{
$dataentryoutput .= "<option value='{$dearow['code']}'";
$dataentryoutput .= ">{$dearow['title']}</option>\n";
}

$oquery="SELECT other FROM ".db_table_name("questions")." WHERE qid={$deqrow['qid']} AND language='{$language}'";
$oresult=db_execute_assoc($oquery) or safe_die("Couldn't get other for list question<br />".$oquery."<br />".$connect->ErrorMsg());
while($orow = $oresult->FetchRow())
{
$fother=$orow['other'];
}
if ($fother == "Y")
{
$dataentryoutput .= "<option value='-oth-'>".$blang->gT("Other")."</option>\n";
}
$dataentryoutput .= "\t</select>\n";
if ($fother == "Y")
{
$dataentryoutput .= "\t"
.$blang->gT("Other").":"
."<input type='text' name='{$fieldname}other' value='' />\n";
}
break;
case "1": // multi scale^
$deaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$baselang}' ORDER BY sortorder, answer";
$dearesult = db_execute_assoc($deaquery);
Expand Down
8 changes: 0 additions & 8 deletions admin/export_structure_quexml.php
Expand Up @@ -362,18 +362,10 @@ function create_subQuestions(&$question,$qid,$varname)
$response->append_child(create_free("date","8",""));
$question->append_child($response);
break;
case "Z": //LIST Flexible drop-down/radio-button list
$response->append_child(create_fixed($lid));
$question->append_child($response);
break;
case "L": //LIST drop-down/radio-button list
$response->append_child(create_fixed($qid,false,false));
$question->append_child($response);
break;
case "W": //List - dropdown
$response->append_child(create_fixed($lid));
$question->append_child($response);
break;
case "!": //List - dropdown
$response->append_child(create_fixed($qid,false,false));
$question->append_child($response);
Expand Down
30 changes: 1 addition & 29 deletions admin/exportresults.php
Expand Up @@ -134,7 +134,7 @@
{
$excesscols[]=$surveyid.'X'.$rows['gid']."X".$rows['qid'];
}
if ($rows['other']=="Y" && ($rows['type']=='M' || $rows['type']=='!'|| $rows['type']=='L' || $rows['type']=='P' || $rows['type'] == "Z" || $rows['type'] == "W"))
if ($rows['other']=="Y" && ($rows['type']=='M' || $rows['type']=='!'|| $rows['type']=='L' || $rows['type']=='P'))
{
$excesscols[]=$surveyid.'X'.$rows['gid']."X".$rows['qid']."other";
}
Expand Down Expand Up @@ -646,8 +646,6 @@
break;
case "L":
case "!":
case "W":
case "Z":
if ($faid == "other") {
$fquest .= " [".$elang->gT("Other")."]";
}
Expand Down Expand Up @@ -1151,32 +1149,6 @@
}
}
break;
case "W":
case "Z":
if (mb_substr($fieldinfo, -5, 5) == "other")
{
$exportoutput .= strip_tags_full($drow[$i]);
if($type == "pdf"){$pdf->intopdf($drow[$i]);}
}
else
{
if ($drow[$i] == "-oth-")
{
$exportoutput .= $elang->gT("Other");
if($type == "pdf"){$pdf->intopdf($elang->gT("Other"));}
}
else
{
$fquery = "SELECT * FROM {$dbprefix}labels WHERE lid=$flid AND language='$explang' AND code='$drow[$i]'";
$fresult = db_execute_assoc($fquery) or safe_die("ERROR:".$fquery."<br />".$qq."<br />".$connect->ErrorMsg());
while ($frow = $fresult->FetchRow())
{
$exportoutput .= strip_tags_full($frow['title']);
if($type == "pdf"){$pdf->intopdf($frow['title']);}
}
}
}
break;
case "O": //DROPDOWN LIST WITH COMMENT
$lq = "SELECT * FROM {$dbprefix}answers WHERE qid=$fqid AND language='$explang' ORDER BY answer";
$lr = db_execute_assoc($lq) or safe_die ("Could do it<br />$lq<br />".$connect->ErrorMsg());
Expand Down
2 changes: 1 addition & 1 deletion admin/importgroup.php
Expand Up @@ -489,7 +489,7 @@
unset($questionrowdata['qid']);

// replace the lid for the new one (if there is no new lid in the $newlids array it mean that was not imported -> error, skip this record)
if (in_array($questionrowdata["type"], array("F","H","W","Z", "1", ":", ";"))) // only fot the questions that uses a label set.
if (in_array($questionrowdata["type"], array("F", "H", "W", "Z", "1", ":", ";"))) // only fot the questions that uses a label set.
if (isset($newlids[$questionrowdata["lid"]]))
{
$questionrowdata["lid"] = $newlids[$questionrowdata["lid"]];
Expand Down
4 changes: 1 addition & 3 deletions admin/importquestion.php
Expand Up @@ -411,9 +411,7 @@

// Now we will fix up the label id
$type = $questionrowdata["type"]; //Get the type
if ($type == "F" || $type == "H" || $type == "W" ||
$type == "Z" || $type == "1" || $type == ":" ||
$type == ";" )
if ($type == "F" || $type == "H" || $type == "1" || $type == ":" || $type == ";" )
{//IF this is a flexible label array, update the lid entry
if (isset($labelreplacements)) {
foreach ($labelreplacements as $lrp) {
Expand Down
16 changes: 13 additions & 3 deletions admin/importsurvey.php
Expand Up @@ -854,7 +854,7 @@
else
if ($currentqid==$questionrowdata['qid']) {$newquestion=false;}

if (!array_key_exists($questionrowdata["type"], $qtypes))
if (!array_key_exists($questionrowdata["type"], $qtypes) && $questionrowdata["type"]!='W' && $questionrowdata["type"]!='Z')
{
$questionrowdata["type"] = strtoupper($questionrowdata["type"]);
if (!array_key_exists($questionrowdata["type"], $qtypes))
Expand Down Expand Up @@ -896,8 +896,18 @@
{
$oldlid2=$questionrowdata['lid1'];
}
unset($questionrowdata['lid']);
unset($questionrowdata['lid1']);
// unset($questionrowdata['lid']);
// unset($questionrowdata['lid1']);
if ($questionrowdata['type']=='W')
{
$questionrowdata['type']='!';
}
elseif ($questionrowdata['type']=='Z')
{
$questionrowdata['type']='L';

}

}

if (!isset($questionrowdata["question_order"]) || $questionrowdata["question_order"]=='') {$questionrowdata["question_order"]=0;}
Expand Down

0 comments on commit 9da74e9

Please sign in to comment.