Skip to content

Commit

Permalink
Merge branch 'master' into 192_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
TMSWhite committed Jun 22, 2012
2 parents f2e1c0b + eb34180 commit d4a7505
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 45 deletions.
3 changes: 3 additions & 0 deletions classes/expressions/ExpressionManager.php
Expand Up @@ -1812,6 +1812,7 @@ public function sProcessStringContainingExpressions($src, $questionNum=0, $numRe
$this->groupSeq = $groupSeq;
$result = $src;
$prettyPrint = '';
$errors = array();

for($i=1;$i<=$numRecursionLevels;++$i)
{
Expand All @@ -1821,8 +1822,10 @@ public function sProcessStringContainingExpressions($src, $questionNum=0, $numRe
{
$prettyPrint = $this->prettyPrintSource;
}
$errors = array_merge($errors, $this->RDP_errs);
}
$this->prettyPrintSource = $prettyPrint; // ensure that if doing recursive substition, can get original source to pretty print
$this->RDP_errs = $errors;
return $result;
}

Expand Down
46 changes: 42 additions & 4 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -7784,6 +7784,7 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
$LEM =& LimeExpressionManager::singleton();

$allErrors = array();
$warnings=0;

$surveyOptions = array(
'assessments'=>$assessments,
Expand Down Expand Up @@ -7816,17 +7817,50 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL

$qtypes=getqtypelist('','array');

templatereplace('{SITENAME}'); // to ensure that lime replacement fields loaded

if (is_null($moveResult) || is_null($LEM->currentQset) || count($LEM->currentQset) == 0) {
return array(
'errors'=>1,
'html'=>$LEM->gT('Invalid question - probably missing sub-questions or language-specific settings for language ') . $_SESSION['LEMlang'],
);
}

$out = "<table border='1'>"
. "<tr><th>#</th><th>".$LEM->gT('Name [ID]')."</th><th>".$LEM->gT('Relevance [Validation] (Default)')."</th><th>".$LEM->gT('Text [Help] (Tip)')."</th></tr>\n";
$surveyname = templatereplace('{SURVEYNAME}');

$out = '<H3>' . $LEM->gT('Logic File for Survey # ') . '[' . $LEM->sid . "]: $surveyname</H3>\n";
$out .= "<table border='1'>";

if (is_null($gid) && is_null($qid))
{
$description = templatereplace('{SURVEYDESCRIPTION}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($description != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("Description:") . "</td><td colspan=2>" . $description . "</td></tr>";
}

$welcome = templatereplace('{WELCOME}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($welcome != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("Welcome:") . "</td><td colspan=2>" . $welcome . "</td></tr>";
}

$endmsg = templatereplace('{ENDTEXT}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($endmsg != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("End message:") . "</td><td colspan=2>" . $endmsg . "</td></tr>";
}

$_linkreplace = templatereplace('{URL}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($_linkreplace != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("End URL") . ":</td><td colspan=2>" . $_linkreplace . "</td></tr>";
}
}

$out .= "<tr><th>#</th><th>".$LEM->gT('Name [ID]')."</th><th>".$LEM->gT('Relevance [Validation] (Default)')."</th><th>".$LEM->gT('Text [Help] (Tip)')."</th></tr>\n";

$_gseq=-1;
foreach ($LEM->currentQset as $q) {
Expand Down Expand Up @@ -8050,6 +8084,10 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
{
++$errorCount;
}
else
{
++$warnings;
}
}

//////
Expand Down
2 changes: 0 additions & 2 deletions classes/expressions/test/survey_logic_file.php
Expand Up @@ -135,8 +135,6 @@

SetSurveyLanguage($surveyid, $language);

echo '<H3>' . $clang->gT('Logic File for Survey # ') . $surveyid . "</H3>\n";

$result = LimeExpressionManager::ShowSurveyLogicFile($surveyid, $gid, $qid,$LEMdebugLevel,$assessments);
print $result['html'];

Expand Down
27 changes: 25 additions & 2 deletions common_functions.php
Expand Up @@ -6681,7 +6681,30 @@ function usedTokens($token)
return $utresult;
}


/**
* Return true if the actual survey answer is completed
*
* @param int $surveyid The survey id
* @param int $srid The survey answer id
*/
function isCompleted($surveyid,$srid)
{
global $connect;
$completed = false;
if($surveyid && $srid)
{
$sRow=$connect->GetRow("SELECT active FROM ".db_table_name('surveys')." WHERE sid=$surveyid");
if($sRow['active']=='Y')
{
$sridRow=$connect->GetRow("SELECT submitdate FROM ".db_table_name('survey_'.$surveyid)." WHERE id=$srid");
if($sridRow && $sridRow['submitdate'])
{
$completed=true;
}
}
}
return $completed;
};

/**
* redirect() generates a redirect URL for the apporpriate SSL mode then applies it.
Expand Down Expand Up @@ -6958,4 +6981,4 @@ function getIPAddress()
}
}

// Closing PHP tag intentionally omitted - yes, it is okay
// Closing PHP tag intentionally omitted - yes, it is okay
7 changes: 7 additions & 0 deletions docs/release_notes.txt
Expand Up @@ -78,6 +78,13 @@ HOW TO UPGRADE from a LimeSurvey 1.70(+) version to the latest 1.9x
Thank you to everyone who helped with this new release!


Changes from 1.92+ (build 120620) to 1.92+ (build 120623) June 22, 2012
-Fixed issue #6240: conversion of conditions to relevance can fail for multiple choice tests during some upgrades (Thomas White)
#Updated translation: Chinese (Simplified) by yooyooh
#Updated translation: French (France) by DenisChenu
#Updated translation: Italian by gifino, lfanfoni
#Updated translation: Polish by elisa


Changes from 1.92+ (build 120613) to 1.92+ (build 120620) June 20, 2012
-Fixed issue #5766: exclude_all_others_auto does not work (Thomas White)
Expand Down
67 changes: 34 additions & 33 deletions index.php
Expand Up @@ -761,51 +761,52 @@
if (isset($_GET['move']) && $_GET['move'] == "clearall")
{
$s_lang = $_SESSION['s_lang'];
if (isset($_SESSION['srid']))
if (isset($_SESSION['srid']) && !isCompleted($surveyid,$_SESSION['srid']))
{
// find out if there are any fuqt questions - checked
$fieldmap = createFieldMap($surveyid);
foreach ($fieldmap as $field)
// delete the response but only if not already completed
$result = $connect->query('SELECT id FROM '.db_table_name('survey_'.$surveyid).' WHERE id='.$_SESSION['srid']." AND submitdate IS NULL");
if($result->RecordCount()>0)
{
if ($field['type'] == "|" && !strpos($field['fieldname'], "_filecount"))
$connect->query('DELETE FROM '.db_table_name('survey_'.$surveyid).' WHERE id='.$_SESSION['srid']." AND submitdate IS NULL");
// find out if there are any fuqt questions - checked
$fieldmap = createFieldMap($surveyid);
foreach ($fieldmap as $field)
{
if (!isset($qid)) { $qid = array(); }
$qid[] = $field['fieldname'];
if ($field['type'] == "|" && !strpos($field['fieldname'], "_filecount"))
{
if (!isset($qid)) { $qid = array(); }
$qid[] = $field['fieldname'];
}
}
}

// if yes, extract the response json to those questions
if (isset($qid))
{
$query = "SELECT * FROM ".db_table_name("survey_".$surveyid)." WHERE id=".$_SESSION['srid'];
$result = db_execute_assoc($query);
while ($row = $result->FetchRow())
// if yes, extract the response json to those questions
if (isset($qid))
{
foreach ($qid as $question)
$query = "SELECT * FROM ".db_table_name("survey_".$surveyid)." WHERE id=".$_SESSION['srid'];
$result = db_execute_assoc($query);
while ($row = $result->FetchRow())
{
$json = $row[$question];
if ($json == "" || $json == NULL)
continue;
foreach ($qid as $question)
{
$json = $row[$question];
if ($json == "" || $json == NULL)
continue;

// decode them
$phparray = json_decode($json);
// decode them
$phparray = json_decode($json);

foreach ($phparray as $metadata)
{
$target = "{$uploaddir}/surveys/{$surveyid}/files/";
// delete those files
unlink($target.$metadata->filename);
foreach ($phparray as $metadata)
{
$target = "{$uploaddir}/surveys/{$surveyid}/files/";
// delete those files
unlink($target.$metadata->filename);
}
}
}
}
// done deleting uploaded files
}
// done deleting uploaded files


// delete the response but only if not already completed
$connect->query('DELETE FROM '.db_table_name('survey_'.$surveyid).' WHERE id='.$_SESSION['srid']." AND submitdate IS NULL");

// also delete a record from saved_control when there is one

// also delete a record from saved_control when there is one, we can allway do it.
$connect->query('DELETE FROM '.db_table_name('saved_control'). ' WHERE srid='.$_SESSION['srid'].' AND sid='.$surveyid);
}
session_unset();
Expand Down
Binary file modified locale/fr/LC_MESSAGES/fr.mo
Binary file not shown.
Binary file modified locale/it/LC_MESSAGES/it.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion qanda.php
Expand Up @@ -1248,7 +1248,7 @@ function do_language($ia)

$answerlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$answerlangs [] = GetBaseLanguageFromSurveyID($surveyid);
$answer = "\n\t<p class=\"question\">\n.<label for='answer{$ia[1]}' class='hide label'>{$clang->gT('Choose your language')}</label><select name=\"$ia[1]\" id=\"answer$ia[1]\" onchange=\"document.getElementById('lang').value=this.value; $checkconditionFunction(this.value, this.name, this.type);\">\n";
$answer = "\n\t<p class=\"question\">\n<label for='answer{$ia[1]}' class='hide label'>{$clang->gT('Choose your language')}</label><select name=\"$ia[1]\" id=\"answer$ia[1]\" onchange=\"document.getElementById('lang').value=this.value; $checkconditionFunction(this.value, this.name, this.type);\">\n";
if (!$_SESSION[$ia[1]]) {$answer .= "\t<option value=\"\" selected=\"selected\">".$clang->gT('Please choose...')."</option>\n";}
foreach ($answerlangs as $ansrow)
{
Expand Down
20 changes: 17 additions & 3 deletions replacements.php
Expand Up @@ -303,14 +303,21 @@ function templatereplace($line, $replacements=array(), $anonymized=false, $quest
{
$_s_lang = $_SESSION['s_lang'];
}

$_clearall = "<input type='button' name='clearallbtn' value='" . $clang->gT("Exit and Clear Survey") . "' class='clearall' "
// CLEARALL
if( $surveyid && !isCompleted($surveyid,$saved_id))
{
$_clearall = "<input type='button' name='clearallbtn' value='" . $clang->gT("Exit and Clear Survey") . "' class='clearall' "
. "onclick=\"if (confirm('" . $clang->gT("Are you sure you want to clear all your responses?", 'js') . "')) {\nwindow.open('{$publicurl}/index.php?sid=$surveyid&amp;move=clearall&amp;lang=" . $_s_lang;
if (returnglobal('token'))
{
$_clearall .= "&amp;token=" . urlencode(trim(sanitize_token(strip_tags(returnglobal('token')))));
$_clearall .= "&amp;token={$_token}";
}
$_clearall .= "', '_self')}\" />";
}
else
{
$_clearall=""; // This survey are already completed or surveyid not set, then don't have access to clearallbtn
}

if (isset($_SESSION['datestamp']))
{
Expand Down Expand Up @@ -639,6 +646,12 @@ function templatereplace($line, $replacements=array(), $anonymized=false, $quest
}
}

$_endtext = '';
if (isset($thissurvey['surveyls_endtext']) && trim($thissurvey['surveyls_endtext'])!='')
{
$_endtext = $thissurvey['surveyls_endtext'];
}

// Set the array of replacement variables here - don't include curly braces
// Please put any conditional logic above this section. Here below should just be an alphabetical list of replacement values with no embedded logic.

Expand All @@ -654,6 +667,7 @@ function templatereplace($line, $replacements=array(), $anonymized=false, $quest
$coreReplacements['CLOSEWINDOW'] = "<a href='javascript:%20self.close()'>".$clang->gT("Close this window")."</a>";
$coreReplacements['COMPLETED'] = $completed; // global
$coreReplacements['DATESTAMP'] = $_datestamp;
$coreReplacements['ENDTEXT'] = $_endtext;
$coreReplacements['EXPIRY'] = $_dateoutput;
$coreReplacements['GID'] = $_question_gid;
$coreReplacements['GOOGLE_ANALYTICS_API_KEY'] = $_googleAnalyticsAPIKey;
Expand Down

0 comments on commit d4a7505

Please sign in to comment.