2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Fixes lp:1510368 Lime quota with more than one option in list doesn't display in queXS quota report

This commit is contained in:
Adam Zammit
2015-11-20 14:01:34 +11:00
parent 1041e73849
commit a055129674
2 changed files with 84 additions and 56 deletions

View File

@@ -238,25 +238,36 @@ if ($questionnaire_id)
{
//limesurvey quotas for this question
$quotas = (get_limesurvey_quota_info($r['id']));
$sqlq = array();
$cob = array();
foreach ($quotas as $q)
$sqlq[] = "s." . $q['fieldname'] . " = '" . $q['value'] . "'";
foreach ($quotas as $qr)
{
$sqlq = array();
foreach($qr as $qid => $q)
{
$sqlq[] = "s." . $q['fieldname'] . " = '" . $q['value'] . "'";
}
$cob[] = "( " . implode(' OR ', $sqlq) . " )";
}
if (!empty($cob))
{
$sql = "SELECT COUNT(id) as count
FROM ".LIME_PREFIX."survey_{$r['sid']} as s
JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id')
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
WHERE ".implode(' AND ',$sqlq)." "."
AND submitdate IS NOT NULL
AND s.token = c.token";
$sql = "SELECT COUNT(id) as count
FROM ".LIME_PREFIX."survey_{$r['sid']} as s
JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id')
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
WHERE ".implode(' AND ',$cob)." "."
AND submitdate IS NOT NULL
AND s.token = c.token";
$rs = $db->GetRow($sql);
$rs = $db->GetRow($sql);
$completions = $rs['count'];
$perc = ROUND(($completions / $r['qlimit']) * 100,2);
$report[] = array("strata" => "<a href='" . LIME_URL . "/admin/admin.php?action=quotas&sid={$r['sid']}&quota_id={$r['id']}&subaction=quota_editquota'>" . $r['name'] . "</a>", "quota" => $r['qlimit'], "completions" => $completions, "perc" => $perc);
$completions = $rs['count'];
$perc = ROUND(($completions / $r['qlimit']) * 100,2);
$report[] = array("strata" => "<a href='" . LIME_URL . "/admin/admin.php?action=quotas&sid={$r['sid']}&quota_id={$r['id']}&subaction=quota_editquota'>" . $r['name'] . "</a>", "quota" => $r['qlimit'], "completions" => $completions, "perc" => $perc);
}
}