Skip to content

Commit

Permalink
New feature Quick navigation buttons to move forward and backward bet…
Browse files Browse the repository at this point in the history
…ween question groups and questions

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9510 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Andrie de Vries committed Nov 19, 2010
1 parent cc04bb9 commit ad7026f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 47 deletions.
36 changes: 16 additions & 20 deletions admin/html.php
Expand Up @@ -737,30 +737,28 @@
if ($GidPrev != "")
{
$surveysummary .= ""
. "<input type='image' src='$imageurl/questiongroupprevious.png' title='". $clang->gT("Previous question group")."' "
. "alt='". $clang->gT("Previous question group")."' name='questiongroupprevious' ";
//. "onclick='document.getElementById(\"surveydetails\").style.display=\"none\";' />\n";
. "<a href='{$scriptname}?sid=$surveyid&amp;gid=$GidPrev'>"
. "<img src='{$imageurl}/questiongroupprevious.png' title='' alt='".$clang->gT("Previous question group")."' "
."name='questiongroupprevious' ".$clang->gT("Previous question group")."/> </a>";
}
else
{
$surveysummary .= ""
. "<input type='image' src='$imageurl/questiongroupprevioushidden.png' title='". $clang->gT("Previous question group")."' "
. "alt='". $clang->gT("Previous question group")."' name='questiongroupprevious' ";
. "<img src='{$imageurl}/questiongroupprevioushidden.png' title='' ";
}

$GidNext = getGidNext($surveyid, $gid);
if ($GidNext != "")
{
$surveysummary .= ""
. "<input type='image' src='$imageurl/questiongroupnext.png' title='". $clang->gT("Next question group")."' "
. "alt='". $clang->gT("Next question group")."' name='questiongroupnext' ";
//. "onclick='document.getElementById(\"surveydetails\").style.display=\"none\";' />\n";
. "<a href='{$scriptname}?sid=$surveyid&amp;gid=$GidNext'>"
. "<img src='{$imageurl}/questiongroupnext.png' title='' alt='".$clang->gT("Next question group")."' "
."name='questiongroupnext' ".$clang->gT("Next question group")."/> </a>";
}
else
{
$surveysummary .= ""
. "<input type='image' src='$imageurl/questiongroupnexthidden.png' title='". $clang->gT("Next question group")."' "
. "alt='". $clang->gT("Next question group")."' name='questiongroupnext' ";
. "<img src='{$imageurl}/questiongroupnexthidden.png' title='' ";
}


Expand Down Expand Up @@ -1109,31 +1107,29 @@
if ($QidPrev != "")
{
$groupsummary .= ""
. "<input type='image' src='$imageurl/questionprevious.png' title='". $clang->gT("Previous question")."' "
. "alt='". $clang->gT("Previous question")."' name='questionprevious' ";
//. "onclick='document.getElementById(\"surveydetails\").style.display=\"none\";' />\n";
. "<a href='{$scriptname}?sid=$surveyid&amp;gid=$gid&amp;qid=$QidPrev'>"
. "<img src='{$imageurl}/questionprevious.png' title='' alt='".$clang->gT("Previous question")."' "
."name='questiongroupprevious' ".$clang->gT("Previous question")."/> </a>";
}
else
{
$groupsummary .= ""
. "<input type='image' src='$imageurl/questionprevioushidden.png' title='". $clang->gT("Previous question")."' "
. "alt='". $clang->gT("Previous question")."' name='questionprevious' ";
. "<img src='{$imageurl}/questionprevioushidden.png' title='' ";
}


$QidNext = getQidNext($surveyid, $gid, $qid);
if ($QidNext != "")
{
$groupsummary .= ""
. "<input type='image' src='$imageurl/questionnext.png' title='". $clang->gT("Next question")."' "
. "alt='". $clang->gT("Next question")."' name='questionnext' ";
//. "onclick='document.getElementById(\"surveydetails\").style.display=\"none\";' />\n";
. "<a href='{$scriptname}?sid=$surveyid&amp;gid=$gid&amp;qid=$QidNext'>"
. "<img src='{$imageurl}/questiongroupnext.png' title='' alt='".$clang->gT("Next question")."' "
."name='questiongroupnext' ".$clang->gT("Next question")."/> </a>";
}
else
{
$groupsummary .= ""
. "<input type='image' src='$imageurl/questionnexthidden.png' title='". $clang->gT("Next question")."' "
. "alt='". $clang->gT("Next question")."' name='questionnext' ";
. "<img src='{$imageurl}/questiongroupnexthidden.png' title='' ";
}


Expand Down
54 changes: 27 additions & 27 deletions common_functions.php
Expand Up @@ -656,68 +656,68 @@ function getGidPrevious($surveyid, $gid)
if ($gid == $qrow['gid']) {$iPrev = $i - 1;}
$i += 1;
}
if ($iPrev > 0) {$GidPrev = $qrows[$iPrev]['gid'];}
if ($iPrev > 0) {$GidPrev = $qrows[$iPrev-1]['gid'];}
else {$GidPrev = "";}
return $GidPrev;
}

/**
* getGidNext() returns the Gid of the group next to the current active group
* getQidPrevious() returns the Qid of the question prior to the current active question
*
* @param string $surveyid
* @param string $gid
* @param string $qid
*
* @return The Gid of the next group
* @return This Qid of the previous question
*/
function getGidNext($surveyid, $gid)
function getQidPrevious($surveyid, $gid, $qid)
{
global $scriptname, $clang;

if (!$surveyid) {$surveyid=returnglobal('sid');}
$s_lang = GetBaseLanguageFromSurveyID($surveyid);
$gquery = "SELECT gid FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order";
$qresult = db_execute_assoc($gquery); //checked
$qquery = 'SELECT * FROM '.db_table_name('questions')." WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order";
$qresult = db_execute_assoc($qquery); //checked
$qrows = $qresult->GetRows();

$i = 0;
$iNext = count($qrows);
$i = 1;
$iPrev = 0;
foreach ($qrows as $qrow)
{
if ($gid == $qrow['gid']) {$iNext = $i + 1;}
if ($qid == $qrow['qid']) {$iPrev = $i - 1;}
$i += 1;
}
if ($iNext < count($qrows)) {$GidNext = $qrows[$iNext]['gid'];}
else {$GidNext = "";}
return $GidNext;
if ($iPrev > 0) {$QidPrev = $qrows[$iPrev-1]['qid'];}
else {$QidPrev = "";}
return $QidPrev;
}

/**
* getQidPrevious() returns the Qid of the question prior to the current active question
* getGidNext() returns the Gid of the group next to the current active group
*
* @param string $surveyid
* @param string $gid
* @param string $qid
*
* @return This Qid of the previous question
* @return The Gid of the next group
*/
function getQidPrevious($surveyid, $gid, $qid)
function getGidNext($surveyid, $gid)
{
global $scriptname, $clang;

if (!$surveyid) {$surveyid=returnglobal('sid');}
$s_lang = GetBaseLanguageFromSurveyID($surveyid);
$qquery = 'SELECT * FROM '.db_table_name('questions')." WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order";
$qresult = db_execute_assoc($qquery); //checked
$gquery = "SELECT gid FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order";
$qresult = db_execute_assoc($gquery); //checked
$qrows = $qresult->GetRows();

$i = 1;
$iPrev = 0;
$i = 0;
$iNext = count($qrows);
foreach ($qrows as $qrow)
{
if ($qid == $qrow['qid']) {$iPrev = $i - 1;}
if ($gid == $qrow['gid']) {$iNext = $i + 1;}
$i += 1;
}
if ($iPrev > 0) {$QidPrev = $qrows[$iPrev]['qid'];}
else {$QidPrev = "";}
return $QidPrev;
if ($iNext < count($qrows)) {$GidNext = $qrows[$iNext]['gid'];}
else {$GidNext = "";}
return $GidNext;
}

/**
Expand All @@ -733,7 +733,7 @@ function getQidNext($surveyid, $gid, $qid)
{
global $scriptname, $clang;
$s_lang = GetBaseLanguageFromSurveyID($surveyid);
$qquery = 'SELECT * FROM '.db_table_name('questions')." WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order";
$qquery = 'SELECT qid FROM '.db_table_name('questions')." WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order";
$qresult = db_execute_assoc($qquery); //checked
$qrows = $qresult->GetRows();

Expand Down

0 comments on commit ad7026f

Please sign in to comment.