Skip to content

Commit

Permalink
Dev Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	application/controllers/admin/responses.php
#	application/models/Response.php
  • Loading branch information
c-schmitz committed Feb 27, 2018
2 parents 360e585 + 98762a4 commit 628349b
Show file tree
Hide file tree
Showing 35 changed files with 3,319 additions and 3,370 deletions.
3 changes: 2 additions & 1 deletion application/controllers/admin/responses.php
Expand Up @@ -281,6 +281,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '')
$answervalue = "Y";
}
} else {
// File upload question type.
if (isset($fnames[$i]['type']) && $fnames[$i]['type'] == Question::QT_VERTICAL_FILE_UPLOAD) {
$index = $fnames[$i]['index'];
$metadata = $fnames[$i]['metadata'];
Expand All @@ -302,7 +303,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '')
}
$aData['bHasFile'] = true;
} else {
$answervalue = "";
$answervalue = "";
}
} else {
$answervalue = htmlspecialchars(strip_tags(stripJavaScript(getExtendedAnswer($iSurveyID, $fnames[$i][0], $iIdrow[$fnames[$i][0]], $sBrowseLanguage))), ENT_QUOTES);
Expand Down
2 changes: 1 addition & 1 deletion application/core/Survey_Common_Action.php
Expand Up @@ -428,7 +428,7 @@ public function _showadminmenu($aData)
$not = new UniqueNotification(array(
'user_id' => App()->user->id,
'importance' => Notification::HIGH_IMPORTANCE,
'title' => 'Password warning',
'title' => gT('Password warning'),
'message' => '<span class="fa fa-exclamation-circle text-warning"></span>&nbsp;'.
gT("Warning: You are still using the default password ('password'). Please change your password and re-login again.")
));
Expand Down
47 changes: 45 additions & 2 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -383,7 +383,9 @@ public function run($surveyid, $args)

// easier to understand for survey maker
$aGroup['aQuestions'][$qid]['qid'] = $qa[4];
$aGroup['aQuestions'][$qid]['gid'] = $qinfo['info']['gid'];
$aGroup['aQuestions'][$qid]['code'] = $qa[5];
$aGroup['aQuestions'][$qid]['type'] = $qinfo['info']['type'];
$aGroup['aQuestions'][$qid]['number'] = $qa[0]['number'];
$aGroup['aQuestions'][$qid]['text'] = LimeExpressionManager::ProcessString($qa[0]['text'], $qa[4], $aStandardsReplacementFields, 3, 1, false, true, false);
$aGroup['aQuestions'][$qid]['SGQ'] = $qa[7];
Expand All @@ -395,6 +397,7 @@ public function run($surveyid, $args)
$aGroup['aQuestions'][$qid]['answer'] = LimeExpressionManager::ProcessString($qa[1], $qa[4], null, 3, 1, false, true, false);
$aGroup['aQuestions'][$qid]['help']['show'] = (flattenText($lemQuestionInfo['info']['help'], true, true) != '');
$aGroup['aQuestions'][$qid]['help']['text'] = LimeExpressionManager::ProcessString($lemQuestionInfo['info']['help'], $qa[4], null, 3, 1, false, true, false);
$aGroup['aQuestions'][$qid] = $this->doBeforeQuestionRenderEvent($aGroup['aQuestions'][$qid]);
}
$aGroup['show_last_group'] = $aGroup['show_last_answer'] = false;
$aGroup['lastgroup'] = $aGroup['lastanswer'] = '';
Expand Down Expand Up @@ -1328,10 +1331,10 @@ public static function getQuestionReplacement($aQuestionQanda)
$aSurveyinfo = getSurveyInfo($iSurveyId, App()->getLanguage());
// Check global setting to see if survey level setting should be applied
if ($showqnumcode_global_ == 'choose') {
// Use survey level settings
// Use survey level settings
$showqnumcode_ = $aSurveyinfo['showqnumcode']; //B, N, C, or X
} else {
// Use global setting
// Use global setting
$showqnumcode_ = $showqnumcode_global_; //both, number, code, or none
}

Expand Down Expand Up @@ -1806,4 +1809,44 @@ private function fixMaxStep()
}
}

