public function actionGetQuestionGroups()
 {
     // get question groups
     $rsQuestionGroups = EvaQuestionGroups::model()->find("section='evaCriteriaMethod'");
     $questionGroups = json_decode($rsQuestionGroups->questions);
     //Get questions
     $rsQuestions = EvaluationQuestion::model()->findAll(['condition' => "flag='final'"], ['select' => "*, CAST(`questionNumber` as SIGNED) AS castedColumn"]);
     $panels = [];
     foreach ($questionGroups as $group => $questions) {
         //print_r($questions); die;
         //asort($questions);
         $panels['Group ' . $group] = '<ul class="rb">';
         foreach ($rsQuestions as $evaQuestion) {
             if (in_array($evaQuestion->evalQuestionId, $questions)) {
                 $panels['Group ' . $group] .= '<li>' . $evaQuestion->questionNumber . ' ' . $evaQuestion->question . '</li>';
             }
         }
         $panels['Group ' . $group] .= '</ul>';
     }
     //		print_r($panels); die;
     $this->renderPartial('questionGroupPopup', ['panels' => $panels], false, true);
 }
Ejemplo n.º 2
0
 /**
 * swaps positions of two objects
 *
 * @access  private
 * @param   string  $parentID     the parentID
 * @param   string  $objectID     the object to swap
 * @param   string  $oldposition  the old position
 * @param   string  $direction    the direction to swap
 */
 function swapPosition($parentID, $objectID, $oldposition, $direction)
 {
     if ($parentID == ROOT_BLOCK) {
         $group = $this->tree->eval;
     } else {
         $group =& $this->tree->getGroupObject($parentID);
     }
     $numberchildren = $group->getNumberChildren();
     $instance = $group->x_instanceof();
     if ($direction == "up") {
         if ($oldposition == 0) {
             $newposition = $numberchildren - 1;
         } else {
             $newposition = $oldposition - 1;
         }
     } else {
         if ($oldposition == $numberchildren - 1) {
             $newposition = 0;
         } else {
             $newposition = $oldposition + 1;
         }
     }
     while ($swapitem = $group->getNextChild()) {
         if ($swapitem->getPosition() == $newposition) {
             $swapitem->setPosition($oldposition);
             $swapitem->save();
         }
     }
     if ($parentID != ROOT_BLOCK && $group->getChildType() == "EvaluationQuestion") {
         $object = new EvaluationQuestion($objectID);
     } else {
         $object =& $this->tree->getGroupObject($objectID);
     }
     $object->setPosition($newposition);
     $object->save();
     if ($swapitem->isError) {
         return EvalCommon::showErrorReport($swapitem, _("Fehler beim verschieben."));
     }
     if ($object->isError) {
         return EvalCommon::showErrorReport($object, _("Fehler beim verschieben."));
     }
 }
