HTML and CSS Reference
In-Depth Information
// TODO: Load the answer form for presenters, but not attendees
$view->answer_link = '';
// Returns the output of render() instead of printing it
$output .= $view->render(FALSE);
return $output;
This code checks for a cookie signaling the question has been voted for already, setting a class name to alter the
styling if so.
in a production environment, the app would need to either add a failsafe for users who have cookies turned
off or simply disallow use of the app without first enabling cookies. Fully locking down form submissions is outside the
scope of this topic, but there are many great resources available online if you want to learn more.
Loading the Vote Up Form
In order to display the vote up form for attendees, but not to presenters, a new method needs to be created that will
conditionally generate a view that can be used for output within the question view.
In system/controllers/ , add the following bold code:
public function output_view( )
$questions = $this->get_questions();
$output = NULL;
foreach ($questions as $question) {
* Questions have their own view type, so this section initializes
* and sets up variables for the question view
$view = new View('question');
$view->question = $question->question;
$view->room_id = $this->room_id;
$view->question_id = $question->question_id;
$view->vote_count = $question->vote_count;
if ($question->is_answered==1) {
$view->answered_class = 'answered';
} else {
$view->answered_class = NULL;
// Checks if the user has already voted up this question
$cookie = 'voted_for_' . $question->question_id;
Search WWH ::

Custom Search