Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Apr 3, 2023
2 parents 360faa7 + 04dd59f commit dd7a902
Show file tree
Hide file tree
Showing 56 changed files with 5,712 additions and 761 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ package.json export-ignore
phpci.yml export-ignore
phpcs.ruleset.xml export-ignore
phpunit.xml export-ignore
palm.xml export-ignore
palm.xml export-ignore
tests export-ignore
yarn.lock export-ignore
vendor/khaled.alshamaa/ar-php/examples export-ignore

# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
# if you want to add a new distributed plugin : add the directory here
/plugins/*
!/plugins/index.html
!/plugins/Demo/

#ignore old styles
/styles/
Expand Down
2 changes: 1 addition & 1 deletion application/config/updater_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// THIS FILE SHOULD NOT BE CHANGED MANUALLY !

$config['updaterversion'] = 19;
$config['updaterversion'] = 20;
$config['comfort_update_server_url'] = 'comfortupdate.limesurvey.org/';
$config['comfort_update_server_ssl'] = 1;
$config['allow_non_public_release'] = 0; // Used internally for debugging
Expand Down
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
$config['assetsversionnumber'] = '30327';
$config['assetsversionnumber'] = '30328';
return $config;
2 changes: 1 addition & 1 deletion application/controllers/StatisticsUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function createSGQA(array $filters)
case Question::QT_S_SHORT_FREE_TEXT: // Short free text
case Question::QT_T_LONG_FREE_TEXT: // Long free text
case Question::QT_U_HUGE_FREE_TEXT: // Huge free text
$allfields = "T" . $SGQidentifier;
$allfields[] = "T" . $SGQidentifier;
break;
case Question::QT_SEMICOLON_ARRAY_TEXT: // Array (Text)
case Question::QT_COLON_ARRAY_NUMBERS: // Array (Numbers)
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public function step4()
// this is the last step - Download the zip file, unpack it and replace files accordingly

$updateModel = new UpdateForm();

Yii::app()->loadLibrary("admin/pclzip"); //Preload PCLZip library in case it is moved to a different location in the update
$remove = $updateModel->removeDeletedFiles((array)$changedFiles);
if (!$remove->result) {
return $this->renderErrorString($remove->error, $remove->message);
Expand Down
31 changes: 24 additions & 7 deletions application/controllers/survey/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public function run()
$this->action();
}

/**
*
* todo: this function is toooo long, to many things happening here. Should be refactored asap!
* @return void
* @throws CException
* @throws CHttpException
*/
public function action()
{
global $surveyid;
Expand Down Expand Up @@ -211,22 +218,32 @@ public function action()
}

