function get_answered_poll($question_id, $admin = false) { $answers = get_answers($question_id); // get answers with asociated information $number_of_answers = get_number_of_answers($question_id); $title = get_question_title($question_id); $rating = get_question_rating($question_id); $num_ppl = get_number_of_people_voted($question_id); $html = "<div id='answered_poll'>\n<pre>"; $html .= "<h1>{$title}</h1>\n"; $html .= "<p>This question has an average rating of {$rating}/10. <br />{$num_ppl} "; $html .= ($num_ppl == 1 ? "person has " : "people have ") . "voted.</p>\n"; $count = 0; foreach ($answers as $answer) { $votes = "Vote" . ($answer['votes_for'] > 1 ? "s" : ""); $percent = $answer['votes_for'] / $num_ppl * 100; $percent = round($percent, 2); $div_id = "bar" . $count++; $html .= "<p>{$answer['answer']}\t<div id=\"{$div_id}\" class='bar_class'></div>{$percent}% \t{$answer['votes_for']} {$votes}</p>\n"; $html .= "<script>\n"; $int_percent = (int) $percent; // the int of the percent $html .= <<<END \t\t\t\$(function(){ \t\t\t\t\$("#{$div_id}").progressbar({ \t\t\t\t\tvalue: {$int_percent} \t\t\t\t}); \t\t\t}); END; $html .= "</script>"; } $html .= "\n</pre></div>"; if (!$admin) { return $html; } $html .= "<p>This question was made by " . get_made_by($question_id) . ".</p>"; $html .= get_comments_html($question_id); return $html; }
/** Luo kysymys muokkausn\"{a}kym\"{a}ss\"{a} * @param $question_id integer */ function create_edit_box($question_id) { /** * $body string * $title string * $tags string */ $body = get_question_body($question_id); $title = get_question_title($question_id); $tags = get_question_tags($question_id); echo "<form id='update_question_form' method='post' " . "action='./handlers/update_question.php" . "'>"; echo "<fieldset>" . create_title_at_question($title) . create_body_at_question($body) . create_tags_at_question($tags) . "</fieldset>"; echo "<input class='update_question' onclick='checkFields();' type='submit' value='Update Your Question' /></form>"; }