mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Allow for single row quotas to be updated on editing
This commit is contained in:
@@ -178,13 +178,12 @@ if ($questionnaire_id)
|
||||
$report[] = array("strata" => T_("Total sample"), "quota" => $drawn + $remain, "sample" => $drawn + $remain, "sampleused" => $drawn, "sampleremain" => $remain, "completions" => $completions, "perc" => ROUND(($completions / ($drawn + $remain)) * 100,2));
|
||||
|
||||
//a. (Standard quota) Monitor outcomes of questions in completed questionnaires, and exclude selected sample records when completion limit is reached
|
||||
//b. (Replicate quota) Exclude selected sample records (where lime_sgqa == -1)
|
||||
$sql = "SELECT qsq.questionnaire_sample_quota_row_id,qsqr_question.lime_sgqa,completions,quota_reached,lime_sid,qsq.description,current_completions, priority, autoprioritise
|
||||
FROM questionnaire_sample_quota_row as qsq, questionnaire as q, qsqr_question
|
||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||
//b. (Replicate quota) Exclude selected sample records (where no qsqr_question rows)
|
||||
$sql = "SELECT qsq.questionnaire_sample_quota_row_id,completions,quota_reached,lime_sid,qsq.description,current_completions, priority, autoprioritise
|
||||
FROM questionnaire_sample_quota_row as qsq, questionnaire as q
|
||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||
AND qsq.sample_import_id = '$sample_import_id'
|
||||
AND q.questionnaire_id = '$questionnaire_id'
|
||||
AND qsqr_question.questionnaire_sample_quota_row_id = qsq.questionnaire_sample_quota_row_id";
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
@@ -198,15 +197,8 @@ if ($questionnaire_id)
|
||||
$qsqr = $v['questionnaire_sample_quota_row_id'];
|
||||
|
||||
|
||||
if ($v['lime_sgqa'] == -1)
|
||||
{
|
||||
$v['completions'] = "";
|
||||
$perc = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$perc = ($v['completions'] <= 0 ? 0 : ROUND(($completions / ($v['completions'])) * 100,2));
|
||||
}
|
||||
$perc = ($v['completions'] <= 0 ? 0 : ROUND(($completions / ($v['completions'])) * 100,2));
|
||||
|
||||
|
||||
//We need to calc Sample size, Sample drawn, Sample remain
|
||||
$sql = "SELECT (c.sample_id is not null) as type, count(*) as count
|
||||
@@ -242,7 +234,7 @@ if ($questionnaire_id)
|
||||
if ($r['type'] == 0) $remain = $r['count'];
|
||||
}
|
||||
|
||||
if ($completions < $v['completions'] || $v['lime_sgqa'] == -1) //if completions less than the quota, allow for closing/opening
|
||||
if ($completions < $v['completions']) //if completions less than the quota, allow for closing/opening
|
||||
{
|
||||
if ($v['quota_reached'] == 1)
|
||||
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota=$qsqr&open=open'>" . T_("closed") . "</a>";
|
||||
|
||||
@@ -72,12 +72,17 @@ global $db;
|
||||
|
||||
if (isset($_GET['delete']))
|
||||
{
|
||||
$qsqri = bigintval($_GET['qsqri']);
|
||||
|
||||
if (isset($_GET['qsqrqi']))
|
||||
{
|
||||
$qsqrqi = bigintval($_GET['qsqrqi']);
|
||||
$sql = "DELETE FROM qsqr_question
|
||||
WHERE qsqr_question_id = $qsqrqi";
|
||||
$db->Execute($sql);
|
||||
|
||||
//Make sure to calculate on the spot
|
||||
update_single_row_quota($qsqri);
|
||||
}
|
||||
if (isset($_GET['qsqrsi']))
|
||||
{
|
||||
@@ -85,6 +90,9 @@ if (isset($_GET['delete']))
|
||||
$sql = "DELETE FROM qsqr_sample
|
||||
WHERE qsqr_sample_id = $qsqrsi";
|
||||
$db->Execute($sql);
|
||||
|
||||
//Make sure to calculate on the spot
|
||||
update_single_row_quota($qsqri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +111,12 @@ if (isset($_POST['add_quota']))
|
||||
$sql = "INSERT INTO questionnaire_sample_quota_row(questionnaire_id, sample_import_id, completions, description, priority, autoprioritise)
|
||||
VALUES ($questionnaire_id, $sample_import_id, $completions, $description, $priority, $autoprioritise)";
|
||||
|
||||
$db->Execute($sql);
|
||||
$db->Execute($sql);
|
||||
|
||||
$qq = $db->Insert_ID();
|
||||
|
||||
//Make sure to calculate on the spot
|
||||
//update_quotas($questionnaire_id);
|
||||
update_single_row_quota($qq);
|
||||
}
|
||||
|
||||
if (isset($_POST['edit_quota']))
|
||||
@@ -129,8 +139,9 @@ if (isset($_POST['edit_quota']))
|
||||
|
||||
$_GET['qsqri'] = $qsqri;
|
||||
$_GET['edit'] = "edit";
|
||||
|
||||
//Make sure to calculate on the spot
|
||||
//update_quotas($questionnaire_id);
|
||||
update_single_row_quota($qsqri);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +176,9 @@ if (isset($_GET['qsqri']) & isset($_GET['edit']))
|
||||
VALUES ($qsqri,$exvar,$exval,$comparison)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
//Make sure to calculate on the spot
|
||||
update_single_row_quota($qsqri);
|
||||
}
|
||||
|
||||
if (isset($_POST['addq']))
|
||||
@@ -177,6 +191,9 @@ if (isset($_GET['qsqri']) & isset($_GET['edit']))
|
||||
VALUES ($qsqri,$sgqa,$value,$comparison)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
//Make sure to calculate on the spot
|
||||
update_single_row_quota($qsqri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user