Exemplo n.º 1
0
 protected function createFullQuestionIndexByGroup($LEMsessid)
 {
     echo "\n\n<!-- PRESENT THE INDEX -->\n";
     echo CHtml::openTag('div', array('id' => 'index'));
     echo CHtml::openTag('div', array('class' => 'container'));
     echo CHtml::tag('h2', array(), gT("Question index"));
     echo CHtml::openTag('ol');
     foreach ($_SESSION[$LEMsessid]['grouplist'] as $key => $group) {
         //						echo '<script>';
         //						echo 'var session = '. json_encode(LimeExpressionManager::singleton()->_ValidateGroup($key)) . ';';
         //						echo 'console.log(session);';
         //						echo '</script>';
         // Better to use tracevar /
         if (LimeExpressionManager::GroupIsRelevant($group['gid'])) {
             $group['step'] = $key + 1;
             $stepInfo = LimeExpressionManager::singleton()->_ValidateGroup($key);
             $classes = implode(' ', array('row', $stepInfo['anyUnanswered'] ? 'missing' : '', $_SESSION[$LEMsessid]['step'] == $group['step'] ? 'current' : ''));
             $sButtonSubmit = CHtml::htmlButton(gT('Go to this group'), array('type' => 'submit', 'value' => $group['step'], 'name' => 'move', 'class' => 'jshide'));
             echo CHtml::tag('li', array('data-gid' => $group['gid'], 'title' => $group['description'], 'class' => $classes), $group['group_name'] . $sButtonSubmit);
         }
     }
     echo CHtml::closeTag('ol');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     App()->getClientScript()->registerScript('manageIndex', "manageIndex()\n", CClientScript::POS_END);
 }
Exemplo n.º 2
0
/**
* Creates an array with details on a particular response for display purposes
* Used in Print answers, Detailed response view and Detailed admin notification email
*
* @param mixed $iSurveyID
* @param mixed $iResponseID
* @param mixed $sLanguageCode
* @param boolean $bHonorConditions Apply conditions
*/
function getFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonorConditions = true)
{
    $aFieldMap = createFieldMap($iSurveyID, 'full', false, false, $sLanguageCode);
    //Get response data
    $idrow = SurveyDynamic::model($iSurveyID)->findByAttributes(array('id' => $iResponseID));
    // Create array of non-null values - those are the relevant ones
    $aRelevantFields = array();
    foreach ($aFieldMap as $sKey => $fname) {
        if (LimeExpressionManager::QuestionIsRelevant($fname['qid']) || $bHonorConditions == false) {
            $aRelevantFields[$sKey] = $fname;
        }
    }
    $aResultTable = array();
    $oldgid = 0;
    $oldqid = 0;
    foreach ($aRelevantFields as $sKey => $fname) {
        if (!empty($fname['qid'])) {
            $attributes = getQuestionAttributeValues($fname['qid']);
            if (getQuestionAttributeValue($attributes, 'hidden') == 1) {
                continue;
            }
        }
        $question = $fname['question'];
        $subquestion = '';
        if (isset($fname['gid']) && !empty($fname['gid'])) {
            //Check to see if gid is the same as before. if not show group name
            if ($oldgid !== $fname['gid']) {
                $oldgid = $fname['gid'];
                if (LimeExpressionManager::GroupIsRelevant($fname['gid']) || $bHonorConditions == false) {
                    $aResultTable['gid_' . $fname['gid']] = array($fname['group_name'], QuestionGroup::model()->getGroupDescription($fname['gid'], $sLanguageCode));
                }
            }
        }
        if (!empty($fname['qid'])) {
            if ($oldqid !== $fname['qid']) {
                $oldqid = $fname['qid'];
                if (isset($fname['subquestion']) || isset($fname['subquestion1']) || isset($fname['subquestion2'])) {
                    $aResultTable['qid_' . $fname['sid'] . 'X' . $fname['gid'] . 'X' . $fname['qid']] = array($fname['question'], '', '');
                } else {
                    $answer = getExtendedAnswer($iSurveyID, $fname['fieldname'], $idrow[$fname['fieldname']], $sLanguageCode);
                    $aResultTable[$fname['fieldname']] = array($question, '', $answer);
                    continue;
                }
            }
        } else {
            $answer = getExtendedAnswer($iSurveyID, $fname['fieldname'], $idrow[$fname['fieldname']], $sLanguageCode);
            $aResultTable[$fname['fieldname']] = array($question, '', $answer);
            continue;
        }
        if (isset($fname['subquestion'])) {
            $subquestion = "[{$fname['subquestion']}]";
        }
        if (isset($fname['subquestion1'])) {
            $subquestion = "[{$fname['subquestion1']}]";
        }
        if (isset($fname['subquestion2'])) {
            $subquestion .= "[{$fname['subquestion2']}]";
        }
        $answer = getExtendedAnswer($iSurveyID, $fname['fieldname'], $idrow[$fname['fieldname']], $sLanguageCode);
        $aResultTable[$fname['fieldname']] = array($question, $subquestion, $answer);
    }
    return $aResultTable;
}