Skip to content

Commit

Permalink
Implement jqgrid at browse response table - by GCI participant Licker…
Browse files Browse the repository at this point in the history
… Nandor

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11572 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Dec 3, 2011
1 parent bc66800 commit 4648894
Show file tree
Hide file tree
Showing 8 changed files with 1,009 additions and 620 deletions.
1,065 changes: 686 additions & 379 deletions application/controllers/admin/browse.php

Large diffs are not rendered by default.

139 changes: 73 additions & 66 deletions application/controllers/admin/dataentry.php
Expand Up @@ -591,16 +591,20 @@ function import($surveyid)
* @param mixed $subaction
* @param mixed $id
* @param mixed $surveyid
* @param mixed $language
* @return
*/
function editdata($subaction,$id,$surveyid,$language)
{
$surveyid = sanitize_int($surveyid);
$id = sanitize_int($id);
if (!isset($sDataEntryLanguage))
{
$sDataEntryLanguage = GetBaseLanguageFromSurveyID($surveyid);
* @param mixed $language
* @return
*/
function editdata($subaction,$id,$surveyid,$language='')
{
if ($language == '') {
$language = GetBaseLanguageFromSurveyID($surveyid);
}

$surveyid = sanitize_int($surveyid);
$id = sanitize_int($id);
if (!isset($sDataEntryLanguage))
{
$sDataEntryLanguage = GetBaseLanguageFromSurveyID($surveyid);
}
$surveyinfo=getSurveyInfo($surveyid);

Expand Down Expand Up @@ -1196,14 +1200,13 @@ function editdata($subaction,$id,$surveyid,$language)
case "|": //FILE UPLOAD
$dataentryoutput .= "<table>\n";
if ($fname['aid']!=='filecount' && isset($idrow[$fname['fieldname'] . '_filecount']) && ($idrow[$fname['fieldname'] . '_filecount'] > 0))
{//file metadata
$metadata = json_decode($idrow[$fname['fieldname']], true);
$qAttributes = getQuestionAttributeValues($fname['qid']);

for ($i = 0; $i < $qAttributes['max_files'], isset($metadata[$i]); $i++)
{
if ($qAttributes['show_title'])
$dataentryoutput .= '<tr><td width="25%">Title </td><td><input type="text" class="'.$fname['fieldname'].'" id="'.$fname['fieldname'].'_title_'.$i .'" name="title" size=50 value="'.htmlspecialchars($metadata[$i]["title"]) .'" /></td></tr>';
{//file metadata
$metadata = json_decode($idrow[$fname['fieldname']], true);
$qAttributes = getQuestionAttributeValues($fname['qid']);
for ($i = 0; $i < $qAttributes['max_num_of_files'], isset($metadata[$i]); $i++)
{
if ($qAttributes['show_title'])
$dataentryoutput .= '<tr><td width="25%">Title </td><td><input type="text" class="'.$fname['fieldname'].'" id="'.$fname['fieldname'].'_title_'.$i .'" name="title" size=50 value="'.htmlspecialchars($metadata[$i]["title"]) .'" /></td></tr>';
if ($qAttributes['show_comment'])
$dataentryoutput .= '<tr><td width="25%">Comment </td><td><input type="text" class="'.$fname['fieldname'].'" id="'.$fname['fieldname'].'_comment_'.$i .'" name="comment" size=50 value="'.htmlspecialchars($metadata[$i]["comment"]) .'" /></td></tr>';

Expand Down Expand Up @@ -1949,13 +1952,13 @@ function insert()
$filecount = 0;

for ($i = 0; $filecount < count($phparray); $i++)
{
if ($_FILES[$fieldname."_file_".$i]['error'] != 4)
{
$target = $CI->config->item('uploaddir')."/surveys/". $thissurvey['sid'] ."/files/".sRandomChars(20);
$size = 0.001 * $_FILES[$fieldname."_file_".$i]['size'];
$name = rawurlencode($_FILES[$fieldname."_file_".$i]['name']);

{
if ($_FILES[$fieldname."_file_".$i]['error'] != 4)
{
$target = $this->config->item('uploaddir')."/surveys/". $thissurvey['sid'] ."/files/".sRandomChars(20);
$size = 0.001 * $_FILES[$fieldname."_file_".$i]['size'];
$name = rawurlencode($_FILES[$fieldname."_file_".$i]['name']);

if (move_uploaded_file($_FILES[$fieldname."_file_".$i]['tmp_name'], $target))
{
$phparray[$filecount]->filename = basename($target);
Expand Down Expand Up @@ -2163,17 +2166,17 @@ function insert()
* @param mixed $surveyid
* @param mixed $lang
* @return
*/
function view($surveyid,$lang=NULL)
{
$surveyid = sanitize_int($surveyid);
if(isset($lang)) $lang=sanitize_languagecode($urlParam);
self::_getAdminHeader();

if (bHasSurveyPermission($surveyid, 'responses','read'))
{
$clang = $this->limesurvey_lang;

*/
function view($surveyid,$lang=NULL)
{
$surveyid = sanitize_int($surveyid);
if(isset($lang)) $lang=sanitize_languagecode($urlParam);
self::_getAdminHeader();

if (bHasSurveyPermission($surveyid, 'responses', 'read'))
{
$clang = $this->limesurvey_lang;

$sDataEntryLanguage = GetBaseLanguageFromSurveyID($surveyid);
$surveyinfo=getSurveyInfo($surveyid);

Expand All @@ -2193,12 +2196,13 @@ function view($surveyid,$lang=NULL)
$blang = $this->limesurvey_lang; //new limesurvey_lang($lang);
$sDataEntryLanguage = $lang;
}

$langlistbox = languageDropdown($surveyid,$sDataEntryLanguage);
$thissurvey=getSurveyInfo($surveyid);
//This is the default, presenting a blank dataentry form
$fieldmap=createFieldMap($surveyid);
// PRESENT SURVEY DATAENTRY SCREEN

$langlistbox = languageDropdown($surveyid,$sDataEntryLanguage);
$thissurvey=getSurveyInfo($surveyid);

//This is the default, presenting a blank dataentry form
$fieldmap=createFieldMap($surveyid);
// PRESENT SURVEY DATAENTRY SCREEN
//$dataentryoutput .= $surveyoptions;
/**
$dataentryoutput .= "<div class='header ui-widget-header'>".$clang->gT("Data entry")."</div>\n";
Expand Down Expand Up @@ -2290,25 +2294,28 @@ function view($surveyid,$lang=NULL)

LimeExpressionManager::StartProcessingPage(false,true,true); // means that all variables are on the same page

$this->load->view("admin/dataentry/caption_view",$data);

$this->load->helper('database');


// SURVEY NAME AND DESCRIPTION TO GO HERE
$degquery = "SELECT * FROM ".$this->db->dbprefix."groups WHERE sid=$surveyid AND language='{$sDataEntryLanguage}' ORDER BY ".$this->db->dbprefix."groups.group_order";
$degresult = db_execute_assoc($degquery);
// GROUP NAME
$dataentryoutput = '';
foreach ($degresult->result_array() as $degrow)
$this->load->view("admin/dataentry/caption_view",$data);

$this->load->helper('database');
$this->load->helper('database');


// SURVEY NAME AND DESCRIPTION TO GO HERE
$degquery = "SELECT * FROM ".$this->db->dbprefix."groups WHERE sid=$surveyid AND language='{$sDataEntryLanguage}' ORDER BY ".$this->db->dbprefix."groups.group_order";
$degresult = db_execute_assoc($degquery);

// GROUP NAME
$dataentryoutput = '';
foreach ($degresult->result_array() as $degrow)
{
LimeExpressionManager::StartProcessingGroup($degrow['gid'],($thissurvey['anonymized']!="N"),$surveyid);

$deqquery = "SELECT * FROM ".$this->db->dbprefix."questions WHERE sid=$surveyid AND parent_qid=0 AND gid={$degrow['gid']} AND language='{$sDataEntryLanguage}'";
$deqresult = db_execute_assoc($deqquery);
$dataentryoutput .= "\t<tr>\n"
."<td colspan='3' align='center'><strong>".FlattenText($degrow['group_name'],true)."</strong></td>\n"
."\t</tr>\n";

$deqquery = "SELECT * FROM ".$this->db->dbprefix."questions WHERE sid=$surveyid AND parent_qid=0 AND gid={$degrow['gid']} AND language='{$sDataEntryLanguage}'";
$deqresult = db_execute_assoc($deqquery);

$dataentryoutput .= "\t<tr>\n"
."<td colspan='3' align='center'><strong>".FlattenText($degrow['group_name'],true)."</strong></td>\n"
."\t</tr>\n";
$gid = $degrow['gid'];

$dataentryoutput .= "\t<tr class='data-entry-separator'><td colspan='3'></td></tr>\n";
Expand Down Expand Up @@ -3574,13 +3581,13 @@ function saveshow(value)

}

self::_loadEndScripts();


self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));


}
self::_loadEndScripts();


self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));


}


}
15 changes: 8 additions & 7 deletions application/helpers/common_helper.php
Expand Up @@ -3176,13 +3176,14 @@ function getQuestionAttributeValues($qid, $type='')

if (isset($cache[$qid])) {
return $cache[$qid];
}
$CI->load->model('questions_model');
$result = $CI->questions_model->getSomeRecords(array('type','sid'),array('qid'=>$qid)) or safe_die("Error finding question attributes"); //Checked
$row=$result->row_array();
if ($row===false) // Question was deleted while running the survey
{
$cache[$qid]=false;
}
$CI->load->model('questions_model');
$result = $CI->questions_model->getSomeRecords(array('type','sid'),array('qid'=>$qid)) or safe_die("Error finding question attributes"); //Checked
$row=$result->row_array();

if ($row===false) // Question was deleted while running the survey
{
$cache[$qid]=false;
return false;
}
$type=$row['type'];
Expand Down
13 changes: 6 additions & 7 deletions application/helpers/qanda_helper.php
Expand Up @@ -5303,13 +5303,12 @@ function do_shortfreetext($ia)

if ($_SESSION[$ia[1]]) {$answer .= str_replace("\\", "", $_SESSION[$ia[1]]);}

$answer .= "</textarea>\n";
}
elseif((int)($aQuestionAttributes['location_mapservice'])!=0){

$mapservice = $aQuestionAttributes['location_mapservice'];
$currentLocation = $_SESSION[$ia[1]];
$currentLatLong = null;
$answer .= "</textarea>\n";
}
elseif((int)($aQuestionAttributes['location_mapservice'])!=0){
$mapservice = $aQuestionAttributes['location_mapservice'];
$currentLocation = $_SESSION[$ia[1]];
$currentLatLong = null;

$floatLat = 0;
$floatLng = 0;
Expand Down
119 changes: 97 additions & 22 deletions application/models/surveys_dynamic_model.php
Expand Up @@ -29,27 +29,102 @@ function getSomeRecords($fields,$iSurveyID,$condition=FALSE,$order=FALSE)
$this->db->order_by($order);
}
$data = $this->db->get('survey_'.$iSurveyID);

return $data;
}

function quotaCompletedCount($iSurveyID,$querycond)
{

return $data;
}

/**
* Get the records with ids from $iFrom to $iFrom + $iCount
* @param $iSurveyID ID of the survey
* @param $iFrom Beginning of the range
* @param $iCount Number of rows
* @param $sSortCol Sort the elements by this colum
* @param $sSortOrder Order of the sort
* @return mixed
*/
function getRecordsInRange($iSurveyID, $iFrom, $iCount, $sSortCol, $sSortOrder)
{
$this->db->order_by($sSortCol, $sSortOrder);
return $this->db->get('survey_'.$iSurveyID, $iCount, $iFrom);
}

function quotaCompletedCount($iSurveyID,$querycond)
{
//Used by get_quotaCompletedCount()
$querysel = "SELECT count(id) as count FROM ".db_table_name('survey_'.$iSurveyID)." WHERE ".implode(' AND ',$querycond)." "." AND submitdate IS NOT NULL";
return $this->db->query($querysel);
}

function insertRecords($iSurveyID,$data)
{
return $this->db->insert('survey_'.$iSurveyID, $data);
}

function deleteRecords($iSurveyID,$condition)
{
$this->db->where($condition);
return $this->db->delete('survey_'.$iSurveyID);
}


}
return $this->db->query($querysel);
}

/**
* Insert a new response
* @param int $iSurveyID ID of the survey
* @param array $data The response
* @return mixed
*/
function insertRecords($iSurveyID, $data)
{
return $this->db->insert('survey_'.$iSurveyID, $data);
}

/**
* Get data from certain columns for a response
* @param array $aFields Array containing field names
* @param int $iSurveyID ID of the survey
* @param int $iResponseID ID of the response
* @return mixed
*/
function getFieldsForID($aFields, $iSurveyID, $iResponseID)
{
foreach ($aFields as $field)
{
$this->db->select($field);
}

$this->db->where('id', $iResponse);
return $this->db->get('survey_'.$iSurveyID);
}


/**
* Get a response from the database
* @param int $iSurveyID ID of the survey
* @param int $iResponseID ID of the response
* @return mixed
*/
function getResponse($iSurveyID, $iResponseID)
{
$this->db->where('id', $iResponseID);
return $this->db->get('survey_'.$iSurveyID);
}

function deleteRecords($iSurveyID,$condition)
{
$this->db->where($condition);
return $this->db->delete('survey_'.$iSurveyID);
}

function deleteResponse($iSurveyID, $iResponseID)
{
$this->db->where('id', $iResponseID);
return $this->db->delete('survey_'.$iSurveyID);
}

function getResponseCount($iSurveyID)
{
return $this->db->count_all_results('survey_'.$iSurveyID);
}


/**
* Update a response
* @param int $iSurveyID ID of the survey
* @param int $iResponseID ID of the response
* @param array $aData Array containg response data
* @return mixed
*/
function updateResponse($iSurveyID, $iResponseID, $aData)
{
$this->db->where('id', $iResponseID);
$this->db->update('survey_'.$iSurveyID, $aData);
}
}
22 changes: 11 additions & 11 deletions application/views/admin/browse/browsemenubar_view.php
Expand Up @@ -13,13 +13,13 @@
<a href='<?php echo site_url("admin/browse/$surveyid");?>' title="<?php echo $clang->gTview("Show summary information");?>">
<img name='SurveySummary' src='<?php echo $imageurl;?>/summary.png' title='' alt='<?php echo $clang->gT("Show summary information");?>' /></a>
<?php if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0) { ?>
<a href='<?php echo site_url("admin/browse/$surveyid/all");?>' title="<?php echo $clang->gTview("Display Responses");?>">
<img name='ViewAll' src='<?php echo $imageurl;?>/document.png' title='' alt='<?php echo $clang->gT("Display Responses");?>' /></a>
<?php } else { ?>
<a href="#" accesskey='b' id='browseresponses' title="<?php echo $clang->gTview("Display Responses");?>" >
<img src='<?php echo $imageurl;?>/document.png' alt='<?php echo $clang->gT("Display Responses");?>' name='ViewAll' /></a>

<div class="langpopup" id="browselangpopup"><?php echo $clang->gT("Please select a language:");?><ul>
<a href='<?php echo site_url("admin/browse/$surveyid/all");?>' title="<?php echo $clang->gTview("Display Responses");?>">
<img name='ViewAll' src='<?php echo $imageurl;?>/document.png' title='' alt='<?php echo $clang->gT("Display Responses");?>' /></a>
<?php } else { ?>
<a href="<?php echo site_url("admin/browse/$surveyid/all");?>" accesskey='b' id='browseresponses' title="<?php echo $clang->gTview("Display Responses");?>" >
<img src='<?php echo $imageurl;?>/document.png' alt='<?php echo $clang->gT("Display Responses");?>' name='ViewAll' /></a>

<div class="langpopup" id="browselangpopup"><?php echo $clang->gT("Please select a language:");?><ul>
<?php foreach ($tmp_survlangs as $tmp_lang) { ?>
<li><a href="<?php echo site_url("admin/browse/$surveyid/all/0/50/asc/$tmp_lang");?>" accesskey='b'><?php echo getLanguageNameFromCode($tmp_lang,false);?></a></li>
<?php } ?>
Expand Down Expand Up @@ -73,7 +73,7 @@
if (bHasSurveyPermission($surveyid,'responses','delete') && $thissurvey['anonymized'] == 'N' && $thissurvey['tokenanswerspersistence'] == 'Y') { ?>
<a href='<?php echo site_url("admin/iteratesurvey/$surveyid/");?>' title="<?php echo $clang->gTview("Iterate survey");?>" >
<img src='<?php echo $imageurl;?>/iterate.png' title='' alt='<?php echo $clang->gT("Iterate survey");?>' /></a>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>

0 comments on commit 4648894

Please sign in to comment.