Ejemplo n.º 3
0
function save1($myuserid)
{
    $mineexists = 0;
    /*Existiert Question/Template schon?*/
    $qdb = new EvaluationQuestionDB();
    if (!$template_id) {
        $template_id = Request::option("template_id");
    }
    if ($qdb->exists($template_id)) {
        $question = new EvaluationQuestion($template_id, NULL, EVAL_LOAD_ALL_CHILDREN);
        if ($question->getParentID() != $myuserid) {
            $foreign = TRUE;
            $question = new EvaluationQuestion();
            $question->setParentID($myuserid);
        } else {
            $overwrite = 1;
            //$question->delete();
            //$question = new EvaluationQuestion();
            //$template_id=$question->getObjectID();
        }
    } else {
        $question = new EvaluationQuestion();
    }
    /*Get Vars ----------------------------------------------------*/
    $template_name = Request::get("template_name");
    $template_type = Request::get("template_type");
    $template_multiple = Request::get("template_multiple");
    $template_add_num_answers = Request::option("template_add_num_answers");
    $template_residual = Request::get("template_residual");
    $template_residual_text = Request::get("template_residual_text");
    $template_answers = Request::getArray("template_answers");
    /*end: Get Vars -----------------------------------------------*/
    $question->setParentID($myuserid);
    $question->setMultiplechoice($template_multiple);
    $question->setText(trim($template_name), YES);
    $question->setType($template_type);
    while ($answerrem = $question->getChild()) {
        $id = $answerrem->getObjectID();
        $answerrem->delete();
        $question->removeChildID($id);
    }
    $controlnumber = count($template_answers);
    $ausgleich = 0;
    for ($i = 0; $i < $controlnumber; $i++) {
        $text = $template_answers[$i]['text'];
        $answerID = $template_answers[$i]['answer_id'];
        $answer = new EvaluationAnswer();
        if (!$foreign) {
            $answer->setObjectID($answerID);
        }
        $answer->setText(trim($text), YES);
        $question->addChild($answer);
        /*Anzahl der Antworten bei Polskalen anpassen ------------------------*/
        if ($template_type == EVALQUESTION_TYPE_POL && $i == 0) {
            $answerdiff = $controlnumber - $template_add_num_answers;
            if ($template_residual) {
                //echo "Hust<br>";
                //$answerdiff;
            }
            if ($answerdiff > 0) {
                /*differenz abziehen => answers überspringen*/
                $i = $i + $answerdiff;
                $ausgleich = $ausgleich - $answerdiff;
            }
            while ($answerdiff < 0) {
                $ausgleich = $ausgleich + 1;
                $answer = new EvaluationAnswer();
                $answer->setText("");
                $answer->setParentID($question->getObjectID());
                $answer->setPosition($i + $ausgleich);
                $answer->setValue($i + 1 + $ausgleich);
                $question->addChild($answer);
                $answerdiff++;
            }
        }
        /*end: Polskala antworten angleichen ----------------------------------*/
    }
    /*create residual category-----------------------------------------------*/
    if ($template_residual) {
        $answer = new EvaluationAnswer();
        $answer->setResidual($template_residual);
        $answer->setText(trim($template_residual_text), QUOTED);
        $answer->setParentID($question->getObjectID());
        $answer->setPosition($i + $ausgleich + 1);
        $answer->setValue(-1);
        $question->addChild($answer);
    }
    /*object HIER NOCH NICHT in db speichern!      */
    // $question->save();
    if (!$overwrite) {
        $db = new EvaluationQuestionDB();
        $lib = new EvalTemplateGUI();
        $lib->setUniqueName($question, $db, $myuserid, YES);
    }
    if ($question->isError()) {
        EvalCommon::showErrorReport($question, _("Fehler beim Speichern."));
    }
    return $question;
}
Ejemplo n.º 4
0
 /**
  * actionEvaQuestionWizard
  */
 public function actionEvaQuestionWizard()
 {
     Yii::log("actionEvaQuestionWizard called", "trace", self::LOG_CAT);
     $this->setPageTitle('Evaluation question wizard');
     $this->layout = '//layouts/column3';
     $model = new EvaluationQuestion('wizard');
     $elements = ContextController::getDefaultElements();
     $questionId = '';
     $menu = [];
     if (empty($_POST['EvaluationQuestion'])) {
         $questions = $model->with('evalQuestionAnswers')->find("flag='primary'");
         unset(Yii::app()->session['leftMenu']);
         $menu[$questions->evalQuestionId]['label'] = $questions->question;
         //var_dump($questions); die;
     } else {
         //print_r($_POST); die;
         $answerId = $_POST['EvaluationQuestion']['answer'];
         $rsAnswers = EvalQuestionAnswers::model()->with('evalQuestion')->findByPk($answerId);
         $questionId = $rsAnswers->nextQuestion;
         $questions = $model->with('evalQuestionAnswers')->findByPk($questionId);
         //var_dump($questions); die();
         if ($questions->flag !== 'final') {
             //print_r($rsMenu); die;
             $menu = CHtml::tag('li', [], "Q: " . addslashes($rsAnswers->evalQuestion->question) . "<br /> A: " . $rsAnswers->optionName);
             Yii::app()->session['leftMenu'] .= $menu;
             if (isset($rsAnswers->flashQuestion)) {
                 Yii::app()->user->setFlash('notice', $rsAnswers->flashQuestion);
             }
         }
         //print_r(Yii::app()->session['leftMenu']); die;
     }
     if (isset($questions->flag) && 'final' == $questions->flag) {
         Yii::app()->user->setFlash('success', 'A question has been selected as per your previous choices');
         $this->redirect(['evaluation/evalQuestionList', 'questionId' => $questionId]);
     }
     $link = '';
     //var_dump($questions[0]['evalQuestionAnswers'], 'fdsf'); //die;
     foreach ($questions->evalQuestionAnswers as $answerKey => $answer) {
         if (!empty($answer->url)) {
             $link = CHtml::link($answer->optionName, $this->createUrl($answer->url));
             if ($answer->url == 'epitools') {
                 $link = CHtml::link($answer->optionName, Yii::app()->params['other']['epitoolsUrl'], ['target' => '_blank']);
             }
             //$questions[0]['evalQuestionAnswers'][$answerKey]->unsetAttributes();
         }
     }
     $elements['elements'] = ['<h4>' . $questions->question . '</h4>', 'answer' => ['type' => 'radiolist', 'style' => 'width:1em;', 'labelOptions' => ['style' => 'display:inline'], 'items' => $model->getItems($questions['evalQuestionAnswers']), 'label' => '', 'afterRequiredLabel' => '']];
     $elements['buttons'] = ['back' => ['type' => 'button', 'label' => 'Back', 'onClick' => 'history.go(-1)'], 'submit' => ['type' => 'submit', 'label' => 'Next']];
     if (isset($questions->flag) && 'end' == $questions->flag) {
         unset($elements['elements']['question']);
         unset($elements['buttons']);
         $link = '<br />' . CHtml::link('Click here to select an evaluation question', $this->createUrl('evalQuestionList'));
     }
     if (!empty($link)) {
         array_push($elements['elements'], $link);
     }
     //print_r($questions[0]['evalQuestionAnswers']); die('pooop');
     $form = new CForm($elements, $model);
     $this->render('evalQuestion', compact('form'));
 }
