Welcome Guest, Not a member yet? Register   Sign In
MVC Style Question... put data in view vs controller
#3

[eluser]oldblueday[/eluser]
Absolutely. Thanks, mddd. However I am having a problem, which I'm hoping has a simple solution.

Code:
<p>Loose snow avalanche!!!!</p>
        <p>The avalanche roared down crushing one of the shelter walls and covering the shelter with up to 3 meters of snow. Many of the people made it out of the shelter on their own, but others had to be assisted.</p>    
    </div>
    &lt;?php
        // if I call a bunch of functions via a procedure, it doesn't work
        echo print_scenario_question($scenario_questions[0], $ans_key);

        // however if I call the functions outright, it works well
        // $q = $this->quizmaker->generate_question($scenario_questions[0]);
        // echo $q['HTML_question'];
        // $ans_key[] = $q['answer_key'];
    ?&gt;
    &lt;?php echo form_close(); ?&gt;


</div>


&lt;?php

/* --------------------------------------------------------------------------------
* PRINT SCENARIO QUESTION
*
* just shorthand to generate the HTML string for the question and update
* the answer key
*
* --------------------------------------------------------------------------------
*/    
    
    function print_scenario_question($question, &$ak)
    {
        $q = $this->quizmaker->generate_question($question);  
        $html .=  "<li>" . $q['HTML_question'] . "</li>";
        $ak[] = $q['answer_key'];
        return $html;
    }

I've narrowed it down to the calling of the $this->quizmaker->generate_question($question) call. Why would it work well inline but not when called from a procedure?

I noticed that you had translated my

Code:
&lt;?php
$this->questions->_print_scenario_question($scenario_questions[0], $html_quiz, $ans_key);
$this->questions->_print_scenario_question($scenario_questions[1], $html_quiz, $ans_key);
$this->questions->_print_scenario_question($scenario_questions[2], $html_quiz, $ans_key);
?&gt;

...into...

Code:
&lt;?php
$questions->_print_scenario_question($scenario_questions[0], $html_quiz, $ans_key);
$questions->_print_scenario_question($scenario_questions[1], $html_quiz, $ans_key);
$questions->_print_scenario_question($scenario_questions[2], $html_quiz, $ans_key);
?&gt;

Does the $this object not need to be there? I tried removing it with no luck, though.

Thanks-Rahul


Messages In This Thread
MVC Style Question... put data in view vs controller - by El Forum - 08-16-2010, 11:24 PM
MVC Style Question... put data in view vs controller - by El Forum - 08-17-2010, 12:17 AM
MVC Style Question... put data in view vs controller - by El Forum - 08-17-2010, 01:38 AM
MVC Style Question... put data in view vs controller - by El Forum - 08-18-2010, 09:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB