Skip to content

Commit

Permalink
New Feature Re-order and/or Delete Questions/Groups Even if there are…
Browse files Browse the repository at this point in the history
… Conditions Attached to them

Dev EM makes conditions obsolete. Can now safely re-order questions and groups.   The Syntax Highlighting and Logic File will let users detect and fix possible errors.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev_tms@11646 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Dec 13, 2011
1 parent 42694dd commit aa2b7f6
Show file tree
Hide file tree
Showing 5 changed files with 539 additions and 545 deletions.
70 changes: 35 additions & 35 deletions admin/database.php
Expand Up @@ -522,10 +522,10 @@ function get_max_question_order($gid)
if (isset($postgid) && $postgid != "")
{

$array_result=checkMovequestionConstraintsForConditions(sanitize_int($postsid),sanitize_int($postqid), sanitize_int($postgid));
// $array_result=checkMovequestionConstraintsForConditions(sanitize_int($postsid),sanitize_int($postqid), sanitize_int($postgid));
// If there is no blocking conditions that could prevent this move
if (is_null($array_result['notAbove']) && is_null($array_result['notBelow']))
{
// if (is_null($array_result['notAbove']) && is_null($array_result['notBelow']))
// {

$questlangs = GetAdditionalLanguagesFromSurveyID($postsid);
$baselang = GetBaseLanguageFromSurveyID($postsid);
Expand Down Expand Up @@ -618,38 +618,38 @@ function get_max_question_order($gid)
$_SESSION['flashmessage'] = $clang->gT("Question was successfully saved.");


}
else
{
// There are conditions constraints: alert the user
$errormsg="";
if (!is_null($array_result['notAbove']))
{
$errormsg.=$clang->gT("This question relies on other question's answers and can't be moved above groupId:","js")
. " " . $array_result['notAbove'][0][0] . " " . $clang->gT("in position","js")." ".$array_result['notAbove'][0][1]."\\n"
. $clang->gT("See conditions:")."\\n";

foreach ($array_result['notAbove'] as $notAboveCond)
{
$errormsg.="- cid:". $notAboveCond[3]."\\n";
}

}
if (!is_null($array_result['notBelow']))
{
$errormsg.=$clang->gT("Some questions rely on this question's answers. You can't move this question below groupId:","js")
. " " . $array_result['notBelow'][0][0] . " " . $clang->gT("in position","js")." ".$array_result['notBelow'][0][1]."\\n"
. $clang->gT("See conditions:")."\\n";

foreach ($array_result['notBelow'] as $notBelowCond)
{
$errormsg.="- cid:". $notBelowCond[3]."\\n";
}
}

$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"$errormsg\")\n //-->\n</script>\n";
$gid= $oldgid; // group move impossible ==> keep display on oldgid
}
// }
// else
// {
// // There are conditions constraints: alert the user
// $errormsg="";
// if (!is_null($array_result['notAbove']))
// {
// $errormsg.=$clang->gT("This question relies on other question's answers and can't be moved above groupId:","js")
// . " " . $array_result['notAbove'][0][0] . " " . $clang->gT("in position","js")." ".$array_result['notAbove'][0][1]."\\n"
// . $clang->gT("See conditions:")."\\n";
//
// foreach ($array_result['notAbove'] as $notAboveCond)
// {
// $errormsg.="- cid:". $notAboveCond[3]."\\n";
// }
//
// }
// if (!is_null($array_result['notBelow']))
// {
// $errormsg.=$clang->gT("Some questions rely on this question's answers. You can't move this question below groupId:","js")
// . " " . $array_result['notBelow'][0][0] . " " . $clang->gT("in position","js")." ".$array_result['notBelow'][0][1]."\\n"
// . $clang->gT("See conditions:")."\\n";
//
// foreach ($array_result['notBelow'] as $notBelowCond)
// {
// $errormsg.="- cid:". $notBelowCond[3]."\\n";
// }
// }
//
// $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"$errormsg\")\n //-->\n</script>\n";
// $gid= $oldgid; // group move impossible ==> keep display on oldgid
// }
}
else
{
Expand Down
110 changes: 55 additions & 55 deletions admin/html.php
Expand Up @@ -685,7 +685,7 @@
LimeExpressionManager::StartProcessingPage(false,$rooturl); // so can click on syntax highlighting to edit questions
LimeExpressionManager::StartProcessingGroup($gid,false,$surveyid); // loads list of replacement values available for this group

if (trim($surveyinfo['surveyls_description'])!='')
if (trim($surveyinfo['surveyls_description'])!='')
{
templatereplace($surveyinfo['surveyls_description']);
$surveysummary .= LimeExpressionManager::GetLastPrettyPrintExpression();
Expand All @@ -698,7 +698,7 @@

templatereplace($surveyinfo['surveyls_welcometext']);
$surveysummary .= LimeExpressionManager::GetLastPrettyPrintExpression();

$surveysummary .= "</td></tr>\n"
. "<tr ><td align='right' valign='top'><strong>"
. $clang->gT("Administrator:")."</strong></td>\n"
Expand Down Expand Up @@ -836,7 +836,7 @@
$grpresult = db_execute_assoc($grpquery); //Checked

// Check if other questions/groups are dependent upon this group
$condarray=GetGroupDepsForConditions($surveyid,"all",$gid,"by-targgid");
// $condarray=GetGroupDepsForConditions($surveyid,"all",$gid,"by-targgid");

$groupsummary = "<div class='menubar'>\n"
. "<div class='menubar-title ui-widget-header'>\n";
Expand Down Expand Up @@ -895,20 +895,20 @@
{
if ((($sumcount4 == 0 && $activated != "Y") || $activated != "Y"))
{
if (is_null($condarray))
{
// if (is_null($condarray))
// {
// $groupsummary .= "<a href='$scriptname?action=delgroup&amp;sid=$surveyid&amp;gid=$gid' onclick=\"return confirm('".$clang->gT("Deleting this group will also delete any questions and answers it contains. Are you sure you want to continue?","js")."')\""
$groupsummary .= "<a href='#' onclick=\"if (confirm('".$clang->gT("Deleting this group will also delete any questions and answers it contains. Are you sure you want to continue?","js")."')) {".get2post("$scriptname?action=delgroup&amp;sid=$surveyid&amp;gid=$gid")."}\""
. " title=\"".$clang->gTview("Delete current question group")."\">"
. "<img src='$imageurl/delete.png' alt='".$clang->gT("Delete current question group")."' name='DeleteWholeGroup' title='' /></a>\n";
//get2post("$scriptname?action=delgroup&amp;sid=$surveyid&amp;gid=$gid");
}
else
{
$groupsummary .= "<a href='$scriptname?sid=$surveyid&amp;gid=$gid' onclick=\"alert('".$clang->gT("Impossible to delete this group because there is at least one question having a condition on its content","js")."')\""
. " title=\"".$clang->gTview("Delete current question group")."\">"
. "<img src='$imageurl/delete_disabled.png' alt='".$clang->gT("Delete current question group")."' name='DeleteWholeGroup' /></a>\n";
}
// }
// else
// {
// $groupsummary .= "<a href='$scriptname?sid=$surveyid&amp;gid=$gid' onclick=\"alert('".$clang->gT("Impossible to delete this group because there is at least one question having a condition on its content","js")."')\""
// . " title=\"".$clang->gTview("Delete current question group")."\">"
// . "<img src='$imageurl/delete_disabled.png' alt='".$clang->gT("Delete current question group")."' name='DeleteWholeGroup' /></a>\n";
// }
}
else
{
Expand Down Expand Up @@ -1049,25 +1049,25 @@
$groupsummary .= $clang->gT("Relevance:")."</td>\n<td align='left'>";
templatereplace('{' . $grow['grelevance'] . '}');
$groupsummary .= LimeExpressionManager::GetLastPrettyPrintExpression();
}
}
$groupsummary .= "</td></tr>\n";

if (!is_null($condarray))
{
$groupsummary .= "<tr><td align='right'><strong>"
. $clang->gT("Questions with conditions to this group").":</strong></td>\n"
. "<td valign='bottom' align='left'>";
foreach ($condarray[$gid] as $depgid => $deprow)
{
foreach ($deprow['conditions'] as $depqid => $depcid)
{
//$groupsummary .= "[QID: ".$depqid."]";
$listcid=implode("-",$depcid);
$groupsummary .= " <a href='#' onclick=\"window.open('admin.php?sid=".$surveyid."&amp;gid=".$depgid."&amp;qid=".$depqid."&amp;action=conditions&amp;markcid=".$listcid."','_top')\">[QID: ".$depqid."]</a>";
}
}
$groupsummary .= "</td></tr>";
}
// if (!is_null($condarray))
// {
// $groupsummary .= "<tr><td align='right'><strong>"
// . $clang->gT("Questions with conditions to this group").":</strong></td>\n"
// . "<td valign='bottom' align='left'>";
// foreach ($condarray[$gid] as $depgid => $deprow)
// {
// foreach ($deprow['conditions'] as $depqid => $depcid)
// {
// //$groupsummary .= "[QID: ".$depqid."]";
// $listcid=implode("-",$depcid);
// $groupsummary .= " <a href='#' onclick=\"window.open('admin.php?sid=".$surveyid."&amp;gid=".$depgid."&amp;qid=".$depqid."&amp;action=conditions&amp;markcid=".$listcid."','_top')\">[QID: ".$depqid."]</a>";
// }
// }
// $groupsummary .= "</td></tr>";
// }
}
$groupsummary .= "\n</table>\n";
}
Expand Down Expand Up @@ -1095,7 +1095,7 @@
$questionsummary = "<div class='menubar'>\n";

