Permalink
Browse files

incremental update

  • Loading branch information...
thenobody
thenobody committed Jul 5, 2010
1 parent 971ec87 commit 55784e6a1a1788715e1d2f8568618f803e4673df
@@ -72,7 +72,6 @@ private function parseQuestionnaire( $filename )
$questionnaire = new Questionnaire();
$questionnaire->Name = (string) $attributes[ 'name' ];
- $questionnaire->File = $filename;
$questionnaire->Continuous = ( (string) $attributes[ 'continuous' ] == 'true' );
$questionnaire->StatusId = 1;
$questionnaire->setXml( $node );
@@ -168,6 +167,7 @@ private function parseAnswers( AnswerGroup $answerGroup )
$answerModel->Text = ( (string) $attributes[ 'text' ] == 'true' );
$answerModel->Value = (string) $attributes[ 'value' ];
$answerModel->Label = (string) $attributes[ 'label' ];
+ $answerModel->Random = ( (string) $attributes[ 'random' ] == 'true' );
$answerModel->Limit = (int) $attributes[ 'limit' ];
$answerModel->setXml( $answer );
@@ -90,7 +90,6 @@
'props' => array(
'Id' => array( 'id', 'int', array( 'pk'=>true, 'autoIncrement'=>true ) ),
'Name' => array( 'name', 'varchar' ),
- 'File' => array( 'file', 'varchar' ),
'Continuous' => array( 'continuous', 'bool' ),
'StatusId' => array( 'status_id', 'int' ),
),
@@ -158,6 +157,7 @@
'Text' => array( 'text', 'bool' ),
'Value' => array( 'value', 'varchar' ),
'Label' => array( 'label', 'varchar' ),
+ 'Random' => array( 'random_position', 'bool' ),
'Limit' => array( 'answer_limit', 'int' ),
'AnswerGroupId' => array( 'answer_group_id', 'int' ),
),
@@ -203,6 +203,8 @@
'props' => array(
'Id' => array( 'id', 'int', array( 'pk'=>true, 'autoIncrement'=>true ) ),
'Name' => array( 'name', 'varchar' ),
+ 'Regexp' => array( 'rule_regexp', 'varchar' ),
+ 'Not' => array( 'not_modifier', 'bool' ),
),
),
'FilteringOrder' => array(
@@ -65,14 +65,13 @@ public function containsNeighbour( QuestionGraphNode $node )
public function getLastAnsweredChild( Token $token )
{
- if( !$this->hasNeighbours() )
- return false;
+ //if( !$this->hasNeighbours() )
+ // return false;
foreach( $this->getNeighbours() as $node )
{
$question = $node->getQuestion();
-
- $test = $question->hasUserAnswers( $token );
+
if( $question->hasUserAnswers( $token ) )
return $node->getLastAnsweredChild( $token );
}
@@ -56,8 +56,9 @@ private function setNextQuestion( Question $question )
public function prepare()
{
$graph = $this->generateQuestionGraph();
- $this->validateAndSaveAnswers( $graph ); // mega todo
+ $this->validateAndSaveAnswers( $graph );
$nextQuestion = $this->findNextQuestion( $graph );
+
if( $nextQuestion )
$this->setNextQuestion( $nextQuestion );
else
@@ -87,6 +88,7 @@ private function validateAndSaveAnswers( QuestionGraph $graph )
if( $valid )
$this->getDB()->save( $questionnaire );
+
}
private function findNextQuestion( QuestionGraph $graph )
@@ -17,7 +17,7 @@ public function addAnswers()
if( !$answers )
return;
-
+
foreach( $answers as $answerName => $answerValues )
$this->processAnswer( $answerName, $answerValues );
}
@@ -45,7 +45,7 @@ private function processAnswer( $answerName, $answerValues )
$answer = $answerGroup->getAnswerByName( $answerName, false );
if( !$answer )
throw new EAnswerNotFound( "$name => $value" );
- $txtValue = ( $answer->Text ) ? $value : null;
+ $txtValue = ( $answerGroup->getAnswerType()->Name == 'text' || $answer->Text ) ? $value : null;
$answer->addUserAnswerByToken( $token, $txtValue );
}
}
@@ -19,7 +19,7 @@ public function evaluateNode( QuestionGraphNode $node )
$token = $this->getToken();
$graph = $this->getQuestionGraph();
$tree = $this->buildTree( $node );
-
+
return $tree->evaluate( $token, $graph );
}
@@ -87,7 +87,6 @@
'props' => array(
'Id' => array( 'id', 'int', array( 'pk'=>true, 'autoIncrement'=>true ) ),
'Name' => array( 'name', 'varchar' ),
- 'File' => array( 'file', 'varchar' ),
'Continuous' => array( 'continuous', 'bool' ),
'StatusId' => array( 'status_id', 'int' ),
),
@@ -38,7 +38,12 @@ public function _radio_vertical()
}
- public function _lines()
+ public function _checkbox_vertical()
+ {
+
+ }
+
+ public function _text()
{
}
@@ -30,8 +30,10 @@ public function getUserAnswer( $token, $default = false )
{
$userAnswers = $this->getUserAnswers();
foreach( $userAnswers as $userAnswer )
+ {
if( $userAnswer->getToken() == $token )
return $userAnswer;
+ }
return $default;
}
@@ -0,0 +1 @@
+<?php echo WidgetBuilder::getFormTag( $question ); ?> <div id="question" class="question"> <?php echo $question->QuestionText; ?> <div id="question-groups" class="question-groups"> <?php foreach( $question->getQuestionGroups() as $questionGroup ): ?> <div class="question-group"> <?php echo $questionGroup->Label; ?> <?php foreach( $questionGroup->getAnswerGroups() as $answerGroup ): ?> <?php echo $answerGroup->Label; ?> <?php/* echo WidgetBuilder::getWidget( $answerGroup ); */ ?> <ul> <?php foreach( $answerGroup->getAnswers() as $answer ): ?> <li><?php echo WidgetBuilder::getWidget( $answer ); ?></li> <?php endforeach; ?> </ul> <?php endforeach; ?> </div> <?php endforeach; ?> </div> <?php echo WidgetBuilder::getSubmitButton( 'Next' ); ?> </div></form>
@@ -1 +0,0 @@
-<?php echo "lines<br />"; ?><?php echo $question->QuestionText; ?>
@@ -0,0 +1 @@
+<?php echo WidgetBuilder::getFormTag( $question ); ?> <div id="question" class="question"> <?php echo $question->QuestionText; ?> <div id="question-groups" class="question-groups"> <?php foreach( $question->getQuestionGroups() as $questionGroup ): ?> <div class="question-group"> <?php echo $questionGroup->Label; ?> <?php foreach( $questionGroup->getAnswerGroups() as $answerGroup ): ?> <?php echo $answerGroup->Label; ?> <?php/* echo WidgetBuilder::getWidget( $answerGroup ); */ ?> <ul> <?php foreach( $answerGroup->getAnswers() as $answer ): ?> <li><?php echo WidgetBuilder::getWidget( $answer ); ?></li> <?php endforeach; ?> </ul> <?php endforeach; ?> </div> <?php endforeach; ?> </div> <?php echo WidgetBuilder::getSubmitButton( 'Next' ); ?> </div></form>
Binary file not shown.
Oops, something went wrong.

0 comments on commit 55784e6

Please sign in to comment.