From c9ee8279c7a41e7c991dbbf69d36cf6c4b32fc6d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 21 Dec 2015 20:22:21 +0300 Subject: [PATCH] fix lp:1528293 - fix and translated outcomes descriptions, added 'outcome id' to output, fix lp: 1527201 - output to csv in dataoutput.php --- admin/dataoutput.php | 10 ++++----- include/limesurvey/admin/exportresults.php | 26 +++++++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/admin/dataoutput.php b/admin/dataoutput.php index a1e7cb32..2d43c022 100644 --- a/admin/dataoutput.php +++ b/admin/dataoutput.php @@ -85,19 +85,19 @@ if (isset($_GET['key']) || isset($_GET['sample'])) echo("token,".T_("Case ID").""); foreach($svars as $s) { - echo("," . $s['value']); + echo("," . str_replace(","," ",$s['value'])); } if (isset($_GET['sample'])) { - echo(",".T_("Current Outcome").",".T_("Number of call attempts").",".T_("Number of calls").",".T_("Case notes").",".T_("Total interview time over all calls (mins)").",".T_("Interview time for last call (mins)").",".T_("Last number dialled").",".T_("DATE/TIME Last number dialled").",".T_("Operator username for last call").",".T_("Shift report").", AAPOR"); + echo(",".T_("Outcome ID").",".T_("Current Outcome").",".T_("Number of call attempts").",".T_("Number of calls").",".T_("Case notes").",".T_("Total interview time over all calls (mins)").",".T_("Interview time for last call (mins)").",".T_("Last number dialled").",".T_("DATE/TIME Last number dialled").",".T_("Operator username for last call").",".T_("Shift report").", AAPOR"); } echo("\n"); $sql = "SELECT c.token,c.case_id "; - if (isset($_GET['sample'])) $sql .= ", o.description, + if (isset($_GET['sample'])) $sql .= ", o.outcome_id, o.description, (SELECT COUNT(ca.call_attempt_id) FROM `call_attempt` as ca WHERE ca.case_id = c.case_id ) as callattempts, (SELECT COUNT(cl.call_id) FROM `call` as cl WHERE cl.case_id = c.case_id ) as calls, (SELECT GROUP_CONCAT(cn1.note SEPARATOR '|') FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes, @@ -149,8 +149,8 @@ if (isset($_GET['key']) || isset($_GET['sample'])) } if (isset($_GET['sample'])) { - $l['description'] = T_($l['description']); - echo "," . str_replace(","," ",$l['description']) . "," .$l['callattempts']."," .$l['calls']."," .$l['casenotes'].",".$l['interviewtimec'].",".$l['interviewtimel'].",".$l['lastnumber'].",".$l['lastcallstart'].",".$l['operatoru'].",".$l['shiftr'].",". $l['aapor_id']; + if(!empty($l['description'])) $l['description'] = T_($l['description']); + echo ",".$l['outcome_id'].",". str_replace(","," ",$l['description']).",".$l['callattempts'].",".$l['calls']."," .str_replace(","," ",$l['casenotes']).",".$l['interviewtimec'].",".$l['interviewtimel'].",".$l['lastnumber'].",".$l['lastcallstart'].",".$l['operatoru'].",".$l['shiftr'].",". $l['aapor_id']; } echo "\n"; } diff --git a/include/limesurvey/admin/exportresults.php b/include/limesurvey/admin/exportresults.php index 06a38897..e71d7e1a 100644 --- a/include/limesurvey/admin/exportresults.php +++ b/include/limesurvey/admin/exportresults.php @@ -256,6 +256,7 @@ $quexsfilterstate = questionnaireSampleFilterstate(); $exportoutput .= "\n" ."\n" + ."\n" ."\n" ."\n" ."\n" @@ -280,7 +281,7 @@ $quexsfilterstate = questionnaireSampleFilterstate(); foreach ($queXSrs as $attr_name=>$val) { - $exportoutput .= "\n"; + $exportoutput .= "\n"; } $exportoutput .= "\n"; } @@ -435,6 +436,12 @@ if ($tokenTableExists && $thissurvey['anonymized']=='N' && isset($_POST['attribu $dquery .= ", (SELECT c4.case_id FROM `case` as c4 WHERE c4.token = {$dbprefix}survey_$surveyid.token) as caseid "; + } + if (in_array('outcomeid',$_POST['attribute_select'])) + { + $dquery .= ", (SELECT c5.current_outcome_id + FROM `case` as c5 + WHERE c5.token = {$dbprefix}survey_$surveyid.token) as outcomeid "; } if (in_array('caseoutcome',$_POST['attribute_select'])) { @@ -643,11 +650,16 @@ for ($i=0; $i<$fieldcount; $i++) { if ($type == "csv") {$firstline .= "\"".T_("Case ID")."\"$separator";} else {$firstline .= T_("Case ID")."$separator";} + } + elseif ($fieldinfo == "outcomeid") + { + if ($type == "csv") {$firstline .= "\"".T_("Outcome ID")."\"$separator";} + else {$firstline .= T_("Outcome ID")."$separator";} } elseif ($fieldinfo == "caseoutcome") { if ($type == "csv") {$firstline .= "\"".T_("Case outcome")."\"$separator";} - else {$firstline .= T_("Case outcome")."$separator";} + else {$firstline .= T_("Case outcome")."$separator";} $caseoutcome_key = $i; } elseif ($fieldinfo == "email") { @@ -838,7 +850,7 @@ if ($answers == "short") //Nice and easy. Just dump the data straight $rowcounter=0; while ($drow = $dresult->FetchRow()) { - $drow=array_map('strip_tags_full',$drow); if (isset($drow['caseoutcome'])) $drow['caseoutcome'] = T_($drow['caseoutcome']); + $drow=array_map('strip_tags_full',$drow); if (isset($drow['caseoutcome']) && !empty($drow['caseoutcome'])) $drow['caseoutcome'] = T_($drow['caseoutcome']); if($convertyto1 == "Y") //Converts "Y" to "1" in export { @@ -921,6 +933,7 @@ elseif ($answers == "long") //chose complete answers while ($drow = $dresult->FetchRow()) { + if (isset($caseoutcome_key) && isset($drow[$caseoutcome_key]) && !empty($drow[$caseoutcome_key])) $drow[$caseoutcome_key] = T_($drow[$caseoutcome_key]); $rowcounter++; if ($type == "pdf") { @@ -942,7 +955,7 @@ elseif ($answers == "long") //chose complete answers $fqid=0; // By default fqid is set to zero $field=$dresult->FetchField($i); $fieldinfo=$field->name; - if ($fieldinfo != "startlanguage" && $fieldinfo != "id" && $fieldinfo != "datestamp" && $fieldinfo != "startdate" && $fieldinfo != "ipaddr" && $fieldinfo != "refurl" && $fieldinfo != "token" && $fieldinfo != "firstname" && $fieldinfo != "lastname" && $fieldinfo != "email" && (substr($fieldinfo,0,10)!="attribute_") && $fieldinfo != "completed" && $fieldinfo != "caseoutcome"&& $fieldinfo != "caseid" && $fieldinfo != "callattempts" && $fieldinfo != "messagesleft"&& $fieldinfo != "casenotes"&& $fieldinfo != "interviewtimec"&& $fieldinfo != "interviewtimel"&& $fieldinfo != "lastnumber"&& $fieldinfo != "operatoru"&& $fieldinfo != "shiftr") + if ($fieldinfo != "startlanguage" && $fieldinfo != "id" && $fieldinfo != "datestamp" && $fieldinfo != "startdate" && $fieldinfo != "ipaddr" && $fieldinfo != "refurl" && $fieldinfo != "token" && $fieldinfo != "firstname" && $fieldinfo != "lastname" && $fieldinfo != "email" && (substr($fieldinfo,0,10)!="attribute_") && $fieldinfo != "completed" && $fieldinfo != "outcomeid" && $fieldinfo != "caseoutcome"&& $fieldinfo != "caseid" && $fieldinfo != "callattempts" && $fieldinfo != "messagesleft"&& $fieldinfo != "casenotes"&& $fieldinfo != "interviewtimec"&& $fieldinfo != "interviewtimel"&& $fieldinfo != "lastnumber"&& $fieldinfo != "operatoru"&& $fieldinfo != "shiftr") { $fielddata=$fieldmap[$fieldinfo]; $fqid=$fielddata['qid']; @@ -966,7 +979,10 @@ elseif ($answers == "long") //chose complete answers case "caseid": $ftitle=T_("Case ID").":"; break; - case "caseoutcome": + case "outcomeid": + $ftitle=T_("Outcome ID").":"; + break; + case "caseoutcome": $ftitle=T_("Case outcome").":"; break; case "callattempts":