// Check if other questions in the Survey are dependent upon this question
$condarray=GetQuestDepsForConditions($surveyid,"all","all",$qid,"by-targqid","outsidegroup");
// $condarray=GetQuestDepsForConditions($surveyid,"all","all",$qid,"by-targqid","outsidegroup");


// PREVIEW THIS QUESTION BUTTON
Expand Down Expand Up @@ -1163,27 +1163,27 @@
. "<a href=\"#\" onclick=\"window.open('$scriptname?action=showlogicfile&amp;sid=$surveyid&amp;gid=$gid&amp;qid=$qid','_blank')\""
. " title=\"".$clang->gTview("Survey Logic File for current question")."\">"
. "<img src='$imageurl/quality_assurance.png' alt='".$clang->gT("Survey Logic File for current question")."' name='ShowQuestionLogicFile' /></a>\n" ;
}
}


// DELETE CURRENT QUESTION BUTTON

if ((($qct == 0 && $activated != "Y") || $activated != "Y") && bHasSurveyPermission($surveyid,'surveycontent','delete'))
{
if (is_null($condarray))
{
// if (is_null($condarray))
// {
$questionsummary .= "<a href='#'" .
"onclick=\"if (confirm('".$clang->gT("Deleting this question will also delete any answer options and subquestions it includes. Are you sure you want to continue?","js")."')) {".get2post("$scriptname?action=delquestion&amp;sid=$surveyid&amp;gid=$gid&amp;qid=$qid")."}\">"
. "<img src='$imageurl/delete.png' name='DeleteWholeQuestion' alt='".$clang->gT("Delete current question")."' "
. "border='0' hspace='0' /></a>\n";
}
else
{
$questionsummary .= "<a href='$scriptname?sid=$surveyid&amp;gid=$gid&amp;qid=$qid'" .
"onclick=\"alert('".$clang->gT("It's impossible to delete this question because there is at least one question having a condition on it.","js")."')\""
. "title=\"".$clang->gTview("Disabled - Delete current question")."\">"
. "<img src='$imageurl/delete_disabled.png' name='DeleteWholeQuestion' alt='".$clang->gT("Disabled - Delete current question")."' /></a>\n";
}
// }
// else
// {
// $questionsummary .= "<a href='$scriptname?sid=$surveyid&amp;gid=$gid&amp;qid=$qid'" .
// "onclick=\"alert('".$clang->gT("It's impossible to delete this question because there is at least one question having a condition on it.","js")."')\""
// . "title=\"".$clang->gTview("Disabled - Delete current question")."\">"
// . "<img src='$imageurl/delete_disabled.png' name='DeleteWholeQuestion' alt='".$clang->gT("Disabled - Delete current question")."' /></a>\n";
// }
}
else {$questionsummary .= "<img src='$imageurl/blank.gif' alt='' width='40' />\n";}

