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:
@@ -238,16 +238,26 @@ if ($questionnaire_id)
|
||||
{
|
||||
//limesurvey quotas for this question
|
||||
$quotas = (get_limesurvey_quota_info($r['id']));
|
||||
$sqlq = array();
|
||||
$cob = array();
|
||||
|
||||
foreach ($quotas as $q)
|
||||
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)." "."
|
||||
WHERE ".implode(' AND ',$cob)." "."
|
||||
AND submitdate IS NOT NULL
|
||||
AND s.token = c.token";
|
||||
|
||||
@@ -258,6 +268,7 @@ if ($questionnaire_id)
|
||||
|
||||
$report[] = array("strata" => "<a href='" . LIME_URL . "/admin/admin.php?action=quotas&sid={$r['sid']}"a_id={$r['id']}&subaction=quota_editquota'>" . $r['name'] . "</a>", "quota" => $r['qlimit'], "completions" => $completions, "perc" => $perc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// At the end - > the entire sample
|
||||
|
||||
@@ -441,13 +441,28 @@ function get_limesurvey_quota_info($lime_quota_id)
|
||||
|
||||
$ret = array();
|
||||
|
||||
$sql = "SELECT q.qid
|
||||
FROM ".LIME_PREFIX."quota_members as q, ".LIME_PREFIX."surveys as s
|
||||
WHERE q.quota_id='$lime_quota_id'
|
||||
AND s.sid = q.sid
|
||||
GROUP BY q.qid";
|
||||
|
||||
$rsq = $db->GetAll($sql);
|
||||
|
||||
foreach ($rsq as $q)
|
||||
{
|
||||
$qid = $q['qid'];
|
||||
|
||||
$sql = "SELECT q.*,s.language
|
||||
FROM ".LIME_PREFIX."quota_members as q, ".LIME_PREFIX."surveys as s
|
||||
WHERE q.quota_id='$lime_quota_id'
|
||||
AND s.sid = q.sid";
|
||||
AND s.sid = q.sid
|
||||
AND q.qid = $qid";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$r2 = array();
|
||||
|
||||
foreach($rs as $quota_entry)
|
||||
{
|
||||
$lime_qid = $quota_entry['qid'];
|
||||
@@ -489,9 +504,11 @@ function get_limesurvey_quota_info($lime_quota_id)
|
||||
}
|
||||
|
||||
|
||||
$ret[] = array('code' => $quota_entry['code'], 'value' => $value, 'qid' => $quota_entry['qid'], 'fieldname' => $fieldnames);
|
||||
$r2[] = array('code' => $quota_entry['code'], 'value' => $value, 'qid' => $quota_entry['qid'], 'fieldname' => $fieldnames);
|
||||
}
|
||||
|
||||
$ret[$qid] = $r2;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user