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 Mar 27, 2018
2 parents 1a90f6b + 9330b1a commit bb479ea
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 196 deletions.
25 changes: 15 additions & 10 deletions application/controllers/admin/checkintegrity.php
Expand Up @@ -861,13 +861,11 @@ protected function checkGroupOrderDuplicates()
{
$sQuery = "
SELECT
sid,
COUNT(DISTINCT group_order) AS group_order,
COUNT(gid) AS gid
sid
FROM
{{groups}}
GROUP BY sid
HAVING group_order != gid";
HAVING COUNT(DISTINCT group_order) != COUNT(gid)";
$result = Yii::app()->db->createCommand($sQuery)->queryAll();
if (!empty($result)) {
foreach ($result as &$survey) {
Expand All @@ -891,15 +889,13 @@ protected function checkQuestionOrderDuplicates()
{
$sQuery = "
SELECT
q.gid,
q.sid,
q.parent_qid,
COUNT(DISTINCT q.question_order) AS question_order,
COUNT(q.qid) AS qid
q.gid,
q.parent_qid
FROM {{questions}} q
JOIN {{groups}} g ON q.gid = g.gid
GROUP BY sid, gid, parent_qid
HAVING question_order != qid;
GROUP BY q.sid, q.gid, q.parent_qid
HAVING COUNT(DISTINCT question_order) != COUNT(qid);
";
$result = Yii::app()->db->createCommand($sQuery)->queryAll();
if (!empty($result)) {
Expand All @@ -911,6 +907,14 @@ protected function checkQuestionOrderDuplicates()
'surveyid' => $info['sid'],
]
);
$info['viewGroupLink'] = Yii::app()->getController()->createUrl(
'admin/questiongroups',
[
'sa' => 'view',
'surveyid' => $info['sid'],
'gid' => $info['gid']
]
);
if ($info['parent_qid'] != 0) {
$info['questionSummaryLink'] = Yii::app()->getController()->createUrl(
'admin/questions',
Expand All @@ -921,6 +925,7 @@ protected function checkQuestionOrderDuplicates()
'qid' => $info['parent_qid']
]
);

}
}
}
Expand Down
5 changes: 2 additions & 3 deletions application/views/admin/checkintegrity/check_view.php
Expand Up @@ -169,13 +169,12 @@
} ?>

<?php if (isset($questionOrderDuplicates) && !empty($questionOrderDuplicates)): ?>
<li><?php eT("The following surveys have an errorneous question order. Please go to each question respectively, check the question order and save it."); ?>
<li><?php eT("The following surveys have an errorneous question order. Please go to each question and group respectively, check the question order and save it."); ?>
<ul>
<?php foreach ($questionOrderDuplicates as $info): ?>
<li>
SID: <a href="<?php echo $info['viewSurveyLink']; ?>"><?php echo $info['sid']; ?></a>
GID: <?php echo $info['sid']; ?>
QID: <?php echo $info['qid']; ?>
GID: <a href="<?php echo $info['viewGroupLink']; ?>"><?php echo $info['gid']; ?></a>
<?php if ($info['parent_qid'] != 0): ?>
Parent QID: <a href="<?php echo $info['questionSummaryLink']; ?>"><?php echo $info['parent_qid']; ?></a>
<?php endif; ?>
Expand Down

0 comments on commit bb479ea

Please sign in to comment.