// No test for response update
if ($this->isSurveyFinished($surveyid) && ($thissurvey['alloweditaftercompletion'] != 'Y' || $thissurvey['tokenanswerspersistence'] != 'Y')) {
if ($this->isSurveyFinished($surveyid)) {
killSurveySession($surveyid);
$aReloadUrlParam = array('lang' => App()->language, 'newtest' => 'Y');

if (!empty($clienttoken)) {
$aReloadUrlParam['token'] = $clienttoken;
}

$aErrors = array(gT('Previous session is set to be finished.'));
$aMessage = array(gT('Your browser reports that it was used previously to answer this survey. We are resetting the session so that you can start from the beginning.'),);
//todo: this url is never shown to the participant in case of renderExitMessage (see below)
$restartUrl = $this->getController()->createUrl("/survey/index/sid/{$surveyid}", $aReloadUrlParam);
$aUrl = array(
'url' => $this->getController()->createUrl("/survey/index/sid/{$surveyid}", $aReloadUrlParam),
'url' => $restartUrl,
'type' => 'restart-survey',
'description' => gT("Click here to start the survey.")
);

killSurveySession($surveyid);
//Use case: if participant has possibility to run survey again
//instead of showing an error message, redirect participant to restart survey
//check if inherit value is set to 'Y'
$alloweditaftercompletion = ($thissurvey['alloweditaftercompletion'] == 'Y') ||
$oSurvey->getIsAllowEditAfterCompletion() || $thissurvey['tokenanswerspersistence'] == 'Y';
if ($alloweditaftercompletion) {
$this->getController()->redirect($restartUrl);
}

$aErrors = array(gT('Previous session is set to be finished.'));
$aMessage = array(gT('Your browser reports that it was used previously to answer this survey.
We are resetting the session so that you can start from the beginning.'),);
App()->getController()->renderExitMessage(
$surveyid,
'restart-survey',
Expand Down
19 changes: 17 additions & 2 deletions application/extensions/SettingsWidget/SettingsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,26 @@ public function renderDate($name, array $metaData, $form = null)
{
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
$value = $metaData['current'] ?? '';
$html = Yii::app()->getController()->widget('ext.DateTimePickerWidget.DateTimePicker', array(
/**
* Fix the value according to saveformat only if isset and not empty
* By defalt : save as sent by input (admin lanuage dependent
**/
if (!empty($metaData['saveformat'])) {
if (is_string($value) && $value !== "") {
$datetimeobj = new Date_Time_Converter($value, $metaData['saveformat']);
$value = $datetimeobj->convert($dateformatdetails['phpdate'] . "H:i");
} else {
$value = "";
}
}
$metaData['class'][] = 'form-control';
$htmlOptions = $this->htmlOptions($metaData, $form);

return Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => $name,
'id' => \CHtml::getIdByName($name),
'value' => $value,
'htmlOptions' => $htmlOptions,
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:mm",
'allowInputToggle' => true,
Expand All @@ -631,7 +647,6 @@ public function renderDate($name, array $metaData, $form = null)
)
), true
);
return $html;
}

/* Return htmlOptions for an input od seting
Expand Down
4 changes: 4 additions & 0 deletions application/helpers/SurveyRuntimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ public function run($surveyid, $args)
if (!empty($_SESSION[$this->LEMsessid]['token']) and $this->aSurveyInfo['anonymized'] != 'Y') {
$this->aSurveyInfo['hiddenInputs'] .= \CHtml::hiddenField('token', $_SESSION[$this->LEMsessid]['token'], array('id' => 'token'));
}
/* Set sof man to true if it's already in POST */
if (App()->request->getPost('mandSoft')) {
$this->aSurveyInfo['hiddenInputs'] .= \CHtml::hiddenField('mandSoft', App()->request->getPost('mandSoft'), array('id' => 'mandSoft'));
}
}

// For "clear all" buttons
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/statistics_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
//we want to have some "real" data here
if ($gdata[$i] != "N/A") {
//calculate percentage
$gdata[$i] = ($grawdata[$i] / $TotalCompleted) * 100;
$gdata[$i] = $TotalCompleted !== 0 ? ($grawdata[$i] / $TotalCompleted) * 100 : 0;
}
}

Expand Down
65 changes: 38 additions & 27 deletions application/helpers/expressions/em_manager_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq = null)
switch ($type) {
case Question::QT_K_MULTIPLE_NUMERICAL: //MULTI NUMERICAL QUESTION TYPE (Need a attribute, not set in 131014)
$subqValidSelector = $sq['jsVarName_on'];
// no break
case Question::QT_N_NUMERICAL: //NUMERICAL QUESTION TYPE
$sq_name = ($this->sgqaNaming) ? $sq['rowdivid'] . ".NAOK" : $sq['varName'] . ".NAOK";
$sq_eqn = '( is_int(' . $sq_name . ') || is_empty(' . $sq_name . ') )';
Expand Down Expand Up @@ -3770,14 +3771,13 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid, $forc
'jsVarName_on' => $jsVarName_on,
'sqsuffix' => '_comment',
];
} else // The question list
{
} else { // The question list
$q2subqInfo[$questionNum]['subqs'][] = [
'varName' => $varName,
'rowdivid' => $surveyid . 'X' . $groupNum . 'X' . $questionNum,
'jsVarName' => $jsVarName,
'jsVarName_on' => $jsVarName_on,
];
'varName' => $varName,
'rowdivid' => $surveyid . 'X' . $groupNum . 'X' . $questionNum,
'jsVarName' => $jsVarName,
'jsVarName_on' => $jsVarName_on,
];
}
break;
case Question::QT_N_NUMERICAL:
Expand Down Expand Up @@ -4099,7 +4099,7 @@ public function ProcessAllNeededRelevance($onlyThisQseq = null, $groupSeq = null
}
$qid = $rel['qid'];
$gseq = $rel['gseq'];
if(
if (
$gseq != $this->currentGroupSeq // ONLY validate current group
&& !$this->allOnOnePage // except if all in one page
&& (is_null($groupSeq) || $gseq > $groupSeq)
Expand Down Expand Up @@ -4828,7 +4828,7 @@ public static function NavigateForwards($force = false)
'invalidSQs' => $result['invalidSQs'],
];
return $LEM->lastMoveResult;
// NB: No break needed
// NB: No break needed
case 'group':
// First validate the current group
$LEM->StartProcessingPage();
Expand All @@ -4838,7 +4838,7 @@ public static function NavigateForwards($force = false)
$result = $LEM->_ValidateGroup($LEM->currentGroupSeq);
$message .= $result['message'];
$updatedValues = array_merge($updatedValues, $result['updatedValues']);
if (!is_null($result) && ($result['mandViolation'] || !$result['valid']) && empty(App()->request->getPost('mandSoft'))) {
if (!is_null($result) && ($result['mandViolation'] || !$result['valid'])) {
// redisplay the current group
$message .= $LEM->_UpdateValuesInDatabase();
$LEM->runtimeTimings[] = [__METHOD__, (microtime(true) - $now)];
Expand Down Expand Up @@ -4917,7 +4917,7 @@ public static function NavigateForwards($force = false)
$updatedValues = array_merge($updatedValues, $result['updatedValues']);
$gRelInfo = $LEM->gRelInfo[$LEM->currentGroupSeq];
$grel = $gRelInfo['result'];
if ($grel && !is_null($result) && ($result['mandViolation'] || !$result['valid']) && empty(App()->request->getPost('mandSoft'))) {
if ($grel && !is_null($result) && ($result['mandViolation'] || !$result['valid'])) {
// redisplay the current question with all error
$message .= $LEM->_UpdateValuesInDatabase();
$LEM->runtimeTimings[] = [__METHOD__, (microtime(true) - $now)];
Expand Down Expand Up @@ -5315,7 +5315,7 @@ public static function JumpTo($seq, $preview = false, $processPOST = true, $forc
'invalidSQs' => $result['invalidSQs'],
];
return $LEM->lastMoveResult;
// NB: No break needed
// NB: No break needed
case 'group':
// First validate the current group
$LEM->StartProcessingPage();
Expand Down Expand Up @@ -5642,7 +5642,6 @@ public function _ValidateGroup($groupSeq, $force = false)
/////////////////////////////////////////////////////////
for ($i = $groupSeqInfo['qstart']; $i <= $groupSeqInfo['qend']; ++$i) {
$qStatus = $LEM->_ValidateQuestion($i, $force);

$updatedValues = array_merge($updatedValues, $qStatus['updatedValues']);

if ($gRelInfo['result'] == true && $qStatus['relevant'] == true) {
Expand Down Expand Up @@ -5974,7 +5973,7 @@ function ($sqRankAnwsers) {
$_SESSION[$LEM->sessid]['relevanceStatus'][$sq['rowdivid']] = false;
}
}
// No break : next part is for array text and array number too
// no break : next part is for array text and array number too
case Question::QT_A_ARRAY_5_POINT: // Array (5 point choice) radio-buttons
case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: // Array (10 point choice) radio-buttons
case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: // Array (Yes/Uncertain/No)
Expand Down Expand Up @@ -6088,8 +6087,7 @@ function ($sqRankAnwsers) {
//////////////////////////////////////////////
$qmandViolation = false; // assume there is no mandatory violation until discover otherwise
$mandatoryTip = '';
// bypass validation if soft mandatory button was pressed
if (($qrel && !$qhidden && ($qInfo['mandatory'] == 'Y' || $qInfo['mandatory'] == 'S')) && empty(App()->request->getPost('mandSoft'))) {
if ($qrel && !$qhidden && ($qInfo['mandatory'] == 'Y' || $qInfo['mandatory'] == 'S')) {
$mandatoryTip = App()->twigRenderer->renderPartial(
'/survey/questions/question_help/mandatory_tip.twig',
[
Expand Down Expand Up @@ -6252,6 +6250,15 @@ function ($sqRankAnwsers) {
break;
}
}
/* Set qmandViolation to false if mandSoft and POST is set */
if (
$qmandViolation
&& $qInfo['mandatory'] == 'S'
&& App()->request->getPost('mandSoft')
) {
$qmandViolation = false;
$mandatoryTip = '';
}

/////////////////////////////////////////////////////////////
// DETECT WHETHER QUESTION SHOULD BE FLAGGED AS UNANSWERED //
Expand Down Expand Up @@ -6718,20 +6725,20 @@ public static function GetStepIndexInfo($step = null)
switch ($LEM->surveyMode) {
case 'survey':
return $LEM->lastMoveResult;
// NB: No break needed
// NB: No break needed
case 'group':
// #14595
if (is_null($step) || !array_key_exists($step, $LEM->indexGseq)) {
return $LEM->indexGseq;
}
return $LEM->indexGseq[$step];
// NB: No break needed
// NB: No break needed
case 'question':
if (is_null($step)) {
return $LEM->indexQseq;
}
return $LEM->indexQseq[$step];
// NB: No break needed
// NB: No break needed
}
}

Expand Down Expand Up @@ -8614,7 +8621,7 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
switch ($attr) {
case 'varName':
return $name;
// NB: No break needed
// NB: No break needed
case 'code':
case 'NAOK':
if (isset($var['code'])) {
Expand All @@ -8640,6 +8647,7 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
} else {
return $_SESSION[$this->sessid][$sgqa];
}
// no break
default:
return $_SESSION[$this->sessid][$sgqa];
}
Expand All @@ -8648,7 +8656,8 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
}
return $default;
}
// NB: No break needed
// NB: No break needed
// no break
case 'value':
case 'valueNAOK':
$type = $var['type'];
Expand Down Expand Up @@ -8687,7 +8696,7 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
break;
}
return $value;
// NB: No break needed
// NB: No break needed
case 'jsName':
if (
$this->surveyMode == 'survey'
Expand All @@ -8699,7 +8708,8 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
} else {
return (isset($var['jsName']) ? $var['jsName'] : $default);
}
// NB: No break needed
// NB: No break needed
// no break
case 'shown':
if (isset($var['shown'])) {
return $var['shown']; // for static values like TOKEN
Expand Down Expand Up @@ -8793,6 +8803,7 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
return $shown;
}
// NB: No break needed
// no break
case 'relevanceStatus':
$gseq = (isset($var['gseq'])) ? $var['gseq'] : -1;
$qid = (isset($var['qid'])) ? $var['qid'] : -1;
Expand All @@ -8804,15 +8815,15 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
return 1;
}
$grel = 1; // Group relevance true by default
if(isset($_SESSION[$this->sessid]['relevanceStatus']['G' . $gseq])) {
if (isset($_SESSION[$this->sessid]['relevanceStatus']['G' . $gseq])) {
$grel = $_SESSION[$this->sessid]['relevanceStatus']['G' . $gseq];
}
$qrel = 0; // Question relevance false by default since EM creation. Update it must create a major API update
if(isset($_SESSION[$this->sessid]['relevanceStatus'][$qid])) {
if (isset($_SESSION[$this->sessid]['relevanceStatus'][$qid])) {
$qrel = $_SESSION[$this->sessid]['relevanceStatus'][$qid];
}
$sqrel = 1; // true by default - only want false if a subquestion is really irrelevant
if(isset($_SESSION[$this->sessid]['relevanceStatus'][$rowdivid])) {
if (isset($_SESSION[$this->sessid]['relevanceStatus'][$rowdivid])) {
$sqrel = $_SESSION[$this->sessid]['relevanceStatus'][$rowdivid];
}
return ($grel && $qrel && $sqrel);
Expand All @@ -8822,7 +8833,7 @@ private function _GetVarAttribute($name, $attr, $default, $gseq, $qseq)
return 1;
}
return (isset($var[$attr])) ? $var[$attr] : $default;
// NB: No break needed
// NB: No break needed
case 'sgqa':
case 'mandatory':
case 'qid':
Expand Down

0 comments on commit dd7a902

Please sign in to comment.