mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Fixes lp:1338395 - Quotas being incremented in samples that have not yet been accessed
This commit is contained in:
@@ -313,20 +313,21 @@ function limesurvey_quota_replicate_completions($lime_sid,$questionnaire_id,$sam
|
|||||||
* @param string $lime_sgqa The limesurvey SGQA
|
* @param string $lime_sgqa The limesurvey SGQA
|
||||||
* @param int $lime_sid The limesurvey survey id
|
* @param int $lime_sid The limesurvey survey id
|
||||||
* @param int $case_id The case id
|
* @param int $case_id The case id
|
||||||
* @param int $sample_import_id The sample import ID
|
|
||||||
* @param string $value The value to compare
|
* @param string $value The value to compare
|
||||||
* @param string $comparison The type of comparison
|
* @param string $comparison The type of comparison
|
||||||
|
* @param int $sample_import_id The sample import ID
|
||||||
|
*
|
||||||
* @return bool|int False if failed, otherwise 1 if matched, 0 if doesn't
|
* @return bool|int False if failed, otherwise 1 if matched, 0 if doesn't
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function limesurvey_quota_match($lime_sgqa,$lime_sid,$case_id,$value,$comparison)
|
function limesurvey_quota_match($lime_sgqa,$lime_sid,$case_id,$value,$comparison,$sample_import_id)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$sql = "SELECT count(*) as c
|
$sql = "SELECT count(*) as c
|
||||||
FROM " . LIME_PREFIX . "survey_$lime_sid as s
|
FROM " . LIME_PREFIX . "survey_$lime_sid as s
|
||||||
JOIN `case` as c ON (c.case_id = '$case_id')
|
JOIN `case` as c ON (c.case_id = '$case_id')
|
||||||
JOIN `sample` as sam ON (c.sample_id = sam.sample_id)
|
JOIN `sample` as sam ON (c.sample_id = sam.sample_id and sam.import_id = $sample_import_id)
|
||||||
WHERE s.token = c.token
|
WHERE s.token = c.token
|
||||||
AND s.`$lime_sgqa` $comparison '$value'";
|
AND s.`$lime_sgqa` $comparison '$value'";
|
||||||
|
|
||||||
@@ -345,19 +346,20 @@ function limesurvey_quota_match($lime_sgqa,$lime_sid,$case_id,$value,$comparison
|
|||||||
* @param int $case_id The case id
|
* @param int $case_id The case id
|
||||||
* @param string $val The sample value to compare
|
* @param string $val The sample value to compare
|
||||||
* @param string $var The sample variable to compare
|
* @param string $var The sample variable to compare
|
||||||
|
* @param int $sample_import_id The sample import id we are looking at
|
||||||
*
|
*
|
||||||
* @return bool|int False if failed, otherwise 1 if matched, 0 if doesn't
|
* @return bool|int False if failed, otherwise 1 if matched, 0 if doesn't
|
||||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||||
* @since 2012-04-30
|
* @since 2012-04-30
|
||||||
*/
|
*/
|
||||||
function limesurvey_quota_replicate_match($lime_sid,$case_id,$val,$var)
|
function limesurvey_quota_replicate_match($lime_sid,$case_id,$val,$var,$import_id)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$sql = "SELECT count(*) as c
|
$sql = "SELECT count(*) as c
|
||||||
FROM " . LIME_PREFIX . "survey_$lime_sid as s
|
FROM " . LIME_PREFIX . "survey_$lime_sid as s
|
||||||
JOIN `case` as c ON (c.case_id = '$case_id')
|
JOIN `case` as c ON (c.case_id = '$case_id')
|
||||||
JOIN `sample` as sam ON (c.sample_id = sam.sample_id)
|
JOIN `sample` as sam ON (c.sample_id = sam.sample_id and sam.import_id = $sample_import_id)
|
||||||
JOIN `sample_var` as sv ON (sv.sample_id = sam.sample_id AND sv.var LIKE '$var' AND sv.val LIKE '$val')
|
JOIN `sample_var` as sv ON (sv.sample_id = sam.sample_id AND sv.var LIKE '$var' AND sv.val LIKE '$val')
|
||||||
WHERE s.token = c.token";
|
WHERE s.token = c.token";
|
||||||
|
|
||||||
|
|||||||
@@ -1685,9 +1685,9 @@ function update_row_quota($questionnaire_id,$case_id = false)
|
|||||||
if ($case_id != false)
|
if ($case_id != false)
|
||||||
{
|
{
|
||||||
if ($r['lime_sgqa'] == -2)
|
if ($r['lime_sgqa'] == -2)
|
||||||
$match = limesurvey_quota_replicate_match($r['lime_sid'],$case_id,$r['exclude_val'],$r['exclude_var']);
|
$match = limesurvey_quota_replicate_match($r['lime_sid'],$case_id,$r['exclude_val'],$r['exclude_var'],$r['sample_import_id']);
|
||||||
else
|
else
|
||||||
$match = limesurvey_quota_match($r['lime_sgqa'],$r['lime_sid'],$case_id,$r['value'],$r['comparison']);
|
$match = limesurvey_quota_match($r['lime_sgqa'],$r['lime_sid'],$case_id,$r['value'],$r['comparison'],$r['sample_import_id']);
|
||||||
|
|
||||||
if ($match == 1)
|
if ($match == 1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user