ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssMultipleChoiceCorrectionsInputGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
18 protected $qstObject;
19
20 public function setValue($a_value)
21 {
22 if (is_array($a_value)) {
23 if (is_array($a_value['points']) && is_array($a_value['points_unchecked'])) {
24 foreach ($this->values as $index => $value) {
25 $this->values[$index]->setPoints($a_value['points'][$index]);
26 $this->values[$index]->setPointsUnchecked($a_value['points_unchecked'][$index]);
27 }
28 }
29 }
30 }
31
32 public function checkInput()
33 {
34 global $DIC;
35 $lng = $DIC['lng'];
36
37 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
38 if (is_array($_POST[$this->getPostVar()])) {
40 }
41 $foundvalues = $_POST[$this->getPostVar()];
42 if (is_array($foundvalues)) {
43 // check points
44 $max = 0;
45 if (is_array($foundvalues['points'])) {
46 foreach ($foundvalues['points'] as $points) {
47 if ($points > $max) {
48 $max = $points;
49 }
50 if (((strlen($points)) == 0) || (!is_numeric($points))) {
51 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
52 return false;
53 }
54 }
55 foreach ($foundvalues['points_unchecked'] as $points) {
56 if ($points > $max) {
57 $max = $points;
58 }
59 if (((strlen($points)) == 0) || (!is_numeric($points))) {
60 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
61 return false;
62 }
63 }
64 }
65 if ($max == 0) {
66 $this->setAlert($lng->txt("enter_enough_positive_points"));
67 return false;
68 }
69 } else {
70 $this->setAlert($lng->txt("msg_input_is_required"));
71 return false;
72 }
73
74 return $this->checkSubItemsInput();
75 }
76
77 public function insert($a_tpl)
78 {
79 global $DIC; /* @var ILIAS\DI\Container $DIC */
80 $lng = $DIC->language();
81
82 $tpl = new ilTemplate("tpl.prop_multiplechoicecorrection_input.html", true, true, "Modules/TestQuestionPool");
83
84 $i = 0;
85
86 foreach ($this->values as $value) {
87 if ($this->qstObject->isSingleline) {
88 if (strlen($value->getImage())) {
89 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
90 if (($this->getSingleline()) && ($this->qstObject->getThumbSize())) {
91 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
92 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
93 }
94 }
95
96 $tpl->setCurrentBlock('image');
97 $tpl->setVariable('SRC_IMAGE', $imagename);
98 $tpl->setVariable('IMAGE_NAME', $value->getImage());
99 $tpl->setVariable('ALT_IMAGE', ilUtil::prepareFormOutput($value->getAnswertext()));
100 $tpl->parseCurrentBlock();
101 } else {
102 $tpl->setCurrentBlock('image');
103 $tpl->touchBlock('image');
104 $tpl->parseCurrentBlock();
105 }
106 }
107
108 $tpl->setCurrentBlock("answer");
109 $tpl->setVariable("ANSWER", $value->getAnswertext());
110 $tpl->parseCurrentBlock();
111
112 $tpl->setCurrentBlock("row");
113 $tpl->setVariable("POINTS_POST_VAR", $this->getPostVar());
114 $tpl->setVariable("POINTS_ROW_NUMBER", $i);
115 $tpl->setVariable("PROPERTY_VALUE_CHECKED", ilUtil::prepareFormOutput($value->getPointsChecked()));
116 $tpl->setVariable("PROPERTY_VALUE_UNCHECKED", ilUtil::prepareFormOutput($value->getPointsUnchecked()));
117 $tpl->parseCurrentBlock();
118
119 $i++;
120 }
121
122 if ($this->qstObject->isSingleline) {
123 $tpl->setCurrentBlock("image_heading");
124 $tpl->setVariable("ANSWER_IMAGE", $lng->txt('answer_image'));
125 $tpl->setVariable("TXT_MAX_SIZE", ilUtil::getFileSizeInfo());
126 $tpl->parseCurrentBlock();
127 }
128
129 $tpl->setCurrentBlock("points_heading");
130 $tpl->setVariable("POINTS_CHECKED_TEXT", $lng->txt('points_checked'));
131 $tpl->setVariable("POINTS_UNCHECKED_TEXT", $lng->txt('points_unchecked'));
132 $tpl->parseCurrentBlock();
133
134 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
135 $tpl->setVariable("ANSWER_TEXT", $lng->txt('answer_text'));
136
137 $a_tpl->setCurrentBlock("prop_generic");
138 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
139 $a_tpl->parseCurrentBlock();
140 }
141}
$tpl
Definition: ilias.php:10
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
This class represents a multiple choice wizard property in a property form.
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
special template class to simplify handling of ITX/PEAR
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static getFileSizeInfo()
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$i
Definition: disco.tpl.php:19
$index
Definition: metadata.php:60
global $DIC
Definition: saml.php:7