Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 1, 2012
2 parents 8ee10d0 + 48b888b commit c14762f
Show file tree
Hide file tree
Showing 20 changed files with 2,565 additions and 2,538 deletions.
8 changes: 2 additions & 6 deletions application/controllers/admin/checkintegrity.php
Expand Up @@ -435,15 +435,11 @@ protected function _checkintegrity()
/**********************************************************************/
/* Check question attributes */
/**********************************************************************/
$question_attributes = Question_attributes::model()->findAll();
$question_attributes = Question_attributes::model()->findAllBySql('select qid from {{question_attributes}} where qid not in (select qid from {{questions}})');
if (Question_attributes::model()->hasErrors()) safeDie(Question_attributes::model()->getError());
foreach ($question_attributes as $question_attribute)
{
$iRowCount = Questions::model()->countByAttributes(array('qid' => $question_attribute['qid']));
if (Questions::model()->hasErrors()) safeDie(Questions::model()->getError());
if (!$iRowCount) {
$aDelete['questionattributes'][] = array('qid' => $question_attribute['qid']);
}
$aDelete['questionattributes'][] = array('qid' => $question_attribute['qid']);
} // foreach


Expand Down
6 changes: 2 additions & 4 deletions application/controllers/admin/dataentry.php
Expand Up @@ -2324,7 +2324,6 @@ public function view($surveyid, $lang=NULL)
unset($answers);
break;
case "M": //Multiple choice checkbox (Quite tricky really!)
// $qidattributes=getQuestionAttributeValues($deqrow['qid']);
if (trim($qidattributes['display_columns'])!='')
{
$dcols=$qidattributes['display_columns'];
Expand All @@ -2336,11 +2335,10 @@ public function view($surveyid, $lang=NULL)
$meaquery = "SELECT title, question FROM {{questions}} WHERE parent_qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' ORDER BY question_order";
$mearesult = dbExecuteAssoc($meaquery);


$cdata['dcols'] = $dcols;
$cdata['meacount'] = $meacount;
$cdata['mearesult'] = $mearesult->readAll();
$meacount = count($cdata['mearesult']);
$cdata['meacount'] = $meacount;
$cdata['dcols'] = $dcols;

break;
case "I": //Language Switch
Expand Down
30 changes: 11 additions & 19 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -1039,7 +1039,7 @@ function subval_sort($a, $subkey, $order)

$page = Yii::app()->request->getPost('page');
$limit = Yii::app()->request->getPost('rows');
$limit = isset($limit) ? $limit : 50; //Stop division by zero errors
$limit = isset($limit) ? $limit : 50; //Stop division by zero errors

$attid = ParticipantAttributeNames::model()->getVisibleAttributes();
$participantfields = array('participant_id', 'can_edit', 'firstname', 'lastname', 'email', 'blacklisted', 'survey', 'language', 'owner_uid');
Expand All @@ -1051,35 +1051,27 @@ function subval_sort($a, $subkey, $order)
//If super admin all the participants will be visible
if (Yii::app()->session['USER_RIGHT_SUPERADMIN'])
{
$records = Participants::model()->getParticipants($page, $limit);
$records = Participants::model()->getParticipants($page, $limit,$attid);
$aData = new stdClass;
$aData->page = $page;
$aData->records = Participants::model()->count();
$aData->total = ceil($aData->records / $limit);
$i = 0;
$sortablearray=array();
foreach ($records as $key => $row)
{
$username = User::model()->getName($row['owner_uid']); //for conversion of uid to human readable names
$sortablearray=array();
foreach ($records as $key => $row)
{
$surveycount = Participants::model()->getSurveyCount($row['participant_id']);
$sortablearray[$i] = array($row['participant_id'], "true", $row['firstname'], $row['lastname'], $row['email'], $row['blacklisted'], $surveycount, $row['language'], $username[0]['full_name']); // since it's the admin he has access to all editing on the participants inspite of what can_edit option is
foreach ($attid as $iAttributeId)
$sortablearray[$i] = array($row['participant_id'], "true", $row['firstname'], $row['lastname'], $row['email'], $row['blacklisted'], $surveycount, $row['language'], $row['ownername']); // since it's the admin he has access to all editing on the participants inspite of what can_edit option is
unset($row['participant_id'], $row['firstname'], $row['lastname'], $row['email'], $row['blacklisted'], $row['language'],$row['ownername'],$row['owner_uid']);
foreach($row as $key=>$attvalue)
{
$answer = ParticipantAttributeNames::model()->getAttributeValue($row['participant_id'], $iAttributeId['attribute_id']);
if (isset($answer['value']))
{
array_push($sortablearray[$i], $answer['value']);
}
else
{
array_push($sortablearray[$i], "");
}
}
array_push($sortablearray[$i], $attvalue);
}
$i++;
}

$indexsort = array_search(Yii::app()->request->getPost('sidx'), $participantfields);
if(!empty($sortablearray)) {
if(!empty($sortablearray)) {
$sortedarray = subval_sort($sortablearray, $indexsort, Yii::app()->request->getPost('sord'));
$i = 0;
$count = count($sortedarray[0]);
Expand Down

0 comments on commit c14762f

Please sign in to comment.