1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4/** 5* This class represents a random test input property in a property form. 6* 7* @author Helmut Schottmüller <ilias@aurealis.de> 8* @version $Id$ 9* @ingroup ServicesForm 10*/ 11class ilRandomTestROInputGUI extends ilSubEnabledFormPropertyGUI 12{ 13 protected $values = array(); 14 15 /** 16 * Constructor 17 * 18 * @param string $a_title Title 19 * @param string $a_postvar Post Variable 20 */ 21 public function __construct($a_title = "", $a_postvar = "") 22 { 23 parent::__construct($a_title, $a_postvar); 24 $this->setRequired(true); 25 } 26 27 /** 28 * Set Value. 29 * 30 * @param string $a_value Value 31 */ 32 public function setValue($a_value) 33 { 34 } 35 36 public function setValueByArray($a_values) 37 { 38 } 39 40 /** 41 * Set Values 42 * 43 * @param array $a_value Value 44 */ 45 public function setValues($a_values) 46 { 47 $this->values = $a_values; 48 } 49 50 /** 51 * Get Values 52 * 53 * @return array Values 54 */ 55 public function getValues() 56 { 57 return $this->values; 58 } 59 60 /** 61 * Check input, strip slashes etc. set alert, if input is not ok. 62 * 63 * @return boolean Input ok, true/false 64 */ 65 public function checkInput() 66 { 67 return $this->checkSubItemsInput(); 68 } 69 70 /** 71 * Insert property html 72 * 73 * @return int Size 74 */ 75 public function insert(&$a_tpl) 76 { 77 global $DIC; 78 $lng = $DIC['lng']; 79 80 $tpl = new ilTemplate("tpl.prop_randomtestroinput.html", true, true, "Modules/Test"); 81 $i = 0; 82 foreach ($this->values as $value) { 83 if ($value['num_of_q'] > 0) { 84 $tpl->setCurrentBlock("num_of_q"); 85 $tpl->setVariable("NUM_OF_Q", $value['num_of_q']); 86 $tpl->setVariable("TEXT_FROM", $lng->txt('questions_from')); 87 $tpl->parseCurrentBlock(); 88 } 89 $tpl->setCurrentBlock("row"); 90 $class = ($i % 2 == 0) ? "even" : "odd"; 91 if ($i == 0) { 92 $class .= " first"; 93 } 94 if ($i == count($this->values) - 1) { 95 $class .= " last"; 96 } 97 $tpl->setVariable("ROW_CLASS", $class); 98 $tpl->setVariable("QPL_VALUE", ilUtil::prepareFormOutput($value['title'])); 99 $tpl->setVariable("COUNT_VALUE", "(" . $value['count'] . " " . $lng->txt('assQuestions') . ")"); 100 $tpl->parseCurrentBlock(); 101 $i++; 102 } 103 $tpl->setVariable("ELEMENT_ID", $this->getPostVar()); 104 105 $a_tpl->setCurrentBlock("prop_generic"); 106 $a_tpl->setVariable("PROP_GENERIC", $tpl->get()); 107 $a_tpl->parseCurrentBlock(); 108 } 109} 110