Skip to content

Commit

Permalink
Fixed issue #6806: If one of a 1-5 answer is never selected, there is…
Browse files Browse the repository at this point in the history
… a random value in statistics graph legend

Fixed issue #6831: Exception when attempting to view individual survey result on MSSQL
  • Loading branch information
c-schmitz committed Nov 6, 2012
1 parent 6298475 commit aca8481
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions application/models/Survey_dynamic.php
Expand Up @@ -209,5 +209,98 @@ public function isCompleted($srid)
return $completed;
}

/**
* Return true if actual respnse exist in database
*
* @param $srid : actual save survey id
*
* @return boolean
*/
public function exist($srid)
{
$sid = self::$sid;
$exist=false;

if(Yii::app()->db->schema->getTable($this->tableName())){
$data=Yii::app()->db->createCommand()
->select("id")
->from($this->tableName())
->where('id=:id', array(':id'=>$srid))
->queryRow();
if($data)
{
$exist=true;
}
}
return $exist;
}

/**
* Return next id if next response exist in database
*
* @param integer $srid : actual save survey id
* @param boolean $usefilterstate
*
* @return integer
*/
public function next($srid,$usefilterstate=false)
{
$sid = self::$sid;
$next=false;
if ($usefilterstate && incompleteAnsFilterState() == 'incomplete')
$wherefilterstate='submitdate IS NULL';
elseif ($usefilterstate && incompleteAnsFilterState() == 'complete')
$wherefilterstate='submitdate IS NOT NULL';
else
$wherefilterstate='1=1';

if(Yii::app()->db->schema->getTable($this->tableName())){
$data=Yii::app()->db->createCommand()
->select("id")
->from($this->tableName())
->where(array('and',$wherefilterstate,'id > :id'), array(':id'=>$srid))
->order('id ASC')
->queryRow();
if($data)
{
$next=$data['id'];
}
}
return $next;
}

/**
* Return previous id if previous response exist in database
*
* @param integer $srid : actual save survey id
* @param boolean $usefilterstate
*
* @return integer
*/
public function previous($srid,$usefilterstate=false)
{
$sid = self::$sid;
$previous=false;
if ($usefilterstate && incompleteAnsFilterState() == 'incomplete')
$wherefilterstate='submitdate IS NULL';
elseif ($usefilterstate && incompleteAnsFilterState() == 'complete')
$wherefilterstate='submitdate IS NOT NULL';
else
$wherefilterstate='1=1';

if(Yii::app()->db->schema->getTable($this->tableName())){
$data=Yii::app()->db->createCommand()
->select("id")
->from($this->tableName())
->where(array('and',$wherefilterstate,'id < :id'), array(':id'=>$srid))
->order('id DESC')
->queryRow();
if($data)
{
$previous=$data['id'];
}
}
return $previous;
}
}
?>

0 comments on commit aca8481

Please sign in to comment.