From 12ee63eb85fb63d62667494c6c587a36ee23c210 Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Wed, 28 Jan 2015 13:00:50 +1100 Subject: [PATCH] Fixes Bug lp:141380 System sort process fails when quotas enabled and limesurvey instrument de-activated --- functions/functions.limesurvey.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/functions/functions.limesurvey.php b/functions/functions.limesurvey.php index 200c7544..71682d03 100644 --- a/functions/functions.limesurvey.php +++ b/functions/functions.limesurvey.php @@ -291,6 +291,16 @@ function limesurvey_quota_replicate_completions($lime_sid,$questionnaire_id,$sam { global $db; + $sql = "SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = 'quexs' + AND table_name = '" . LIME_PREFIX . "survey_$lime_sid'"; + + $rs = $db->GetOne($sql); + + if ($rs != 1) + return false; + $sql = "SELECT count(*) as c FROM " . LIME_PREFIX . "survey_$lime_sid as s JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id') @@ -390,6 +400,16 @@ function limesurvey_quota_completions($lime_sgqa,$lime_sid,$questionnaire_id,$sa { global $db; + $sql = "SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = 'quexs' + AND table_name = '" . LIME_PREFIX . "survey_$lime_sid'"; + + $rs = $db->GetOne($sql); + + if ($rs != 1) + return false; + $sql = "SELECT count(*) as c FROM " . LIME_PREFIX . "survey_$lime_sid as s JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id')