Skip to content

Commit

Permalink
New feature: Check for group sort order duplicates in data integrity …
Browse files Browse the repository at this point in the history
…check
  • Loading branch information
olleharstedt committed Mar 9, 2018
1 parent 99092dc commit e2603a3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
29 changes: 28 additions & 1 deletion application/controllers/admin/checkintegrity.php
Expand Up @@ -458,7 +458,7 @@ protected function _checkintegrity()
$aDelete = array();
foreach ($aConditions as $condition) {
if ($condition['cqid'] != 0) {
// skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
// skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
if (!array_key_exists($condition['cqid'], $okQuestion)) {
$iRowCount = Question::model()->countByAttributes(array('qid' => $condition['cqid']));
if (Question::model()->hasErrors()) {
Expand Down Expand Up @@ -821,6 +821,33 @@ protected function _checkintegrity()
}
}

/**********************************************************************/
/* Check group sort order duplicates */
/**********************************************************************/
$sQuery = "
SELECT
sid,
COUNT(DISTINCT group_order) AS group_order,
COUNT(gid) AS gid
FROM
lime_groups
GROUP BY sid
HAVING group_order != gid";
$result = Yii::app()->db->createCommand($sQuery)->queryAll();
if (!empty($result)) {
foreach ($result as &$survey) {
$survey['organizerLink'] = Yii::app()->getController()->createUrl(
'admin/survey',
[
'sa' => 'organize',
'surveyid' => $survey['sid'],
]
);
}
$aDelete['groupOrderDuplicates'] = $result;
}
unset($survey); // &$survey escapes scope (lol php).

/**********************************************************************/
/* CHECK CPDB SURVEY_LINKS TABLE FOR REDUNDENT Survey participants tableS */
/**********************************************************************/
Expand Down
13 changes: 13 additions & 0 deletions application/views/admin/checkintegrity/check_view.php
Expand Up @@ -186,6 +186,19 @@
<li><?php eT("All groups meet consistency standards."); ?></li><?php
} ?>

<?php if (isset($groupOrderDuplicates)): ?>
<li><?php eT("The following surveys have duplicate group sort orders. Please go to each survey respectively and double check the organization of the survey."); ?>
<ul>
<?php foreach ($groupOrderDuplicates as $info): ?>
<li>
SID: <a href="<?php echo $info['organizerLink']; ?>"><?php echo $info['sid']; ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<li><?php eT("No duplicated group sort order detected."); ?></li>
<?php endif; ?>

<?php
if (isset($orphansurveytables))
{?>
Expand Down

2 comments on commit e2603a3

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More a fix than a feature, no ?

@olleharstedt
Copy link
Collaborator Author

@olleharstedt olleharstedt commented on e2603a3 Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe. Always hard to know.

Please sign in to comment.