Ejemplo n.º 5
0
<?php

/* @var $this EvaQuestionGroupsController */
/* @var $model EvaQuestionGroups */
/* @var $form CActiveForm */
?>

<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'eva-question-groups-form', 'enableAjaxValidation' => false));
$evaluationQuestions = CHtml::listData(EvaluationQuestion::model()->findAll('flag=:flag', [':flag' => 'final']), 'evalQuestionId', function ($question) {
    return $question->questionNumber . ' ' . $question->question;
});
$economicMethods = CHtml::listData(EconEvaMethods::model()->findAll(), 'id', 'buttonName');
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'method');
?>
		<?php 
echo $form->dropdownlist($model, 'method', $economicMethods, ['class' => 'chozen']);
?>
		<?php 
Ejemplo n.º 6
0
                /* multiple choice question */
                foreach ($answer as $nr => $answer_id) {
                    voteFor($answer_id);
                }
            } else {
                /* answer = answer_id */
                voteFor($answer);
            }
        }
    }
    /* process the user's typed-in answers --------------------------------- */
    $freetexts = Request::quotedArray('freetexts');
    if (is_array($freetexts)) {
        foreach ($freetexts as $question_id => $text) {
            if (trim($text) != '') {
                $question = new EvaluationQuestion($question_id);
                $answer = new EvaluationAnswer();
                $answer->setText($text);
                $answer->setRows(1);
                $answer->vote($GLOBALS["userID"]);
                $question->addChild($answer);
                $question->save();
                $debug .= "added answer text <b>" . $answer->getText() . "</b> for question <b>" . $question->getText() . "</b>\n";
            }
        }
    }
    /* connect user with eval */
    $evalDB->connectWithUser($evalID, $auth->auth["uid"]);
    /* header ------ */
    $table->cont($lib->createEvaluationHeader($eval, $votedNow, $votedEarlier));
} elseif ($votedEarlier) {
Ejemplo n.º 7
0
 /**
  * Sets the template id
  * @access   public
  * @param    string   $templateID   The template id
  */
 function setTemplateID($templateID)
 {
     $newQuestionTexts = array();
     #      if ($templateID == $this->templateID)
     #         return; // for performance reasons
     $this->templateID = $templateID;
     while ($child =& $this->getChild()) {
         array_push($newQuestionTexts, $child->getText());
         $child->delete();
     }
     while ($text = array_pop($newQuestionTexts)) {
         $template = new EvaluationQuestion($templateID, NULL, EVAL_LOAD_ALL_CHILDREN);
         $child =& $template->duplicate();
         $child->setText($text);
         $this->addChild($child);
     }
 }
 /**
  * @param $questions
  * @return array
  */
 private function getAssociationData($questions)
 {
     $questionArray = json_decode($questions, true);
     $econMethods = array_keys($questionArray);
     $methodQuestions = [];
     foreach ($questionArray as $questionGroup) {
         //print_r($questionArray); die;
         $methodQuestions = array_merge($methodQuestions, $questionGroup);
     }
     //print_r($methodQuestions); die;
     $questionCriteria = new CDbCriteria();
     $questionCriteria->addInCondition('evalQuestionId', $methodQuestions);
     $rsQuestions = EvaluationQuestion::model()->findAll($questionCriteria);
     $econMethodCriteria = new CDbCriteria();
     $econMethodCriteria->addInCondition('id', $econMethods);
     $rsEconMethod = EconEvaMethods::model()->findAll($econMethodCriteria);
     $associationData = [];
     foreach ($rsEconMethod as $methodKey => $method) {
         //print_r($questionArray);
         //print_r($method);
         $associationData[$methodKey]['methodName'] = $method->buttonName;
         $associationData[$methodKey]['methodId'] = $method->id;
         $associationData[$methodKey]['questions'] = '<ul>';
         foreach ($rsQuestions as $question) {
             if (isset(array_flip($questionArray[$method->id])[$question->evalQuestionId])) {
                 $associationData[$methodKey]['questions'] .= CHtml::tag('li', [], $question->questionNumber . ' ' . $question->question);
             }
         }
         $associationData[$methodKey]['questions'] .= '</ul>';
     }
     return $associationData;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return EvaluationQuestion the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = EvaluationQuestion::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }