Skip to content

Commit

Permalink
Dev Reworked dataentry to use CreateFieldMap - saved around 400 lines…
Browse files Browse the repository at this point in the history
… of code

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@8331 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Feb 1, 2010
1 parent 9351e87 commit f0e47a2
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 673 deletions.
19 changes: 12 additions & 7 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@
if(hasRight($surveyid,'browse_response')) {include('statistics.php');}
else { include('access_denied.php');}
}
elseif ($action == 'browse')
{
if(hasRight($surveyid,'browse_response')) {include('browse.php');}
else { include('access_denied.php');}
}
elseif ($action == 'tokens')
{
if(hasRight($surveyid,'activate_survey')) {$_SESSION['FileManagerContext']="edit:emailsettings:$surveyid"; include('tokens.php');}
Expand Down Expand Up @@ -448,7 +443,7 @@
(isset($surveyid) || $action=='listurveys' || $action=='personalsettings' || //Still to check
$action=='importsurvey' || $action=='editsurvey' || $action=='updatesurvey' || $action=='ordergroups' || $action=='dataentry' ||
$action=='newsurvey' || $action=='listsurveys' || $action=='globalsettings' || $action=='editusergroups' ||
$action=='surveyrights' || $action=='quotas' || $action=='editusers' || $action=='' || $action=='login') )
$action=='surveyrights' || $action=='quotas' || $action=='editusers' || $action=='' || $action=='login' || $action=='browse') )
{
if ($action=='editsurvey' || $action=='updatesurvey')
{
Expand All @@ -468,7 +463,17 @@
include('access_denied.php');
}
}

elseif ($action == 'browse')
{
if(hasRight($surveyid,'browse_response'))
{
include('browse.php');
}
else
{
include('access_denied.php');
}
}

if ($action=='addquestion' || $action=='copyquestion' || $action=='editquestion' ||
$action=='orderquestions' || $action=='ajaxquestionattributes' || $action=='ajaxlabelsetpicker' || $action=='ajaxlabelsetdetails')
Expand Down
79 changes: 26 additions & 53 deletions admin/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,69 +135,42 @@
if ($subaction == "id") // Looking at a SINGLE entry
{
$dateformatdetails=getDateFormatData($_SESSION['dateformat']);

//SHOW HEADER
if (!isset($_POST['sql']) || !$_POST['sql']) {$browseoutput .= $surveyoptions;} // Don't show options if coming from tokens script
//FIRST LETS GET THE NAMES OF THE QUESTIONS AND MATCH THEM TO THE FIELD NAMES FOR THE DATABASE
$fnquery = "SELECT * FROM ".db_table_name("questions").", ".db_table_name("groups").", ".db_table_name("surveys")."
WHERE ".db_table_name("questions").".gid=".db_table_name("groups").".gid AND ".db_table_name("groups").".sid=".db_table_name("surveys").".sid
AND ".db_table_name("questions").".sid='$surveyid' AND
".db_table_name("questions").".language='{$language}' AND ".db_table_name("groups").".language='{$language}' ORDER BY ".db_table_name("groups").".group_order, ".db_table_name("questions").".title";
$fnresult = db_execute_assoc($fnquery);
$fncount = 0;

$fnrows = array(); //Create an empty array in case fetch_array does not return any rows
while ($fnrow = $fnresult->FetchRow()) {++$fncount; $fnrows[] = $fnrow; $private = $fnrow['private']; $datestamp=$fnrow['datestamp']; $ipaddr=$fnrow['ipaddr']; $refurl=$fnrow['refurl'];} // Get table output into array

// Perform a case insensitive natural sort on group name then question title of a multidimensional array
usort($fnrows, 'CompareGroupThenTitle');


$fnames[] = array("id", "id");
if ($private == "N") //add token to top ofl ist is survey is not private
{
$fnames[] = array("token", $clang->gT("Token ID"));
}

$fnames[] = array("completed", $clang->gT("Completed"), "0");
$fncount = 0;

if ($datestamp == "Y") //add datetime to list if survey is datestamped
{
// submitdate for not-datestamped surveys is always 1980/01/01
// so only display it when datestamped
$fnames[] = array("startdate", $clang->gT("Date Started"));
$fnames[] = array("datestamp", $clang->gT("Date Last Action"));
$fnames[] = array("submitdate", $clang->gT("Date Submitted"));
}
if ($ipaddr == "Y") //add ipaddr to list if survey should save submitters IP address
{
$fnames[] = array("ipaddr", $clang->gT("IP Address"));
}
if ($refurl == "Y") //add refer_URL to list if survey should save referring URL
{
$fnames[] = array("refurl", $clang->gT("Referring URL"));
}


$fieldmap=createFieldMap($surveyid,'full');
unset($fieldmap[0]);
unset($fieldmap[1]);
$position=0;
foreach ($fieldmap as $field)
{
$question=$field['question'];
if (isset($field['subquestion']) && $field['subquestion']!='')
$question=$field['question'];
if (isset($field['subquestion']) && $field['subquestion']!='')
{
$question .=' ('.$field['subquestion'];
}
if (isset($field['answer']) && $field['answer']!='')
{
$question .=' : '.$field['answer'];
}
$question .=')';
if (isset($field['scale_id']))
$question .=' ('.$field['subquestion'].')';
}
if (isset($field['subquestion1']) && isset($field['subquestion1']))
{
$question .='['.$field['scale'].']';
}
$fnames[]=array($field['fieldname'],$question);
}
$question .=' ('.$field['subquestion1'].':'.$field['subquestion2'].')';
}
if (isset($field['scale_id']))
{
$question .='['.$field['scale'].']';
}
$fnames[]=array($field['fieldname'],$question);
if ($position==1)
{
$fnames[] = array("completed", $clang->gT("Completed"), "0");
if ($surveyinfo['private'] == "N") //add token to top ofl ist is survey is not private
{
$fnames[] = array("token", $clang->gT("Token ID"));
}
}
$position++;
}

$nfncount = count($fnames)-1;
//SHOW INDIVIDUAL RECORD
Expand Down

0 comments on commit f0e47a2

Please sign in to comment.