isError()) { exit_no_group(); } $sh = new SurveyHTML(); html_use_jqueryjqplotpluginCanvas(); html_use_jqueryjqplotpluginPie(); html_use_jqueryjqplotpluginhighlighter(); html_use_jqueryjqplotplugindateAxisRenderer(); html_use_jqueryjqplotpluginBar(); $title = _('Survey Results'); $sh->header(array('title' => $title, 'modal' => 1)); if (!session_loggedin() || !forge_check_perm('project_admin', $group_id)) { echo $HTML->error_msg(_('Permission denied.')); $sh->footer(); exit; } /* Show detailed results of a survey */ if ($survey_id) { $s = new Survey($g, $survey_id); if (!$s || !is_object($s)) { echo $HTML->error_msg(_('Error')._(': ')._('Cannot get Survey')); $sh->footer(); exit; } elseif ( $s->isError()) { echo $HTML->error_msg(_('Error')._(': ').$s->getErrorMessage()); $sh->footer(); exit; } /* A specific question */ $question_id = getIntFromRequest('question_id'); if ($question_id) { /* Create a Survey Question for general purpose */ $sq = new SurveyQuestion($g, $question_id); if (!$sq || !is_object($sq)) { echo $HTML->error_msg(_('Error')._(': ')._('Cannot get Survey Question')); } elseif ($sq->isError()) { echo $HTML->error_msg(_('Error')._(': ').$sq->getErrorMessage()); } else { showResult($sh, $s, $sq, 1, 0, $graph); } } else { echo html_e('h2', array(),$s->getTitle().' ('. $s->getNumberOfVotes() .' ' . _("Votes") . ')'); /* Get questions of this survey */ $questions = $s->getQuestionInstances(); $question_number = 1; for ($i=0; $iisError()) { echo $questions[$i]->getErrorMessage(); } else { if ($questions[$i]->getQuestionType()!='4') { showResult($sh, $s, $questions[$i], $show_comment, $question_number++, $graph); } } } } } /* Show list of Surveys with result link */ /* Show list of Surveys */ $sf = new SurveyFactory($g); $ss = & $sf->getSurveys(); if (!$ss) { echo $HTML->information(_('No Survey Question is found')); } else { echo $sh->showSurveys($ss, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1); } $sh->footer(); /** * showResult - Get Result from Survey and Question. Pass the result to Show Result HTML class * * @param object $SurveyHTML a survey object * @param object $Survey * @param object $Question a question object * @param int $show_comment whether print out export(csv) format * @param string $q_num * @param int $graph */ function showResult(&$SurveyHTML, &$Survey, &$Question, $show_comment=0, $q_num="", $graph=0) { global $HTML; /* Get results */ $srf = new SurveyResponseFactory($Survey, $Question); if (!$srf || !is_object($srf)) { echo $HTML->error_msg(_('Error'). ' ' . _('Cannot get Survey Response Factory')); } elseif ($srf->isError()) { echo $HTML->error_msg(_('Error'). $srf->getErrorMessage()); } else { /* Show result in HTML*/ echo $SurveyHTML->showResult($srf, $show_comment, $q_num, $graph); } }