Beispiel #1
0
 /**
  * Returns HTML Formatted Text for Question Display on the 'answer' page
  *
  * @param string $question_text 
  * @return void
  * @author Ben Evans
  */
 public static function output_with_hints($question_text)
 {
     $text_and_hints = View_Helper_Question::format_for_text($question_text, true);
     $question = $text_and_hints['question'];
     $hints = $text_and_hints['explanations'];
     $return_text = "";
     for ($i = 0; $i < sizeof($question); $i++) {
         if (array_key_exists($i, $hints) && strlen($hints[$i]) > 0) {
             $return_text .= "<div class='question-explanation-holder' id='question-explanation-holder-{$i}' onClick='showExplanation({$i});'></div>";
             $return_text .= "<div class='question-explanation-details' id='question-explanation-details-{$i}' >" . $hints[$i] . "</div>";
         } else {
             $return_text .= "<div class='question-blank-holder'></div>";
         }
         $question[$i] = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $question[$i]);
         $return_text .= "<div class='question-text-output' id='question-text-output-{$i}'>" . $question[$i] . "</div>\n";
     }
     return $return_text;
 }
Beispiel #2
0
 public function makeImage($mImageText)
 {
     $rows = explode("\n", View_Helper_Question::format_for_text($mImageText, false));
     $im = imagecreate(600, 30 * sizeof($rows) + 50);
     $bg = imagecolorallocate($im, 255, 255, 255);
     $textcolor = imagecolorallocate($im, 0, 0, 255);
     $rowNum = 0;
     foreach ($rows as $row) {
         //Interpret TABs correctly (this is WAAAAAY Beta)
         $row = str_replace("\t", "      ", $row);
         $row = html_entity_decode($row);
         imagettftext($im, 12, 0, 5, $rowNum * 23 + 50, $textcolor, APPLICATION_PATH . "/../resources/couri.ttf", $row);
         //imagestring($im, 5, 0, $rowNum*30, $row, $textcolor);
         $rowNum++;
     }
     header('Content-type: image/png');
     imagepng($im);
     imagedestroy($im);
 }