ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssMatchingPairCorrectionsInputGUI.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{
15 public function getPairs()
16 {
17 return $this->pairs;
18 }
19
20 public function setValue($a_value)
21 {
22 if (is_array($a_value)) {
23 if (is_array($a_value['points'])) {
24 foreach ($a_value['points'] as $idx => $term) {
25 $this->pairs[$idx]->points = $a_value['points'][$idx];
26 }
27 }
28 }
29 }
30
31 public function checkInput()
32 {
33 global $DIC;
34 $lng = $DIC['lng'];
35
36 if (is_array($_POST[$this->getPostVar()])) {
38 }
39 $foundvalues = $_POST[$this->getPostVar()];
40 if (is_array($foundvalues)) {
41 $max = 0;
42 foreach ($foundvalues['points'] as $val) {
43 if ($val > 0) {
44 $max += $val;
45 }
46 if ($this->getRequired() && (strlen($val)) == 0) {
47 $this->setAlert($lng->txt("msg_input_is_required"));
48 return false;
49 }
50 }
51 if ($max <= 0) {
52 $this->setAlert($lng->txt("enter_enough_positive_points"));
53 return false;
54 }
55 } else {
56 if ($this->getRequired()) {
57 $this->setAlert($lng->txt("msg_input_is_required"));
58 return false;
59 }
60 }
61
62 return $this->checkSubItemsInput();
63 }
64
65 public function insert($a_tpl)
66 {
67 global $DIC;
68 $lng = $DIC['lng'];
69
70 $tpl = new ilTemplate("tpl.prop_matchingpaircorrection_input.html", true, true, "Modules/TestQuestionPool");
71 $i = 0;
72
73 foreach ($this->pairs as $pair) {
74 $tpl->setCurrentBlock("row");
75
76 foreach ($this->terms as $term) {
77 if ($pair->term->identifier == $term->identifier) {
78 $tpl->setVariable('TERM', $term->text);
79 }
80 }
81 foreach ($this->definitions as $definition) {
82 if ($pair->definition->identifier == $definition->identifier) {
83 $tpl->setVariable('DEFINITION', $definition->text);
84 }
85 }
86
87 $tpl->setVariable('POINTS_VALUE', $pair->points);
88 $tpl->setVariable("ROW_NUMBER", $i);
89
90 $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
91 $tpl->setVariable("POST_VAR", $this->getPostVar());
92
93 $tpl->parseCurrentBlock();
94
95 $i++;
96 }
97
98 $tpl->setCurrentBlock('term_ids');
99 $ids = array();
100 foreach ($this->terms as $term) {
101 array_push($ids, $term->identifier);
102 }
103 $tpl->setVariable("POST_VAR", $this->getPostVar());
104 $tpl->setVariable("TERM_IDS", join(",", $ids));
105 $tpl->parseCurrentBlock();
106
107 $tpl->setCurrentBlock('definition_ids');
108 $ids = array();
109 foreach ($this->definitions as $definition) {
110 array_push($ids, $definition->identifier);
111 }
112 $tpl->setVariable("POST_VAR", $this->getPostVar());
113 $tpl->setVariable("DEFINITION_IDS", join(",", $ids));
114 $tpl->parseCurrentBlock();
115
116 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
117 $tpl->setVariable("TEXT_POINTS", $lng->txt('points'));
118 $tpl->setVariable("TEXT_DEFINITION", $lng->txt('definition'));
119 $tpl->setVariable("TEXT_TERM", $lng->txt('term'));
120 $tpl->setVariable("TEXT_ACTIONS", $lng->txt('actions'));
121
122 $a_tpl->setCurrentBlock("prop_generic");
123 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
124 $a_tpl->parseCurrentBlock();
125 }
126}
$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 key value pair wizard property in a property form.
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.
$i
Definition: disco.tpl.php:19
global $DIC
Definition: saml.php:7