/**
* Apply the plugin even beforeQuestionRender to
* question data.
*
* @see https://manual.limesurvey.org/BeforeQuestionRender
*
* @param array $data Question data
* @return array Question data modified by plugin
*/
protected function doBeforeQuestionRenderEvent($data)
{
$event = new PluginEvent('beforeQuestionRender');
$event->set('surveyId', $this->iSurveyid);
$event->set('type', $data['type']);
$event->set('code', $data['code']);
$event->set('qid', $data['qid']);
$event->set('gid', $data['gid']);
$event->set('text', $data['text']);
$event->set('input_error_class', $data['input_error_class']);
$event->set('answers', $data['answer']); // NB: "answers" in plugin, "answer" in $data.
$event->set('help', $data['help']['text']);
$event->set('man_message', $data['man_message']);
$event->set('valid_message', $data['valid_message']);
$event->set('file_valid_message', $data['file_valid_message']);
//$event->set('aHtmlOptions', $aHtmlOptions); // TODO

App()->getPluginManager()->dispatchEvent($event);

$data['text'] = $event->get('text');
$data['mandatory'] = $event->get('mandatory',$data['mandatory']);
$data['input_error_class'] = $event->get('input_error_class');
$data['valid_message'] = $event->get('valid_message');
$data['file_valid_message'] = $event->get('file_valid_message');
$data['man_message'] = $event->get('man_message');
$data['answer'] = $event->get('answers');
$data['help']['text'] = $event->get('help');
$data['help']['show'] = flattenText($data['help']['text'], true, true) != '';

return $data;
}
}
14 changes: 12 additions & 2 deletions application/models/Response.php
Expand Up @@ -39,11 +39,21 @@ public static function create($surveyId, $scenario = 'insert')
/**
* Get all files related to this response and (optionally) question ID.
*
* @param int $qid
* @return array
*/
public function getFiles()
public function getFiles($qid = null)
{
$questions = Question::model()->findAllByAttributes(array('sid' => $this->dynamicId, 'type' => Question::QT_VERTICAL_FILE_UPLOAD));
$survey = Survey::model()->findByPk($this->dynamicId);
$conditions = [
'sid' => $this->dynamicId,
'type' => Question::QT_VERTICAL_FILE_UPLOAD,
'language'=>$survey->language
];
if ($qid !== null) {
$conditions['qid'] = $qid;
}
$questions = Question::model()->findAllByAttributes($conditions);
$files = array();
foreach ($questions as $question) {
$field = $question->sid.'X'.$question->gid.'X'.$question->qid;
Expand Down
18 changes: 9 additions & 9 deletions application/models/SurveysGroups.php
Expand Up @@ -65,16 +65,16 @@ public function relations()
public function attributeLabels()
{
return array(
'gsid' => gT('ID'),
'name' => gT('Name'),
'title' => 'Title',
'gsid' => gT('ID'),
'name' => gT('Name'),
'title' => gT('Title'),
'description' => gT('Description'),
'sortorder' => gT('Sort order'),
'owner_uid' => gT('Owner UID'),
'parent_id' => gT('Parent group'),
'created' => gT('Created on'),
'modified' => gT('Modified on'),
'created_by' => gT('Created by'),
'sortorder' => gT('Sort order'),
'owner_uid' => gT('Owner UID'),
'parent_id' => gT('Parent group'),
'created' => gT('Created on'),
'modified' => gT('Modified on'),
'created_by' => gT('Created by'),
);
}

Expand Down
22 changes: 22 additions & 0 deletions application/models/User.php
Expand Up @@ -109,6 +109,21 @@ public function getSurveysCreated()
return $noofsurveys;
}

/**
* @return string
*/
public function getDateFormat()
{
$dateFormat = getDateFormatData(Yii::app()->session['dateformat']);
return $dateFormat['phpdate'];
}

public function getFormattedDateCreated()
{
$dateCreated = $this->created;
$date = new DateTime($dateCreated);
return $date->format($this->dateFormat);
}
/**
* Returns onetime password
*
Expand Down Expand Up @@ -458,6 +473,13 @@ public function getColums()
"name" =>"parentUserName",
"header" => gT("Created by"),
);

$cols[] = array(
"name" =>"created",
"header" => gT("Created on"),
"value" => '$data->formattedDateCreated',

);
return $cols;
}

Expand Down

0 comments on commit 628349b

Please sign in to comment.