Expand Down Expand Up @@ -1327,7 +1327,7 @@
if (trim($qrrow['help'])!='')
{
templatereplace($qrrow['help'],false,false,$qid);
$questionsummary .= LimeExpressionManager::GetLastPrettyPrintExpression();
$questionsummary .= LimeExpressionManager::GetLastPrettyPrintExpression();
}
$questionsummary .= "</td></tr>\n";
if ($qrrow['preg'])
Expand Down Expand Up @@ -1377,19 +1377,19 @@
$questionsummary .= ($qrrow['mandatory'] == "Y") ? ($clang->gT("Yes")) : ($clang->gT("No")) ;
$questionsummary .= "</td></tr>\n";
}
if (!is_null($condarray))
{
$questionsummary .= "<tr>"
. "<td align='right' valign='top'><strong>"
. $clang->gT("Other questions having conditions on this question:")
. "</strong></td>\n<td align='left' valign='bottom'>\n";
foreach ($condarray[$qid] as $depqid => $depcid)
{
$listcid=implode("-",$depcid);
$questionsummary .= " <a href='#' onclick=\"window.open('admin.php?sid=".$surveyid."&amp;qid=".$depqid."&amp;action=conditions&amp;markcid=".$listcid."','_top')\">[QID: ".$depqid."]</a>";
}
$questionsummary .= "</td></tr>";
}
// if (!is_null($condarray))
// {
// $questionsummary .= "<tr>"
// . "<td align='right' valign='top'><strong>"
// . $clang->gT("Other questions having conditions on this question:")
// . "</strong></td>\n<td align='left' valign='bottom'>\n";
// foreach ($condarray[$qid] as $depqid => $depcid)
// {
// $listcid=implode("-",$depcid);
// $questionsummary .= " <a href='#' onclick=\"window.open('admin.php?sid=".$surveyid."&amp;qid=".$depqid."&amp;action=conditions&amp;markcid=".$listcid."','_top')\">[QID: ".$depqid."]</a>";
// }
// $questionsummary .= "</td></tr>";
// }
if (is_null($qrrow['relevance']) || trim($qrrow['relevance']) == '')
{
$rel2show = 1;
Expand Down

0 comments on commit aa2b7f6

Please sign in to comment.