@@ -29,11 +29,11 @@ |
||
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | 31 | foreach($langs as $weight => $codes) { |
32 | - foreach ($codes as $code) { |
|
33 | - if (in_array($code, $available_langs)) { |
|
34 | - return $code; |
|
35 | - } |
|
36 | - } |
|
32 | + foreach ($codes as $code) { |
|
33 | + if (in_array($code, $available_langs)) { |
|
34 | + return $code; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | // No match |
39 | 39 | return null; |
@@ -28,7 +28,7 @@ |
||
28 | 28 | } |
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | - foreach($langs as $weight => $codes) { |
|
31 | + foreach ($langs as $weight => $codes) { |
|
32 | 32 | foreach ($codes as $code) { |
33 | 33 | if (in_array($code, $available_langs)) { |
34 | 34 | return $code; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | * @param string $encoding character encoding scheme of message |
53 | 53 | * @param string $method method for which XML is parsed (unused?) |
54 | 54 | * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
55 | - * @return void|bool |
|
55 | + * @return false|null |
|
56 | 56 | * @access public |
57 | 57 | */ |
58 | 58 | function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
@@ -11,236 +11,236 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class nusoap_parser extends nusoap_base |
13 | 13 | { |
14 | - var $xml = ''; |
|
15 | - var $xml_encoding = ''; |
|
16 | - var $method = ''; |
|
17 | - var $root_struct = ''; |
|
18 | - var $root_struct_name = ''; |
|
19 | - var $root_struct_namespace = ''; |
|
20 | - var $root_header = ''; |
|
14 | + var $xml = ''; |
|
15 | + var $xml_encoding = ''; |
|
16 | + var $method = ''; |
|
17 | + var $root_struct = ''; |
|
18 | + var $root_struct_name = ''; |
|
19 | + var $root_struct_namespace = ''; |
|
20 | + var $root_header = ''; |
|
21 | 21 | var $document = ''; // incoming SOAP body (text) |
22 | - // determines where in the message we are (envelope,header,body,method) |
|
23 | - var $status = ''; |
|
24 | - var $position = 0; |
|
25 | - var $depth = 0; |
|
26 | - var $default_namespace = ''; |
|
27 | - var $namespaces = array(); |
|
28 | - var $message = array(); |
|
22 | + // determines where in the message we are (envelope,header,body,method) |
|
23 | + var $status = ''; |
|
24 | + var $position = 0; |
|
25 | + var $depth = 0; |
|
26 | + var $default_namespace = ''; |
|
27 | + var $namespaces = array(); |
|
28 | + var $message = array(); |
|
29 | 29 | var $parent; |
30 | - var $fault = false; |
|
31 | - var $fault_code = ''; |
|
32 | - var $fault_str = ''; |
|
33 | - var $fault_detail = ''; |
|
34 | - var $depth_array = array(); |
|
35 | - var $debug_flag = true; |
|
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | - var $body_position = 0; |
|
40 | - // for multiref parsing: |
|
41 | - // array of id => pos |
|
42 | - var $ids = array(); |
|
43 | - // array of id => hrefs => pos |
|
44 | - var $multirefs = array(); |
|
45 | - // toggle for auto-decoding element content |
|
46 | - var $decode_utf8 = true; |
|
30 | + var $fault = false; |
|
31 | + var $fault_code = ''; |
|
32 | + var $fault_str = ''; |
|
33 | + var $fault_detail = ''; |
|
34 | + var $depth_array = array(); |
|
35 | + var $debug_flag = true; |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | + var $body_position = 0; |
|
40 | + // for multiref parsing: |
|
41 | + // array of id => pos |
|
42 | + var $ids = array(); |
|
43 | + // array of id => hrefs => pos |
|
44 | + var $multirefs = array(); |
|
45 | + // toggle for auto-decoding element content |
|
46 | + var $decode_utf8 = true; |
|
47 | 47 | |
48 | - /** |
|
49 | - * constructor that actually does the parsing |
|
50 | - * |
|
51 | - * @param string $xml SOAP message |
|
52 | - * @param string $encoding character encoding scheme of message |
|
53 | - * @param string $method method for which XML is parsed (unused?) |
|
54 | - * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | - * @return void|bool |
|
56 | - * @access public |
|
57 | - */ |
|
58 | - function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true) |
|
48 | + /** |
|
49 | + * constructor that actually does the parsing |
|
50 | + * |
|
51 | + * @param string $xml SOAP message |
|
52 | + * @param string $encoding character encoding scheme of message |
|
53 | + * @param string $method method for which XML is parsed (unused?) |
|
54 | + * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | + * @return void|bool |
|
56 | + * @access public |
|
57 | + */ |
|
58 | + function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true) |
|
59 | 59 | { |
60 | - parent::__construct(); |
|
61 | - $this->xml = $xml; |
|
62 | - $this->xml_encoding = $encoding; |
|
63 | - $this->method = $method; |
|
64 | - $this->decode_utf8 = $decode_utf8; |
|
60 | + parent::__construct(); |
|
61 | + $this->xml = $xml; |
|
62 | + $this->xml_encoding = $encoding; |
|
63 | + $this->method = $method; |
|
64 | + $this->decode_utf8 = $decode_utf8; |
|
65 | 65 | |
66 | - // Check whether content has been read. |
|
67 | - if(!empty($this->xml)){ |
|
68 | - // Check XML encoding |
|
69 | - $pos_xml = strpos($xml, '<?xml'); |
|
70 | - if ($pos_xml !== FALSE) { |
|
71 | - $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
72 | - if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
73 | - $xml_encoding = $res[1]; |
|
74 | - if (strtoupper($xml_encoding) != $encoding) { |
|
75 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
76 | - $this->debug($err); |
|
77 | - if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
78 | - $this->setError($err); |
|
79 | - return false; |
|
80 | - } |
|
81 | - // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
82 | - } else { |
|
83 | - $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
84 | - } |
|
85 | - } else { |
|
86 | - $this->debug('No encoding specified in XML declaration'); |
|
87 | - } |
|
88 | - } else { |
|
89 | - $this->debug('No XML declaration'); |
|
90 | - } |
|
91 | - $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
92 | - // Create an XML parser - why not xml_parser_create_ns? |
|
93 | - $this->parser = xml_parser_create($this->xml_encoding); |
|
94 | - // Set the options for parsing the XML data. |
|
95 | - //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
96 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
97 | - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
98 | - // Set the object for the parser. |
|
99 | - xml_set_object($this->parser, $this); |
|
100 | - // Set the element handlers for the parser. |
|
101 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
102 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
66 | + // Check whether content has been read. |
|
67 | + if(!empty($this->xml)){ |
|
68 | + // Check XML encoding |
|
69 | + $pos_xml = strpos($xml, '<?xml'); |
|
70 | + if ($pos_xml !== FALSE) { |
|
71 | + $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
72 | + if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
73 | + $xml_encoding = $res[1]; |
|
74 | + if (strtoupper($xml_encoding) != $encoding) { |
|
75 | + $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
76 | + $this->debug($err); |
|
77 | + if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
78 | + $this->setError($err); |
|
79 | + return false; |
|
80 | + } |
|
81 | + // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
82 | + } else { |
|
83 | + $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
84 | + } |
|
85 | + } else { |
|
86 | + $this->debug('No encoding specified in XML declaration'); |
|
87 | + } |
|
88 | + } else { |
|
89 | + $this->debug('No XML declaration'); |
|
90 | + } |
|
91 | + $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
92 | + // Create an XML parser - why not xml_parser_create_ns? |
|
93 | + $this->parser = xml_parser_create($this->xml_encoding); |
|
94 | + // Set the options for parsing the XML data. |
|
95 | + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
96 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
97 | + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
98 | + // Set the object for the parser. |
|
99 | + xml_set_object($this->parser, $this); |
|
100 | + // Set the element handlers for the parser. |
|
101 | + xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
102 | + xml_set_character_data_handler($this->parser,'character_data'); |
|
103 | 103 | |
104 | - xml_parse($this->parser, $this->xml); |
|
104 | + xml_parse($this->parser, $this->xml); |
|
105 | 105 | |
106 | - // Parse the XML file. |
|
107 | - //if (!xml_parse($this->parser,$xml,true)){ |
|
108 | - if (false) { |
|
109 | - // Display an error message. |
|
110 | - $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
111 | - xml_get_current_line_number($this->parser), |
|
112 | - xml_error_string(xml_get_error_code($this->parser))); |
|
113 | - $this->debug($err); |
|
114 | - $this->debug("XML payload:\n" . $xml); |
|
115 | - $this->setError($err); |
|
116 | - } else { |
|
117 | - $this->debug('in nusoap_parser ctor, message:'); |
|
118 | - $this->appendDebug($this->varDump($this->message)); |
|
119 | - $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
120 | - // get final value |
|
121 | - $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
122 | - // get header value |
|
123 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
124 | - $this->soapheader = $this->message[$this->root_header]['result']; |
|
125 | - } |
|
126 | - // resolve hrefs/ids |
|
127 | - if(sizeof($this->multirefs) > 0){ |
|
128 | - foreach($this->multirefs as $id => $hrefs){ |
|
129 | - $this->debug('resolving multirefs for id: '.$id); |
|
130 | - $idVal = $this->buildVal($this->ids[$id]); |
|
131 | - if (is_array($idVal) && isset($idVal['!id'])) { |
|
132 | - unset($idVal['!id']); |
|
133 | - } |
|
134 | - foreach($hrefs as $refPos => $ref){ |
|
135 | - $this->debug('resolving href at pos '.$refPos); |
|
136 | - $this->multirefs[$id][$refPos] = $idVal; |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - } |
|
141 | - xml_parser_free($this->parser); |
|
142 | - } else { |
|
143 | - $this->debug('xml was empty, didn\'t parse!'); |
|
144 | - $this->setError('xml was empty, didn\'t parse!'); |
|
145 | - } |
|
146 | - } |
|
106 | + // Parse the XML file. |
|
107 | + //if (!xml_parse($this->parser,$xml,true)){ |
|
108 | + if (false) { |
|
109 | + // Display an error message. |
|
110 | + $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
111 | + xml_get_current_line_number($this->parser), |
|
112 | + xml_error_string(xml_get_error_code($this->parser))); |
|
113 | + $this->debug($err); |
|
114 | + $this->debug("XML payload:\n" . $xml); |
|
115 | + $this->setError($err); |
|
116 | + } else { |
|
117 | + $this->debug('in nusoap_parser ctor, message:'); |
|
118 | + $this->appendDebug($this->varDump($this->message)); |
|
119 | + $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
120 | + // get final value |
|
121 | + $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
122 | + // get header value |
|
123 | + if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
124 | + $this->soapheader = $this->message[$this->root_header]['result']; |
|
125 | + } |
|
126 | + // resolve hrefs/ids |
|
127 | + if(sizeof($this->multirefs) > 0){ |
|
128 | + foreach($this->multirefs as $id => $hrefs){ |
|
129 | + $this->debug('resolving multirefs for id: '.$id); |
|
130 | + $idVal = $this->buildVal($this->ids[$id]); |
|
131 | + if (is_array($idVal) && isset($idVal['!id'])) { |
|
132 | + unset($idVal['!id']); |
|
133 | + } |
|
134 | + foreach($hrefs as $refPos => $ref){ |
|
135 | + $this->debug('resolving href at pos '.$refPos); |
|
136 | + $this->multirefs[$id][$refPos] = $idVal; |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + } |
|
141 | + xml_parser_free($this->parser); |
|
142 | + } else { |
|
143 | + $this->debug('xml was empty, didn\'t parse!'); |
|
144 | + $this->setError('xml was empty, didn\'t parse!'); |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * start-element handler |
|
150 | - * |
|
151 | - * @param resource $parser XML parser object |
|
152 | - * @param string $name element name |
|
153 | - * @param array $attrs associative array of attributes |
|
154 | - * @access private |
|
155 | - */ |
|
156 | - function start_element($parser, $name, $attrs) { |
|
148 | + /** |
|
149 | + * start-element handler |
|
150 | + * |
|
151 | + * @param resource $parser XML parser object |
|
152 | + * @param string $name element name |
|
153 | + * @param array $attrs associative array of attributes |
|
154 | + * @access private |
|
155 | + */ |
|
156 | + function start_element($parser, $name, $attrs) { |
|
157 | 157 | |
158 | - // position in a total number of elements, starting from 0 |
|
159 | - // update class level pos |
|
160 | - $pos = $this->position++; |
|
161 | - // and set mine |
|
162 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
163 | - // depth = how many levels removed from root? |
|
164 | - // set mine as current global depth and increment global depth value |
|
165 | - $this->message[$pos]['depth'] = $this->depth++; |
|
158 | + // position in a total number of elements, starting from 0 |
|
159 | + // update class level pos |
|
160 | + $pos = $this->position++; |
|
161 | + // and set mine |
|
162 | + $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
163 | + // depth = how many levels removed from root? |
|
164 | + // set mine as current global depth and increment global depth value |
|
165 | + $this->message[$pos]['depth'] = $this->depth++; |
|
166 | 166 | |
167 | - // else add self as child to whoever the current parent is |
|
168 | - if($pos != 0){ |
|
169 | - $this->message[$this->parent]['children'] .= '|'.$pos; |
|
170 | - } |
|
171 | - // set my parent |
|
172 | - $this->message[$pos]['parent'] = $this->parent; |
|
173 | - // set self as current parent |
|
174 | - $this->parent = $pos; |
|
175 | - // set self as current value for this depth |
|
176 | - $this->depth_array[$this->depth] = $pos; |
|
177 | - // get element prefix |
|
178 | - if(strpos($name,':')){ |
|
179 | - // get ns prefix |
|
180 | - $prefix = substr($name,0,strpos($name,':')); |
|
181 | - // get unqualified name |
|
182 | - $name = substr(strstr($name,':'),1); |
|
183 | - } |
|
184 | - // set status |
|
185 | - if ($name == 'Envelope' && $this->status == '') { |
|
186 | - $this->status = 'envelope'; |
|
187 | - } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
188 | - $this->root_header = $pos; |
|
189 | - $this->status = 'header'; |
|
190 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
191 | - $this->status = 'body'; |
|
192 | - $this->body_position = $pos; |
|
193 | - // set method |
|
194 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
195 | - $this->status = 'method'; |
|
196 | - $this->root_struct_name = $name; |
|
197 | - $this->root_struct = $pos; |
|
198 | - $this->message[$pos]['type'] = 'struct'; |
|
199 | - $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
200 | - } |
|
201 | - // set my status |
|
202 | - $this->message[$pos]['status'] = $this->status; |
|
203 | - // set name |
|
204 | - $this->message[$pos]['name'] = htmlspecialchars($name); |
|
205 | - // set attrs |
|
206 | - $this->message[$pos]['attrs'] = $attrs; |
|
167 | + // else add self as child to whoever the current parent is |
|
168 | + if($pos != 0){ |
|
169 | + $this->message[$this->parent]['children'] .= '|'.$pos; |
|
170 | + } |
|
171 | + // set my parent |
|
172 | + $this->message[$pos]['parent'] = $this->parent; |
|
173 | + // set self as current parent |
|
174 | + $this->parent = $pos; |
|
175 | + // set self as current value for this depth |
|
176 | + $this->depth_array[$this->depth] = $pos; |
|
177 | + // get element prefix |
|
178 | + if(strpos($name,':')){ |
|
179 | + // get ns prefix |
|
180 | + $prefix = substr($name,0,strpos($name,':')); |
|
181 | + // get unqualified name |
|
182 | + $name = substr(strstr($name,':'),1); |
|
183 | + } |
|
184 | + // set status |
|
185 | + if ($name == 'Envelope' && $this->status == '') { |
|
186 | + $this->status = 'envelope'; |
|
187 | + } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
188 | + $this->root_header = $pos; |
|
189 | + $this->status = 'header'; |
|
190 | + } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
191 | + $this->status = 'body'; |
|
192 | + $this->body_position = $pos; |
|
193 | + // set method |
|
194 | + } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
195 | + $this->status = 'method'; |
|
196 | + $this->root_struct_name = $name; |
|
197 | + $this->root_struct = $pos; |
|
198 | + $this->message[$pos]['type'] = 'struct'; |
|
199 | + $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
200 | + } |
|
201 | + // set my status |
|
202 | + $this->message[$pos]['status'] = $this->status; |
|
203 | + // set name |
|
204 | + $this->message[$pos]['name'] = htmlspecialchars($name); |
|
205 | + // set attrs |
|
206 | + $this->message[$pos]['attrs'] = $attrs; |
|
207 | 207 | |
208 | - // loop through atts, logging ns and type declarations |
|
208 | + // loop through atts, logging ns and type declarations |
|
209 | 209 | $attstr = ''; |
210 | - foreach($attrs as $key => $value){ |
|
211 | - $key_prefix = $this->getPrefix($key); |
|
212 | - $key_localpart = $this->getLocalPart($key); |
|
213 | - // if ns declarations, add to class level array of valid namespaces |
|
210 | + foreach($attrs as $key => $value){ |
|
211 | + $key_prefix = $this->getPrefix($key); |
|
212 | + $key_localpart = $this->getLocalPart($key); |
|
213 | + // if ns declarations, add to class level array of valid namespaces |
|
214 | 214 | if($key_prefix == 'xmlns'){ |
215 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
216 | - $this->XMLSchemaVersion = $value; |
|
217 | - $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
218 | - $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
219 | - } |
|
215 | + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
216 | + $this->XMLSchemaVersion = $value; |
|
217 | + $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
218 | + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
219 | + } |
|
220 | 220 | $this->namespaces[$key_localpart] = $value; |
221 | - // set method namespace |
|
222 | - if($name == $this->root_struct_name){ |
|
223 | - $this->methodNamespace = $value; |
|
224 | - } |
|
225 | - // if it's a type declaration, set type |
|
221 | + // set method namespace |
|
222 | + if($name == $this->root_struct_name){ |
|
223 | + $this->methodNamespace = $value; |
|
224 | + } |
|
225 | + // if it's a type declaration, set type |
|
226 | 226 | } elseif($key_localpart == 'type'){ |
227 | - if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
228 | - // do nothing: already processed arrayType |
|
229 | - } else { |
|
230 | - $value_prefix = $this->getPrefix($value); |
|
231 | - $value_localpart = $this->getLocalPart($value); |
|
232 | - $this->message[$pos]['type'] = $value_localpart; |
|
233 | - $this->message[$pos]['typePrefix'] = $value_prefix; |
|
234 | - if(isset($this->namespaces[$value_prefix])){ |
|
235 | - $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
236 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
237 | - $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
238 | - } |
|
239 | - // should do something here with the namespace of specified type? |
|
240 | - } |
|
241 | - } elseif($key_localpart == 'arrayType'){ |
|
242 | - $this->message[$pos]['type'] = 'array'; |
|
243 | - /* do arrayType ereg here |
|
227 | + if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
228 | + // do nothing: already processed arrayType |
|
229 | + } else { |
|
230 | + $value_prefix = $this->getPrefix($value); |
|
231 | + $value_localpart = $this->getLocalPart($value); |
|
232 | + $this->message[$pos]['type'] = $value_localpart; |
|
233 | + $this->message[$pos]['typePrefix'] = $value_prefix; |
|
234 | + if(isset($this->namespaces[$value_prefix])){ |
|
235 | + $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
236 | + } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
237 | + $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
238 | + } |
|
239 | + // should do something here with the namespace of specified type? |
|
240 | + } |
|
241 | + } elseif($key_localpart == 'arrayType'){ |
|
242 | + $this->message[$pos]['type'] = 'array'; |
|
243 | + /* do arrayType ereg here |
|
244 | 244 | [1] arrayTypeValue ::= atype asize |
245 | 245 | [2] atype ::= QName rank* |
246 | 246 | [3] rank ::= '[' (',')* ']' |
@@ -248,129 +248,129 @@ discard block |
||
248 | 248 | [5] length ::= nextDimension* Digit+ |
249 | 249 | [6] nextDimension ::= Digit+ ',' |
250 | 250 | */ |
251 | - $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
252 | - if(preg_match($expr,$value,$regs)){ |
|
253 | - $this->message[$pos]['typePrefix'] = $regs[1]; |
|
254 | - $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
255 | - if (isset($this->namespaces[$regs[1]])) { |
|
256 | - $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
257 | - } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
258 | - $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
259 | - } |
|
260 | - $this->message[$pos]['arrayType'] = $regs[2]; |
|
261 | - $this->message[$pos]['arraySize'] = $regs[3]; |
|
262 | - $this->message[$pos]['arrayCols'] = $regs[4]; |
|
263 | - } |
|
264 | - // specifies nil value (or not) |
|
265 | - } elseif ($key_localpart == 'nil'){ |
|
266 | - $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
267 | - // some other attribute |
|
268 | - } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
269 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
270 | - } |
|
251 | + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
252 | + if(preg_match($expr,$value,$regs)){ |
|
253 | + $this->message[$pos]['typePrefix'] = $regs[1]; |
|
254 | + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
255 | + if (isset($this->namespaces[$regs[1]])) { |
|
256 | + $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
257 | + } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
258 | + $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
259 | + } |
|
260 | + $this->message[$pos]['arrayType'] = $regs[2]; |
|
261 | + $this->message[$pos]['arraySize'] = $regs[3]; |
|
262 | + $this->message[$pos]['arrayCols'] = $regs[4]; |
|
263 | + } |
|
264 | + // specifies nil value (or not) |
|
265 | + } elseif ($key_localpart == 'nil'){ |
|
266 | + $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
267 | + // some other attribute |
|
268 | + } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
269 | + $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
270 | + } |
|
271 | 271 | |
272 | - if ($key == 'xmlns') { |
|
273 | - $this->default_namespace = $value; |
|
274 | - } |
|
275 | - // log id |
|
276 | - if($key == 'id'){ |
|
277 | - $this->ids[$value] = $pos; |
|
278 | - } |
|
279 | - // root |
|
280 | - if($key_localpart == 'root' && $value == 1){ |
|
281 | - $this->status = 'method'; |
|
282 | - $this->root_struct_name = $name; |
|
283 | - $this->root_struct = $pos; |
|
284 | - $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
285 | - } |
|
272 | + if ($key == 'xmlns') { |
|
273 | + $this->default_namespace = $value; |
|
274 | + } |
|
275 | + // log id |
|
276 | + if($key == 'id'){ |
|
277 | + $this->ids[$value] = $pos; |
|
278 | + } |
|
279 | + // root |
|
280 | + if($key_localpart == 'root' && $value == 1){ |
|
281 | + $this->status = 'method'; |
|
282 | + $this->root_struct_name = $name; |
|
283 | + $this->root_struct = $pos; |
|
284 | + $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
285 | + } |
|
286 | 286 | // for doclit |
287 | 287 | $attstr .= " $key=\"$value\""; |
288 | - } |
|
288 | + } |
|
289 | 289 | // get namespace - must be done after namespace atts are processed |
290 | - if(isset($prefix)){ |
|
291 | - $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
292 | - $this->default_namespace = $this->namespaces[$prefix]; |
|
293 | - } else { |
|
294 | - $this->message[$pos]['namespace'] = $this->default_namespace; |
|
295 | - } |
|
290 | + if(isset($prefix)){ |
|
291 | + $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
292 | + $this->default_namespace = $this->namespaces[$prefix]; |
|
293 | + } else { |
|
294 | + $this->message[$pos]['namespace'] = $this->default_namespace; |
|
295 | + } |
|
296 | 296 | if($this->status == 'header'){ |
297 | - if ($this->root_header != $pos) { |
|
298 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
299 | - } |
|
297 | + if ($this->root_header != $pos) { |
|
298 | + $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
299 | + } |
|
300 | 300 | } elseif($this->root_struct_name != ''){ |
301 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
301 | + $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
302 | 302 | } |
303 | - } |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * end-element handler |
|
307 | - * |
|
308 | - * @param resource $parser XML parser object |
|
309 | - * @param string $name element name |
|
310 | - * @access private |
|
311 | - */ |
|
312 | - function end_element($parser, $name) { |
|
313 | - // position of current element is equal to the last value left in depth_array for my depth |
|
314 | - $pos = $this->depth_array[$this->depth--]; |
|
305 | + /** |
|
306 | + * end-element handler |
|
307 | + * |
|
308 | + * @param resource $parser XML parser object |
|
309 | + * @param string $name element name |
|
310 | + * @access private |
|
311 | + */ |
|
312 | + function end_element($parser, $name) { |
|
313 | + // position of current element is equal to the last value left in depth_array for my depth |
|
314 | + $pos = $this->depth_array[$this->depth--]; |
|
315 | 315 | |
316 | 316 | // get element prefix |
317 | - if(strpos($name,':')){ |
|
318 | - // get ns prefix |
|
319 | - $prefix = substr($name,0,strpos($name,':')); |
|
320 | - // get unqualified name |
|
321 | - $name = substr(strstr($name,':'),1); |
|
322 | - } |
|
317 | + if(strpos($name,':')){ |
|
318 | + // get ns prefix |
|
319 | + $prefix = substr($name,0,strpos($name,':')); |
|
320 | + // get unqualified name |
|
321 | + $name = substr(strstr($name,':'),1); |
|
322 | + } |
|
323 | 323 | |
324 | - // build to native type |
|
325 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
326 | - // deal w/ multirefs |
|
327 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
328 | - // get id |
|
329 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
330 | - // add placeholder to href array |
|
331 | - $this->multirefs[$id][$pos] = 'placeholder'; |
|
332 | - // add set a reference to it as the result value |
|
333 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
324 | + // build to native type |
|
325 | + if(isset($this->body_position) && $pos > $this->body_position){ |
|
326 | + // deal w/ multirefs |
|
327 | + if(isset($this->message[$pos]['attrs']['href'])){ |
|
328 | + // get id |
|
329 | + $id = substr($this->message[$pos]['attrs']['href'],1); |
|
330 | + // add placeholder to href array |
|
331 | + $this->multirefs[$id][$pos] = 'placeholder'; |
|
332 | + // add set a reference to it as the result value |
|
333 | + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
334 | 334 | // build complexType values |
335 | - } elseif($this->message[$pos]['children'] != ''){ |
|
336 | - // if result has already been generated (struct/array) |
|
337 | - if(!isset($this->message[$pos]['result'])){ |
|
338 | - $this->message[$pos]['result'] = $this->buildVal($pos); |
|
339 | - } |
|
340 | - // build complexType values of attributes and possibly simpleContent |
|
341 | - } elseif (isset($this->message[$pos]['xattrs'])) { |
|
342 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
343 | - $this->message[$pos]['xattrs']['!'] = null; |
|
344 | - } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
345 | - if (isset($this->message[$pos]['type'])) { |
|
346 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
347 | - } else { |
|
348 | - $parent = $this->message[$pos]['parent']; |
|
349 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
350 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
351 | - } else { |
|
352 | - $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
356 | - $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
357 | - // set value of simpleType (or nil complexType) |
|
358 | - } else { |
|
359 | - //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
360 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
361 | - $this->message[$pos]['xattrs']['!'] = null; |
|
362 | - } elseif (isset($this->message[$pos]['type'])) { |
|
363 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
364 | - } else { |
|
365 | - $parent = $this->message[$pos]['parent']; |
|
366 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
367 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
368 | - } else { |
|
369 | - $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
370 | - } |
|
371 | - } |
|
335 | + } elseif($this->message[$pos]['children'] != ''){ |
|
336 | + // if result has already been generated (struct/array) |
|
337 | + if(!isset($this->message[$pos]['result'])){ |
|
338 | + $this->message[$pos]['result'] = $this->buildVal($pos); |
|
339 | + } |
|
340 | + // build complexType values of attributes and possibly simpleContent |
|
341 | + } elseif (isset($this->message[$pos]['xattrs'])) { |
|
342 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
343 | + $this->message[$pos]['xattrs']['!'] = null; |
|
344 | + } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
345 | + if (isset($this->message[$pos]['type'])) { |
|
346 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
347 | + } else { |
|
348 | + $parent = $this->message[$pos]['parent']; |
|
349 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
350 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
351 | + } else { |
|
352 | + $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | + $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
357 | + // set value of simpleType (or nil complexType) |
|
358 | + } else { |
|
359 | + //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
360 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
361 | + $this->message[$pos]['xattrs']['!'] = null; |
|
362 | + } elseif (isset($this->message[$pos]['type'])) { |
|
363 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
364 | + } else { |
|
365 | + $parent = $this->message[$pos]['parent']; |
|
366 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
367 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
368 | + } else { |
|
369 | + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
370 | + } |
|
371 | + } |
|
372 | 372 | |
373 | - /* add value to parent's result, if parent is struct/array |
|
373 | + /* add value to parent's result, if parent is struct/array |
|
374 | 374 | $parent = $this->message[$pos]['parent']; |
375 | 375 | if($this->message[$parent]['type'] != 'map'){ |
376 | 376 | if(strtolower($this->message[$parent]['type']) == 'array'){ |
@@ -380,261 +380,261 @@ discard block |
||
380 | 380 | } |
381 | 381 | } |
382 | 382 | */ |
383 | - } |
|
384 | - } |
|
383 | + } |
|
384 | + } |
|
385 | 385 | |
386 | 386 | // for doclit |
387 | 387 | if($this->status == 'header'){ |
388 | - if ($this->root_header != $pos) { |
|
389 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
390 | - } |
|
388 | + if ($this->root_header != $pos) { |
|
389 | + $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
390 | + } |
|
391 | 391 | } elseif($pos >= $this->root_struct){ |
392 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
392 | + $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
393 | 393 | } |
394 | - // switch status |
|
395 | - if ($pos == $this->root_struct){ |
|
396 | - $this->status = 'body'; |
|
397 | - $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
398 | - } elseif ($pos == $this->root_header) { |
|
399 | - $this->status = 'envelope'; |
|
400 | - } elseif ($name == 'Body' && $this->status == 'body') { |
|
401 | - $this->status = 'envelope'; |
|
402 | - } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
403 | - $this->status = 'envelope'; |
|
404 | - } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
405 | - $this->status = ''; |
|
406 | - } |
|
407 | - // set parent back to my parent |
|
408 | - $this->parent = $this->message[$pos]['parent']; |
|
409 | - } |
|
394 | + // switch status |
|
395 | + if ($pos == $this->root_struct){ |
|
396 | + $this->status = 'body'; |
|
397 | + $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
398 | + } elseif ($pos == $this->root_header) { |
|
399 | + $this->status = 'envelope'; |
|
400 | + } elseif ($name == 'Body' && $this->status == 'body') { |
|
401 | + $this->status = 'envelope'; |
|
402 | + } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
403 | + $this->status = 'envelope'; |
|
404 | + } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
405 | + $this->status = ''; |
|
406 | + } |
|
407 | + // set parent back to my parent |
|
408 | + $this->parent = $this->message[$pos]['parent']; |
|
409 | + } |
|
410 | 410 | |
411 | - /** |
|
412 | - * element content handler |
|
413 | - * |
|
414 | - * @param resource $parser XML parser object |
|
415 | - * @param string $data element content |
|
416 | - * @access private |
|
417 | - */ |
|
418 | - function character_data($parser, $data) |
|
411 | + /** |
|
412 | + * element content handler |
|
413 | + * |
|
414 | + * @param resource $parser XML parser object |
|
415 | + * @param string $data element content |
|
416 | + * @access private |
|
417 | + */ |
|
418 | + function character_data($parser, $data) |
|
419 | 419 | { |
420 | - $pos = $this->depth_array[$this->depth]; |
|
421 | - if ($this->xml_encoding == 'UTF-8'){ |
|
422 | - // TODO: add an option to disable this for folks who want |
|
423 | - // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
424 | - // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
425 | - if($this->decode_utf8){ |
|
426 | - $data = utf8_decode($data); |
|
427 | - } |
|
428 | - } |
|
420 | + $pos = $this->depth_array[$this->depth]; |
|
421 | + if ($this->xml_encoding == 'UTF-8'){ |
|
422 | + // TODO: add an option to disable this for folks who want |
|
423 | + // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
424 | + // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
425 | + if($this->decode_utf8){ |
|
426 | + $data = utf8_decode($data); |
|
427 | + } |
|
428 | + } |
|
429 | 429 | $this->message[$pos]['cdata'] .= $data; |
430 | 430 | // for doclit |
431 | 431 | if($this->status == 'header'){ |
432 | - $this->responseHeaders .= $data; |
|
432 | + $this->responseHeaders .= $data; |
|
433 | 433 | } else { |
434 | - $this->document .= $data; |
|
434 | + $this->document .= $data; |
|
435 | 435 | } |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - /** |
|
439 | - * get the parsed message (SOAP Body) |
|
440 | - * |
|
441 | - * @return mixed |
|
442 | - * @access public |
|
443 | - * @deprecated use get_soapbody instead |
|
444 | - */ |
|
445 | - function get_response(){ |
|
446 | - return $this->soapresponse; |
|
447 | - } |
|
438 | + /** |
|
439 | + * get the parsed message (SOAP Body) |
|
440 | + * |
|
441 | + * @return mixed |
|
442 | + * @access public |
|
443 | + * @deprecated use get_soapbody instead |
|
444 | + */ |
|
445 | + function get_response(){ |
|
446 | + return $this->soapresponse; |
|
447 | + } |
|
448 | 448 | |
449 | - /** |
|
450 | - * get the parsed SOAP Body (NULL if there was none) |
|
451 | - * |
|
452 | - * @return mixed |
|
453 | - * @access public |
|
454 | - */ |
|
455 | - function get_soapbody(){ |
|
456 | - return $this->soapresponse; |
|
457 | - } |
|
449 | + /** |
|
450 | + * get the parsed SOAP Body (NULL if there was none) |
|
451 | + * |
|
452 | + * @return mixed |
|
453 | + * @access public |
|
454 | + */ |
|
455 | + function get_soapbody(){ |
|
456 | + return $this->soapresponse; |
|
457 | + } |
|
458 | 458 | |
459 | - /** |
|
460 | - * get the parsed SOAP Header (NULL if there was none) |
|
461 | - * |
|
462 | - * @return mixed |
|
463 | - * @access public |
|
464 | - */ |
|
465 | - function get_soapheader(){ |
|
466 | - return $this->soapheader; |
|
467 | - } |
|
459 | + /** |
|
460 | + * get the parsed SOAP Header (NULL if there was none) |
|
461 | + * |
|
462 | + * @return mixed |
|
463 | + * @access public |
|
464 | + */ |
|
465 | + function get_soapheader(){ |
|
466 | + return $this->soapheader; |
|
467 | + } |
|
468 | 468 | |
469 | - /** |
|
470 | - * get the unparsed SOAP Header |
|
471 | - * |
|
472 | - * @return string XML or empty if no Header |
|
473 | - * @access public |
|
474 | - */ |
|
475 | - function getHeaders(){ |
|
476 | - return $this->responseHeaders; |
|
477 | - } |
|
469 | + /** |
|
470 | + * get the unparsed SOAP Header |
|
471 | + * |
|
472 | + * @return string XML or empty if no Header |
|
473 | + * @access public |
|
474 | + */ |
|
475 | + function getHeaders(){ |
|
476 | + return $this->responseHeaders; |
|
477 | + } |
|
478 | 478 | |
479 | - /** |
|
480 | - * decodes simple types into PHP variables |
|
481 | - * |
|
482 | - * @param string $value value to decode |
|
483 | - * @param string $type XML type to decode |
|
484 | - * @param string $typens XML type namespace to decode |
|
485 | - * @return mixed PHP value |
|
486 | - * @access private |
|
487 | - */ |
|
488 | - function decodeSimple($value, $type, $typens) { |
|
489 | - // TODO: use the namespace! |
|
490 | - if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
491 | - return (string) $value; |
|
492 | - } |
|
493 | - if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
494 | - return (int) $value; |
|
495 | - } |
|
496 | - if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
497 | - return (double) $value; |
|
498 | - } |
|
499 | - if ($type == 'boolean') { |
|
500 | - if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
501 | - return false; |
|
502 | - } |
|
503 | - return (boolean) $value; |
|
504 | - } |
|
505 | - if ($type == 'base64' || $type == 'base64Binary') { |
|
506 | - $this->debug('Decode base64 value'); |
|
507 | - return base64_decode($value); |
|
508 | - } |
|
509 | - // obscure numeric types |
|
510 | - if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
511 | - || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
512 | - || $type == 'unsignedInt' |
|
513 | - || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
514 | - return (int) $value; |
|
515 | - } |
|
516 | - // bogus: parser treats array with no elements as a simple type |
|
517 | - if ($type == 'array') { |
|
518 | - return array(); |
|
519 | - } |
|
520 | - // everything else |
|
521 | - return (string) $value; |
|
522 | - } |
|
479 | + /** |
|
480 | + * decodes simple types into PHP variables |
|
481 | + * |
|
482 | + * @param string $value value to decode |
|
483 | + * @param string $type XML type to decode |
|
484 | + * @param string $typens XML type namespace to decode |
|
485 | + * @return mixed PHP value |
|
486 | + * @access private |
|
487 | + */ |
|
488 | + function decodeSimple($value, $type, $typens) { |
|
489 | + // TODO: use the namespace! |
|
490 | + if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
491 | + return (string) $value; |
|
492 | + } |
|
493 | + if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
494 | + return (int) $value; |
|
495 | + } |
|
496 | + if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
497 | + return (double) $value; |
|
498 | + } |
|
499 | + if ($type == 'boolean') { |
|
500 | + if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
501 | + return false; |
|
502 | + } |
|
503 | + return (boolean) $value; |
|
504 | + } |
|
505 | + if ($type == 'base64' || $type == 'base64Binary') { |
|
506 | + $this->debug('Decode base64 value'); |
|
507 | + return base64_decode($value); |
|
508 | + } |
|
509 | + // obscure numeric types |
|
510 | + if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
511 | + || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
512 | + || $type == 'unsignedInt' |
|
513 | + || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
514 | + return (int) $value; |
|
515 | + } |
|
516 | + // bogus: parser treats array with no elements as a simple type |
|
517 | + if ($type == 'array') { |
|
518 | + return array(); |
|
519 | + } |
|
520 | + // everything else |
|
521 | + return (string) $value; |
|
522 | + } |
|
523 | 523 | |
524 | - /** |
|
525 | - * builds response structures for compound values (arrays/structs) |
|
526 | - * and scalars |
|
527 | - * |
|
528 | - * @param integer $pos position in node tree |
|
529 | - * @return mixed PHP value |
|
530 | - * @access private |
|
531 | - */ |
|
532 | - function buildVal($pos){ |
|
533 | - if(!isset($this->message[$pos]['type'])){ |
|
534 | - $this->message[$pos]['type'] = ''; |
|
535 | - } |
|
536 | - $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
537 | - // if there are children... |
|
538 | - if($this->message[$pos]['children'] != ''){ |
|
539 | - $this->debug('in buildVal, there are children'); |
|
540 | - $children = explode('|',$this->message[$pos]['children']); |
|
541 | - array_shift($children); // knock off empty |
|
542 | - // md array |
|
543 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
544 | - $r=0; // rowcount |
|
545 | - $c=0; // colcount |
|
546 | - foreach($children as $child_pos){ |
|
547 | - $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
548 | - $params[$r][] = $this->message[$child_pos]['result']; |
|
549 | - $c++; |
|
550 | - if($c == $this->message[$pos]['arrayCols']){ |
|
551 | - $c = 0; |
|
552 | - $r++; |
|
553 | - } |
|
524 | + /** |
|
525 | + * builds response structures for compound values (arrays/structs) |
|
526 | + * and scalars |
|
527 | + * |
|
528 | + * @param integer $pos position in node tree |
|
529 | + * @return mixed PHP value |
|
530 | + * @access private |
|
531 | + */ |
|
532 | + function buildVal($pos){ |
|
533 | + if(!isset($this->message[$pos]['type'])){ |
|
534 | + $this->message[$pos]['type'] = ''; |
|
535 | + } |
|
536 | + $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
537 | + // if there are children... |
|
538 | + if($this->message[$pos]['children'] != ''){ |
|
539 | + $this->debug('in buildVal, there are children'); |
|
540 | + $children = explode('|',$this->message[$pos]['children']); |
|
541 | + array_shift($children); // knock off empty |
|
542 | + // md array |
|
543 | + if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
544 | + $r=0; // rowcount |
|
545 | + $c=0; // colcount |
|
546 | + foreach($children as $child_pos){ |
|
547 | + $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
548 | + $params[$r][] = $this->message[$child_pos]['result']; |
|
549 | + $c++; |
|
550 | + if($c == $this->message[$pos]['arrayCols']){ |
|
551 | + $c = 0; |
|
552 | + $r++; |
|
553 | + } |
|
554 | 554 | } |
555 | 555 | // array |
556 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | + } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
557 | 557 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
558 | 558 | foreach($children as $child_pos){ |
559 | - $params[] = &$this->message[$child_pos]['result']; |
|
559 | + $params[] = &$this->message[$child_pos]['result']; |
|
560 | 560 | } |
561 | 561 | // apache Map type: java hashtable |
562 | 562 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
563 | 563 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
564 | 564 | foreach($children as $child_pos){ |
565 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
566 | - $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
565 | + $kv = explode("|",$this->message[$child_pos]['children']); |
|
566 | + $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
567 | 567 | } |
568 | 568 | // generic compound type |
569 | 569 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { |
570 | - } else { |
|
571 | - // Apache Vector type: treat as an array |
|
570 | + } else { |
|
571 | + // Apache Vector type: treat as an array |
|
572 | 572 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); |
573 | - if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
574 | - $notstruct = 1; |
|
575 | - } else { |
|
576 | - $notstruct = 0; |
|
577 | - } |
|
578 | - // |
|
579 | - foreach($children as $child_pos){ |
|
580 | - if($notstruct){ |
|
581 | - $params[] = &$this->message[$child_pos]['result']; |
|
582 | - } else { |
|
583 | - if (isset($params[$this->message[$child_pos]['name']])) { |
|
584 | - // de-serialize repeated element name into an array |
|
585 | - if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
586 | - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
587 | - } |
|
588 | - $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
589 | - } else { |
|
590 | - $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
591 | - } |
|
592 | - } |
|
573 | + if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
574 | + $notstruct = 1; |
|
575 | + } else { |
|
576 | + $notstruct = 0; |
|
593 | 577 | } |
594 | - } |
|
595 | - if (isset($this->message[$pos]['xattrs'])) { |
|
578 | + // |
|
579 | + foreach($children as $child_pos){ |
|
580 | + if($notstruct){ |
|
581 | + $params[] = &$this->message[$child_pos]['result']; |
|
582 | + } else { |
|
583 | + if (isset($params[$this->message[$child_pos]['name']])) { |
|
584 | + // de-serialize repeated element name into an array |
|
585 | + if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
586 | + $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
587 | + } |
|
588 | + $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
589 | + } else { |
|
590 | + $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + } |
|
595 | + if (isset($this->message[$pos]['xattrs'])) { |
|
596 | 596 | $this->debug('in buildVal, handling attributes'); |
597 | - foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
598 | - $params[$n] = $v; |
|
599 | - } |
|
600 | - } |
|
601 | - // handle simpleContent |
|
602 | - if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
597 | + foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
598 | + $params[$n] = $v; |
|
599 | + } |
|
600 | + } |
|
601 | + // handle simpleContent |
|
602 | + if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
603 | 603 | $this->debug('in buildVal, handling simpleContent'); |
604 | - if (isset($this->message[$pos]['type'])) { |
|
605 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
606 | - } else { |
|
607 | - $parent = $this->message[$pos]['parent']; |
|
608 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
609 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
610 | - } else { |
|
611 | - $params['!'] = $this->message[$pos]['cdata']; |
|
612 | - } |
|
613 | - } |
|
614 | - } |
|
615 | - $ret = is_array($params) ? $params : array(); |
|
616 | - $this->debug('in buildVal, return:'); |
|
617 | - //$this->appendDebug($this->varDump($ret)); |
|
618 | - return $ret; |
|
619 | - } else { |
|
620 | - $this->debug('in buildVal, no children, building scalar'); |
|
621 | - $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
622 | - if (isset($this->message[$pos]['type'])) { |
|
623 | - $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
624 | - $this->debug("in buildVal, return: $ret"); |
|
625 | - return $ret; |
|
626 | - } |
|
627 | - $parent = $this->message[$pos]['parent']; |
|
628 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
629 | - $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
630 | - $this->debug("in buildVal, return: $ret"); |
|
631 | - return $ret; |
|
632 | - } |
|
633 | - $ret = $this->message[$pos]['cdata']; |
|
634 | - $this->debug("in buildVal, return: $ret"); |
|
635 | - return $ret; |
|
636 | - } |
|
637 | - } |
|
604 | + if (isset($this->message[$pos]['type'])) { |
|
605 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
606 | + } else { |
|
607 | + $parent = $this->message[$pos]['parent']; |
|
608 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
609 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
610 | + } else { |
|
611 | + $params['!'] = $this->message[$pos]['cdata']; |
|
612 | + } |
|
613 | + } |
|
614 | + } |
|
615 | + $ret = is_array($params) ? $params : array(); |
|
616 | + $this->debug('in buildVal, return:'); |
|
617 | + //$this->appendDebug($this->varDump($ret)); |
|
618 | + return $ret; |
|
619 | + } else { |
|
620 | + $this->debug('in buildVal, no children, building scalar'); |
|
621 | + $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
622 | + if (isset($this->message[$pos]['type'])) { |
|
623 | + $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
624 | + $this->debug("in buildVal, return: $ret"); |
|
625 | + return $ret; |
|
626 | + } |
|
627 | + $parent = $this->message[$pos]['parent']; |
|
628 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
629 | + $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
630 | + $this->debug("in buildVal, return: $ret"); |
|
631 | + return $ret; |
|
632 | + } |
|
633 | + $ret = $this->message[$pos]['cdata']; |
|
634 | + $this->debug("in buildVal, return: $ret"); |
|
635 | + return $ret; |
|
636 | + } |
|
637 | + } |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var $root_struct_name = ''; |
19 | 19 | var $root_struct_namespace = ''; |
20 | 20 | var $root_header = ''; |
21 | - var $document = ''; // incoming SOAP body (text) |
|
21 | + var $document = ''; // incoming SOAP body (text) |
|
22 | 22 | // determines where in the message we are (envelope,header,body,method) |
23 | 23 | var $status = ''; |
24 | 24 | var $position = 0; |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | var $fault_detail = ''; |
34 | 34 | var $depth_array = array(); |
35 | 35 | var $debug_flag = true; |
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | 39 | var $body_position = 0; |
40 | 40 | // for multiref parsing: |
41 | 41 | // array of id => pos |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return void|bool |
56 | 56 | * @access public |
57 | 57 | */ |
58 | - function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true) |
|
58 | + function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) |
|
59 | 59 | { |
60 | 60 | parent::__construct(); |
61 | 61 | $this->xml = $xml; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->decode_utf8 = $decode_utf8; |
65 | 65 | |
66 | 66 | // Check whether content has been read. |
67 | - if(!empty($this->xml)){ |
|
67 | + if (!empty($this->xml)) { |
|
68 | 68 | // Check XML encoding |
69 | 69 | $pos_xml = strpos($xml, '<?xml'); |
70 | 70 | if ($pos_xml !== FALSE) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
73 | 73 | $xml_encoding = $res[1]; |
74 | 74 | if (strtoupper($xml_encoding) != $encoding) { |
75 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | + $err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'"; |
|
76 | 76 | $this->debug($err); |
77 | 77 | if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
78 | 78 | $this->setError($err); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | // Set the object for the parser. |
99 | 99 | xml_set_object($this->parser, $this); |
100 | 100 | // Set the element handlers for the parser. |
101 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
102 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
101 | + xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
102 | + xml_set_character_data_handler($this->parser, 'character_data'); |
|
103 | 103 | |
104 | 104 | xml_parse($this->parser, $this->xml); |
105 | 105 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | xml_get_current_line_number($this->parser), |
112 | 112 | xml_error_string(xml_get_error_code($this->parser))); |
113 | 113 | $this->debug($err); |
114 | - $this->debug("XML payload:\n" . $xml); |
|
114 | + $this->debug("XML payload:\n".$xml); |
|
115 | 115 | $this->setError($err); |
116 | 116 | } else { |
117 | 117 | $this->debug('in nusoap_parser ctor, message:'); |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | // get final value |
121 | 121 | $this->soapresponse = $this->message[$this->root_struct]['result']; |
122 | 122 | // get header value |
123 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | + if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) { |
|
124 | 124 | $this->soapheader = $this->message[$this->root_header]['result']; |
125 | 125 | } |
126 | 126 | // resolve hrefs/ids |
127 | - if(sizeof($this->multirefs) > 0){ |
|
128 | - foreach($this->multirefs as $id => $hrefs){ |
|
127 | + if (sizeof($this->multirefs) > 0) { |
|
128 | + foreach ($this->multirefs as $id => $hrefs) { |
|
129 | 129 | $this->debug('resolving multirefs for id: '.$id); |
130 | 130 | $idVal = $this->buildVal($this->ids[$id]); |
131 | 131 | if (is_array($idVal) && isset($idVal['!id'])) { |
132 | 132 | unset($idVal['!id']); |
133 | 133 | } |
134 | - foreach($hrefs as $refPos => $ref){ |
|
134 | + foreach ($hrefs as $refPos => $ref) { |
|
135 | 135 | $this->debug('resolving href at pos '.$refPos); |
136 | 136 | $this->multirefs[$id][$refPos] = $idVal; |
137 | 137 | } |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | // update class level pos |
160 | 160 | $pos = $this->position++; |
161 | 161 | // and set mine |
162 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | + $this->message[$pos] = array('pos' => $pos, 'children'=>'', 'cdata'=>''); |
|
163 | 163 | // depth = how many levels removed from root? |
164 | 164 | // set mine as current global depth and increment global depth value |
165 | 165 | $this->message[$pos]['depth'] = $this->depth++; |
166 | 166 | |
167 | 167 | // else add self as child to whoever the current parent is |
168 | - if($pos != 0){ |
|
168 | + if ($pos != 0) { |
|
169 | 169 | $this->message[$this->parent]['children'] .= '|'.$pos; |
170 | 170 | } |
171 | 171 | // set my parent |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | // set self as current value for this depth |
176 | 176 | $this->depth_array[$this->depth] = $pos; |
177 | 177 | // get element prefix |
178 | - if(strpos($name,':')){ |
|
178 | + if (strpos($name, ':')) { |
|
179 | 179 | // get ns prefix |
180 | - $prefix = substr($name,0,strpos($name,':')); |
|
180 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
181 | 181 | // get unqualified name |
182 | - $name = substr(strstr($name,':'),1); |
|
182 | + $name = substr(strstr($name, ':'), 1); |
|
183 | 183 | } |
184 | 184 | // set status |
185 | 185 | if ($name == 'Envelope' && $this->status == '') { |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | } elseif ($name == 'Header' && $this->status == 'envelope') { |
188 | 188 | $this->root_header = $pos; |
189 | 189 | $this->status = 'header'; |
190 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | + } elseif ($name == 'Body' && $this->status == 'envelope') { |
|
191 | 191 | $this->status = 'body'; |
192 | 192 | $this->body_position = $pos; |
193 | 193 | // set method |
194 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | + } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) { |
|
195 | 195 | $this->status = 'method'; |
196 | 196 | $this->root_struct_name = $name; |
197 | 197 | $this->root_struct = $pos; |
@@ -207,23 +207,23 @@ discard block |
||
207 | 207 | |
208 | 208 | // loop through atts, logging ns and type declarations |
209 | 209 | $attstr = ''; |
210 | - foreach($attrs as $key => $value){ |
|
210 | + foreach ($attrs as $key => $value) { |
|
211 | 211 | $key_prefix = $this->getPrefix($key); |
212 | 212 | $key_localpart = $this->getLocalPart($key); |
213 | 213 | // if ns declarations, add to class level array of valid namespaces |
214 | - if($key_prefix == 'xmlns'){ |
|
215 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
214 | + if ($key_prefix == 'xmlns') { |
|
215 | + if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) { |
|
216 | 216 | $this->XMLSchemaVersion = $value; |
217 | 217 | $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
218 | 218 | $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
219 | 219 | } |
220 | 220 | $this->namespaces[$key_localpart] = $value; |
221 | 221 | // set method namespace |
222 | - if($name == $this->root_struct_name){ |
|
222 | + if ($name == $this->root_struct_name) { |
|
223 | 223 | $this->methodNamespace = $value; |
224 | 224 | } |
225 | 225 | // if it's a type declaration, set type |
226 | - } elseif($key_localpart == 'type'){ |
|
226 | + } elseif ($key_localpart == 'type') { |
|
227 | 227 | if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
228 | 228 | // do nothing: already processed arrayType |
229 | 229 | } else { |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | $value_localpart = $this->getLocalPart($value); |
232 | 232 | $this->message[$pos]['type'] = $value_localpart; |
233 | 233 | $this->message[$pos]['typePrefix'] = $value_prefix; |
234 | - if(isset($this->namespaces[$value_prefix])){ |
|
234 | + if (isset($this->namespaces[$value_prefix])) { |
|
235 | 235 | $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
236 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | + } else if (isset($attrs['xmlns:'.$value_prefix])) { |
|
237 | 237 | $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
238 | 238 | } |
239 | 239 | // should do something here with the namespace of specified type? |
240 | 240 | } |
241 | - } elseif($key_localpart == 'arrayType'){ |
|
241 | + } elseif ($key_localpart == 'arrayType') { |
|
242 | 242 | $this->message[$pos]['type'] = 'array'; |
243 | 243 | /* do arrayType ereg here |
244 | 244 | [1] arrayTypeValue ::= atype asize |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | [6] nextDimension ::= Digit+ ',' |
250 | 250 | */ |
251 | 251 | $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
252 | - if(preg_match($expr,$value,$regs)){ |
|
252 | + if (preg_match($expr, $value, $regs)) { |
|
253 | 253 | $this->message[$pos]['typePrefix'] = $regs[1]; |
254 | 254 | $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
255 | 255 | if (isset($this->namespaces[$regs[1]])) { |
@@ -262,22 +262,22 @@ discard block |
||
262 | 262 | $this->message[$pos]['arrayCols'] = $regs[4]; |
263 | 263 | } |
264 | 264 | // specifies nil value (or not) |
265 | - } elseif ($key_localpart == 'nil'){ |
|
265 | + } elseif ($key_localpart == 'nil') { |
|
266 | 266 | $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
267 | 267 | // some other attribute |
268 | 268 | } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
269 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | + $this->message[$pos]['xattrs']['!'.$key] = $value; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | if ($key == 'xmlns') { |
273 | 273 | $this->default_namespace = $value; |
274 | 274 | } |
275 | 275 | // log id |
276 | - if($key == 'id'){ |
|
276 | + if ($key == 'id') { |
|
277 | 277 | $this->ids[$value] = $pos; |
278 | 278 | } |
279 | 279 | // root |
280 | - if($key_localpart == 'root' && $value == 1){ |
|
280 | + if ($key_localpart == 'root' && $value == 1) { |
|
281 | 281 | $this->status = 'method'; |
282 | 282 | $this->root_struct_name = $name; |
283 | 283 | $this->root_struct = $pos; |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | $attstr .= " $key=\"$value\""; |
288 | 288 | } |
289 | 289 | // get namespace - must be done after namespace atts are processed |
290 | - if(isset($prefix)){ |
|
290 | + if (isset($prefix)) { |
|
291 | 291 | $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
292 | 292 | $this->default_namespace = $this->namespaces[$prefix]; |
293 | 293 | } else { |
294 | 294 | $this->message[$pos]['namespace'] = $this->default_namespace; |
295 | 295 | } |
296 | - if($this->status == 'header'){ |
|
296 | + if ($this->status == 'header') { |
|
297 | 297 | if ($this->root_header != $pos) { |
298 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + $this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
299 | 299 | } |
300 | - } elseif($this->root_struct_name != ''){ |
|
301 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
300 | + } elseif ($this->root_struct_name != '') { |
|
301 | + $this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
@@ -314,27 +314,27 @@ discard block |
||
314 | 314 | $pos = $this->depth_array[$this->depth--]; |
315 | 315 | |
316 | 316 | // get element prefix |
317 | - if(strpos($name,':')){ |
|
317 | + if (strpos($name, ':')) { |
|
318 | 318 | // get ns prefix |
319 | - $prefix = substr($name,0,strpos($name,':')); |
|
319 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
320 | 320 | // get unqualified name |
321 | - $name = substr(strstr($name,':'),1); |
|
321 | + $name = substr(strstr($name, ':'), 1); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | // build to native type |
325 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | + if (isset($this->body_position) && $pos > $this->body_position) { |
|
326 | 326 | // deal w/ multirefs |
327 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | + if (isset($this->message[$pos]['attrs']['href'])) { |
|
328 | 328 | // get id |
329 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | + $id = substr($this->message[$pos]['attrs']['href'], 1); |
|
330 | 330 | // add placeholder to href array |
331 | 331 | $this->multirefs[$id][$pos] = 'placeholder'; |
332 | 332 | // add set a reference to it as the result value |
333 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
333 | + $this->message[$pos]['result'] = & $this->multirefs[$id][$pos]; |
|
334 | 334 | // build complexType values |
335 | - } elseif($this->message[$pos]['children'] != ''){ |
|
335 | + } elseif ($this->message[$pos]['children'] != '') { |
|
336 | 336 | // if result has already been generated (struct/array) |
337 | - if(!isset($this->message[$pos]['result'])){ |
|
337 | + if (!isset($this->message[$pos]['result'])) { |
|
338 | 338 | $this->message[$pos]['result'] = $this->buildVal($pos); |
339 | 339 | } |
340 | 340 | // build complexType values of attributes and possibly simpleContent |
@@ -384,15 +384,15 @@ discard block |
||
384 | 384 | } |
385 | 385 | |
386 | 386 | // for doclit |
387 | - if($this->status == 'header'){ |
|
387 | + if ($this->status == 'header') { |
|
388 | 388 | if ($this->root_header != $pos) { |
389 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + $this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
390 | 390 | } |
391 | - } elseif($pos >= $this->root_struct){ |
|
392 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
391 | + } elseif ($pos >= $this->root_struct) { |
|
392 | + $this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
393 | 393 | } |
394 | 394 | // switch status |
395 | - if ($pos == $this->root_struct){ |
|
395 | + if ($pos == $this->root_struct) { |
|
396 | 396 | $this->status = 'body'; |
397 | 397 | $this->root_struct_namespace = $this->message[$pos]['namespace']; |
398 | 398 | } elseif ($pos == $this->root_header) { |
@@ -418,17 +418,17 @@ discard block |
||
418 | 418 | function character_data($parser, $data) |
419 | 419 | { |
420 | 420 | $pos = $this->depth_array[$this->depth]; |
421 | - if ($this->xml_encoding == 'UTF-8'){ |
|
421 | + if ($this->xml_encoding == 'UTF-8') { |
|
422 | 422 | // TODO: add an option to disable this for folks who want |
423 | 423 | // raw UTF-8 that, e.g., might not map to iso-8859-1 |
424 | 424 | // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
425 | - if($this->decode_utf8){ |
|
425 | + if ($this->decode_utf8) { |
|
426 | 426 | $data = utf8_decode($data); |
427 | 427 | } |
428 | 428 | } |
429 | 429 | $this->message[$pos]['cdata'] .= $data; |
430 | 430 | // for doclit |
431 | - if($this->status == 'header'){ |
|
431 | + if ($this->status == 'header') { |
|
432 | 432 | $this->responseHeaders .= $data; |
433 | 433 | } else { |
434 | 434 | $this->document .= $data; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @access public |
443 | 443 | * @deprecated use get_soapbody instead |
444 | 444 | */ |
445 | - function get_response(){ |
|
445 | + function get_response() { |
|
446 | 446 | return $this->soapresponse; |
447 | 447 | } |
448 | 448 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @return mixed |
453 | 453 | * @access public |
454 | 454 | */ |
455 | - function get_soapbody(){ |
|
455 | + function get_soapbody() { |
|
456 | 456 | return $this->soapresponse; |
457 | 457 | } |
458 | 458 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @return mixed |
463 | 463 | * @access public |
464 | 464 | */ |
465 | - function get_soapheader(){ |
|
465 | + function get_soapheader() { |
|
466 | 466 | return $this->soapheader; |
467 | 467 | } |
468 | 468 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @return string XML or empty if no Header |
473 | 473 | * @access public |
474 | 474 | */ |
475 | - function getHeaders(){ |
|
475 | + function getHeaders() { |
|
476 | 476 | return $this->responseHeaders; |
477 | 477 | } |
478 | 478 | |
@@ -529,40 +529,40 @@ discard block |
||
529 | 529 | * @return mixed PHP value |
530 | 530 | * @access private |
531 | 531 | */ |
532 | - function buildVal($pos){ |
|
533 | - if(!isset($this->message[$pos]['type'])){ |
|
532 | + function buildVal($pos) { |
|
533 | + if (!isset($this->message[$pos]['type'])) { |
|
534 | 534 | $this->message[$pos]['type'] = ''; |
535 | 535 | } |
536 | 536 | $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
537 | 537 | // if there are children... |
538 | - if($this->message[$pos]['children'] != ''){ |
|
538 | + if ($this->message[$pos]['children'] != '') { |
|
539 | 539 | $this->debug('in buildVal, there are children'); |
540 | - $children = explode('|',$this->message[$pos]['children']); |
|
540 | + $children = explode('|', $this->message[$pos]['children']); |
|
541 | 541 | array_shift($children); // knock off empty |
542 | 542 | // md array |
543 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
544 | - $r=0; // rowcount |
|
545 | - $c=0; // colcount |
|
546 | - foreach($children as $child_pos){ |
|
543 | + if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') { |
|
544 | + $r = 0; // rowcount |
|
545 | + $c = 0; // colcount |
|
546 | + foreach ($children as $child_pos) { |
|
547 | 547 | $this->debug("in buildVal, got an MD array element: $r, $c"); |
548 | 548 | $params[$r][] = $this->message[$child_pos]['result']; |
549 | 549 | $c++; |
550 | - if($c == $this->message[$pos]['arrayCols']){ |
|
550 | + if ($c == $this->message[$pos]['arrayCols']) { |
|
551 | 551 | $c = 0; |
552 | 552 | $r++; |
553 | 553 | } |
554 | 554 | } |
555 | 555 | // array |
556 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | + } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') { |
|
557 | 557 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
558 | - foreach($children as $child_pos){ |
|
558 | + foreach ($children as $child_pos) { |
|
559 | 559 | $params[] = &$this->message[$child_pos]['result']; |
560 | 560 | } |
561 | 561 | // apache Map type: java hashtable |
562 | - } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
|
562 | + } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
563 | 563 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
564 | - foreach($children as $child_pos){ |
|
565 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
564 | + foreach ($children as $child_pos) { |
|
565 | + $kv = explode("|", $this->message[$child_pos]['children']); |
|
566 | 566 | $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
567 | 567 | } |
568 | 568 | // generic compound type |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | $notstruct = 0; |
577 | 577 | } |
578 | 578 | // |
579 | - foreach($children as $child_pos){ |
|
580 | - if($notstruct){ |
|
579 | + foreach ($children as $child_pos) { |
|
580 | + if ($notstruct) { |
|
581 | 581 | $params[] = &$this->message[$child_pos]['result']; |
582 | 582 | } else { |
583 | 583 | if (isset($params[$this->message[$child_pos]['name']])) { |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
356 | - * @return int |
|
356 | + * @return string |
|
357 | 357 | */ |
358 | 358 | public function selectPassPercentage() |
359 | 359 | { |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * tells if questions are selected randomly, and if so returns the draws |
463 | 463 | * |
464 | 464 | * @author Olivier Brouckaert |
465 | - * @return integer - 0 if not random, otherwise the draws |
|
465 | + * @return boolean - 0 if not random, otherwise the draws |
|
466 | 466 | */ |
467 | 467 | public function isRandom() |
468 | 468 | { |
@@ -2830,7 +2830,7 @@ discard block |
||
2830 | 2830 | * @param int int lp id |
2831 | 2831 | * @param int int lp item id |
2832 | 2832 | * @param int int lp item_view id |
2833 | - * @param float $weight |
|
2833 | + * @param integer $weight |
|
2834 | 2834 | * @param array question list |
2835 | 2835 | */ |
2836 | 2836 | public function save_stat_track_exercise_info( |
@@ -5327,6 +5327,9 @@ discard block |
||
5327 | 5327 | } |
5328 | 5328 | } |
5329 | 5329 | |
5330 | + /** |
|
5331 | + * @param integer $exe_id |
|
5332 | + */ |
|
5330 | 5333 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
5331 | 5334 | { |
5332 | 5335 | if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
@@ -5478,7 +5481,7 @@ discard block |
||
5478 | 5481 | * @param int Maximum number of attempts (0 if no limit) |
5479 | 5482 | * @param int Feedback type |
5480 | 5483 | * @todo this was function was added due the import exercise via CSV |
5481 | - * @return int New exercise ID |
|
5484 | + * @return string New exercise ID |
|
5482 | 5485 | */ |
5483 | 5486 | public function createExercise( |
5484 | 5487 | $title, |
@@ -6813,7 +6816,7 @@ discard block |
||
6813 | 6816 | * @param bool $show_comment |
6814 | 6817 | * @param null $exercise_feedback |
6815 | 6818 | * @param bool $show_answers |
6816 | - * @param null $modelType |
|
6819 | + * @param integer $modelType |
|
6817 | 6820 | * @param bool $categoryMinusOne |
6818 | 6821 | * @return bool|null|string |
6819 | 6822 | */ |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | $label = get_lang('NextQuestion'); |
1967 | 1967 | $class = 'btn btn-primary'; |
1968 | 1968 | } |
1969 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1969 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1970 | 1970 | if ($this->type == ONE_PER_PAGE) { |
1971 | 1971 | if ($questionNum != 1) { |
1972 | 1972 | $prev_question = $questionNum - 2; |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | $all_label = get_lang('EndTest'); |
1992 | 1992 | $class = 'btn btn-warning'; |
1993 | 1993 | } |
1994 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1994 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | 1996 | $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
1997 | 1997 | $html .= $all_button; |
@@ -3774,7 +3774,7 @@ discard block |
||
3774 | 3774 | |
3775 | 3775 | //Fixes multiple answer question in order to be exact |
3776 | 3776 | //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
3777 | - /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3777 | + /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3778 | 3778 | $diff = @array_diff($answer_correct_array, $real_answers); |
3779 | 3779 | |
3780 | 3780 | // All good answers or nothing works like exact |
@@ -5073,8 +5073,8 @@ discard block |
||
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
5076 | - * @return string |
|
5077 | - */ |
|
5076 | + * @return string |
|
5077 | + */ |
|
5078 | 5078 | public function get_formated_title() |
5079 | 5079 | { |
5080 | 5080 | return api_html_entity_decode($this->selectTitle()); |
@@ -3243,7 +3243,9 @@ discard block |
||
3243 | 3243 | $organs_at_risk_hit = 0; |
3244 | 3244 | $questionScore = 0; |
3245 | 3245 | |
3246 | - if ($debug) error_log('Start answer loop '); |
|
3246 | + if ($debug) { |
|
3247 | + error_log('Start answer loop '); |
|
3248 | + } |
|
3247 | 3249 | |
3248 | 3250 | $answer_correct_array = array(); |
3249 | 3251 | |
@@ -3372,7 +3374,9 @@ discard block |
||
3372 | 3374 | } |
3373 | 3375 | $totalScore += $answerWeighting; |
3374 | 3376 | |
3375 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
3377 | + if ($debug) { |
|
3378 | + error_log("studentChoice: $studentChoice"); |
|
3379 | + } |
|
3376 | 3380 | break; |
3377 | 3381 | case GLOBAL_MULTIPLE_ANSWER: |
3378 | 3382 | if ($from_database) { |
@@ -3397,7 +3401,9 @@ discard block |
||
3397 | 3401 | $real_answers[$answerId] = (bool)$studentChoice; |
3398 | 3402 | } |
3399 | 3403 | $totalScore += $answerWeighting; |
3400 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
3404 | + if ($debug) { |
|
3405 | + error_log("studentChoice: $studentChoice"); |
|
3406 | + } |
|
3401 | 3407 | break; |
3402 | 3408 | case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
3403 | 3409 | if ($from_database) { |
@@ -4143,7 +4149,9 @@ discard block |
||
4143 | 4149 | } // end switch Answertype |
4144 | 4150 | |
4145 | 4151 | if ($show_result) { |
4146 | - if ($debug) error_log('Showing questions $from '.$from); |
|
4152 | + if ($debug) { |
|
4153 | + error_log('Showing questions $from '.$from); |
|
4154 | + } |
|
4147 | 4155 | if ($from == 'exercise_result') { |
4148 | 4156 | //display answers (if not matching type, or if the answer is correct) |
4149 | 4157 | if ( |
@@ -4440,7 +4448,9 @@ discard block |
||
4440 | 4448 | } |
4441 | 4449 | } |
4442 | 4450 | } else { |
4443 | - if ($debug) error_log('Showing questions $from '.$from); |
|
4451 | + if ($debug) { |
|
4452 | + error_log('Showing questions $from '.$from); |
|
4453 | + } |
|
4444 | 4454 | |
4445 | 4455 | switch ($answerType) { |
4446 | 4456 | case UNIQUE_ANSWER: |
@@ -4786,10 +4796,14 @@ discard block |
||
4786 | 4796 | } |
4787 | 4797 | } |
4788 | 4798 | } |
4789 | - if ($debug) error_log(' ------ '); |
|
4799 | + if ($debug) { |
|
4800 | + error_log(' ------ '); |
|
4801 | + } |
|
4790 | 4802 | } // end for that loops over all answers of the current question |
4791 | 4803 | |
4792 | - if ($debug) error_log('-- end answer loop --'); |
|
4804 | + if ($debug) { |
|
4805 | + error_log('-- end answer loop --'); |
|
4806 | + } |
|
4793 | 4807 | |
4794 | 4808 | $final_answer = true; |
4795 | 4809 | |
@@ -4862,7 +4876,9 @@ discard block |
||
4862 | 4876 | // some results that haven't been stored in the database yet |
4863 | 4877 | if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
4864 | 4878 | |
4865 | - if ($debug) error_log('$from AND this is a hotspot kind of question '); |
|
4879 | + if ($debug) { |
|
4880 | + error_log('$from AND this is a hotspot kind of question '); |
|
4881 | + } |
|
4866 | 4882 | |
4867 | 4883 | $my_exe_id = 0; |
4868 | 4884 | $from_database = 0; |
@@ -5038,8 +5054,12 @@ discard block |
||
5038 | 5054 | // stored by exercise_results.php (using the session) |
5039 | 5055 | |
5040 | 5056 | if ($saved_results) { |
5041 | - if ($debug) error_log("Save question results $saved_results"); |
|
5042 | - if ($debug) error_log(print_r($choice ,1 )); |
|
5057 | + if ($debug) { |
|
5058 | + error_log("Save question results $saved_results"); |
|
5059 | + } |
|
5060 | + if ($debug) { |
|
5061 | + error_log(print_r($choice ,1 )); |
|
5062 | + } |
|
5043 | 5063 | |
5044 | 5064 | if (empty($choice)) { |
5045 | 5065 | $choice = 0; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public $feedback_type; |
30 | 30 | public $end_time; |
31 | 31 | public $start_time; |
32 | - public $questionList; // array with the list of this exercise's questions |
|
32 | + public $questionList; // array with the list of this exercise's questions |
|
33 | 33 | /* including question list of the media */ |
34 | 34 | public $questionListUncompressed; |
35 | 35 | public $results_disabled; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); |
130 | 130 | $table_lp_item = Database::get_course_table(TABLE_LP_ITEM); |
131 | 131 | |
132 | - $id = intval($id); |
|
132 | + $id = intval($id); |
|
133 | 133 | if (empty($this->course_id)) { |
134 | 134 | |
135 | 135 | return false; |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | public function isRandom() |
468 | 468 | { |
469 | - if($this->random > 0 || $this->random == -1) { |
|
469 | + if ($this->random > 0 || $this->random == -1) { |
|
470 | 470 | return true; |
471 | 471 | } else { |
472 | 472 | return false; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | $question_media = null; |
628 | 628 | if (!empty($objQuestionTmp->parent_id)) { |
629 | 629 | $objQuestionMedia = Question::read($objQuestionTmp->parent_id); |
630 | - $question_media = Question::getMediaLabel($objQuestionMedia->question); |
|
630 | + $question_media = Question::getMediaLabel($objQuestionMedia->question); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM).$question_media); |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | $cat = new TestCategory(); |
1023 | 1023 | $cat = $cat->getCategory($categoryId); |
1024 | 1024 | |
1025 | - $cat = (array)$cat; |
|
1025 | + $cat = (array) $cat; |
|
1026 | 1026 | $cat['iid'] = $cat['id']; |
1027 | 1027 | //*$cat['name'] = $cat['name']; |
1028 | 1028 | |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | */ |
1235 | 1235 | public function updateTitle($title) |
1236 | 1236 | { |
1237 | - $this->exercise=$title; |
|
1237 | + $this->exercise = $title; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | */ |
1245 | 1245 | public function updateAttempts($attempts) |
1246 | 1246 | { |
1247 | - $this->attempts=$attempts; |
|
1247 | + $this->attempts = $attempts; |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | /** |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | */ |
1255 | 1255 | public function updateFeedbackType($feedback_type) |
1256 | 1256 | { |
1257 | - $this->feedback_type=$feedback_type; |
|
1257 | + $this->feedback_type = $feedback_type; |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | /** |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | */ |
1266 | 1266 | public function updateDescription($description) |
1267 | 1267 | { |
1268 | - $this->description=$description; |
|
1268 | + $this->description = $description; |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | /** |
@@ -1401,23 +1401,23 @@ discard block |
||
1401 | 1401 | * @param string $sound - exercise sound file |
1402 | 1402 | * @param string $delete - ask to delete the file |
1403 | 1403 | */ |
1404 | - public function updateSound($sound,$delete) |
|
1404 | + public function updateSound($sound, $delete) |
|
1405 | 1405 | { |
1406 | 1406 | global $audioPath, $documentPath; |
1407 | 1407 | $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
1408 | 1408 | |
1409 | - if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) { |
|
1410 | - $this->sound=$sound['name']; |
|
1409 | + if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) { |
|
1410 | + $this->sound = $sound['name']; |
|
1411 | 1411 | |
1412 | - if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) { |
|
1412 | + if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) { |
|
1413 | 1413 | $sql = "SELECT 1 FROM $TBL_DOCUMENT |
1414 | - WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'"; |
|
1414 | + WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'"; |
|
1415 | 1415 | $result = Database::query($sql); |
1416 | 1416 | |
1417 | 1417 | if (!Database::num_rows($result)) { |
1418 | 1418 | $id = add_document( |
1419 | 1419 | $this->course, |
1420 | - str_replace($documentPath,'',$audioPath).'/'.$this->sound, |
|
1420 | + str_replace($documentPath, '', $audioPath).'/'.$this->sound, |
|
1421 | 1421 | 'file', |
1422 | 1422 | $sound['size'], |
1423 | 1423 | $sound['name'] |
@@ -1436,8 +1436,8 @@ discard block |
||
1436 | 1436 | ); |
1437 | 1437 | } |
1438 | 1438 | } |
1439 | - } elseif($delete && is_file($audioPath.'/'.$this->sound)) { |
|
1440 | - $this->sound=''; |
|
1439 | + } elseif ($delete && is_file($audioPath.'/'.$this->sound)) { |
|
1440 | + $this->sound = ''; |
|
1441 | 1441 | } |
1442 | 1442 | } |
1443 | 1443 | |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | */ |
1486 | 1486 | public function enable() |
1487 | 1487 | { |
1488 | - $this->active=1; |
|
1488 | + $this->active = 1; |
|
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | /** |
@@ -1495,7 +1495,7 @@ discard block |
||
1495 | 1495 | */ |
1496 | 1496 | public function disable() |
1497 | 1497 | { |
1498 | - $this->active=0; |
|
1498 | + $this->active = 0; |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | /** |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | api_get_user_id() |
1623 | 1623 | ); |
1624 | 1624 | |
1625 | - if (api_get_setting('search_enabled')=='true') { |
|
1625 | + if (api_get_setting('search_enabled') == 'true') { |
|
1626 | 1626 | $this->search_engine_edit(); |
1627 | 1627 | } |
1628 | 1628 | } else { |
@@ -1770,7 +1770,7 @@ discard block |
||
1770 | 1770 | public function removeFromList($questionId) |
1771 | 1771 | { |
1772 | 1772 | // searches the position of the question ID in the list |
1773 | - $pos = array_search($questionId,$this->questionList); |
|
1773 | + $pos = array_search($questionId, $this->questionList); |
|
1774 | 1774 | |
1775 | 1775 | // question not found |
1776 | 1776 | if ($pos === false) { |
@@ -1806,7 +1806,7 @@ discard block |
||
1806 | 1806 | api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizDeleted', api_get_user_id()); |
1807 | 1807 | api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'delete', api_get_user_id()); |
1808 | 1808 | |
1809 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) { |
|
1809 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
1810 | 1810 | $this->search_engine_delete(); |
1811 | 1811 | } |
1812 | 1812 | } |
@@ -1815,7 +1815,7 @@ discard block |
||
1815 | 1815 | * Creates the form to create / edit an exercise |
1816 | 1816 | * @param FormValidator $form |
1817 | 1817 | */ |
1818 | - public function createForm($form, $type='full') |
|
1818 | + public function createForm($form, $type = 'full') |
|
1819 | 1819 | { |
1820 | 1820 | if (empty($type)) { |
1821 | 1821 | $type = 'full'; |
@@ -1846,7 +1846,7 @@ discard block |
||
1846 | 1846 | 'Width' => '100%', |
1847 | 1847 | 'Height' => '150', |
1848 | 1848 | ); |
1849 | - if (is_array($type)){ |
|
1849 | + if (is_array($type)) { |
|
1850 | 1850 | $editor_config = array_merge($editor_config, $type); |
1851 | 1851 | } |
1852 | 1852 | |
@@ -1900,7 +1900,7 @@ discard block |
||
1900 | 1900 | '2', |
1901 | 1901 | array('id' => 'exerciseType_2') |
1902 | 1902 | ); |
1903 | - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions'))); |
|
1903 | + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions'))); |
|
1904 | 1904 | |
1905 | 1905 | // Type of results display on the final page |
1906 | 1906 | $radios_results_disabled = array(); |
@@ -1944,8 +1944,8 @@ discard block |
||
1944 | 1944 | // Type of questions disposition on page |
1945 | 1945 | $radios = array(); |
1946 | 1946 | |
1947 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1948 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1947 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1948 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1949 | 1949 | |
1950 | 1950 | $form->addGroup($radios, null, get_lang('QuestionsPerPage')); |
1951 | 1951 | |
@@ -1955,32 +1955,32 @@ discard block |
||
1955 | 1955 | |
1956 | 1956 | // feedback type |
1957 | 1957 | $radios_feedback = array(); |
1958 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); |
|
1958 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); |
|
1959 | 1959 | |
1960 | 1960 | if (api_get_setting('enable_quiz_scenario') == 'true') { |
1961 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()')); |
|
1961 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()')); |
|
1962 | 1962 | } |
1963 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2')); |
|
1964 | - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions'))); |
|
1963 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2')); |
|
1964 | + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions'))); |
|
1965 | 1965 | |
1966 | 1966 | //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"'); |
1967 | 1967 | $radios_results_disabled = array(); |
1968 | 1968 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1969 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1970 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); |
|
1971 | - $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),''); |
|
1969 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1970 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); |
|
1971 | + $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
|
1972 | 1972 | |
1973 | 1973 | // Type of questions disposition on page |
1974 | 1974 | $radios = array(); |
1975 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); |
|
1976 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2'); |
|
1975 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); |
|
1976 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'); |
|
1977 | 1977 | $form->addGroup($radios, null, get_lang('ExerciseType')); |
1978 | 1978 | |
1979 | 1979 | } else { |
1980 | 1980 | //Show options freeze |
1981 | 1981 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1982 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1983 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); |
|
1982 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1983 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); |
|
1984 | 1984 | $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents')); |
1985 | 1985 | $result_disable_group->freeze(); |
1986 | 1986 | |
@@ -1989,8 +1989,8 @@ discard block |
||
1989 | 1989 | $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE); |
1990 | 1990 | |
1991 | 1991 | // Type of questions disposition on page |
1992 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1993 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1992 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1993 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1994 | 1994 | |
1995 | 1995 | $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage')); |
1996 | 1996 | $type_group->freeze(); |
@@ -2162,7 +2162,7 @@ discard block |
||
2162 | 2162 | ); |
2163 | 2163 | |
2164 | 2164 | // Exercise time limit |
2165 | - $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); |
|
2165 | + $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); |
|
2166 | 2166 | |
2167 | 2167 | $var = Exercise::selectTimeLimit(); |
2168 | 2168 | |
@@ -2174,9 +2174,9 @@ discard block |
||
2174 | 2174 | |
2175 | 2175 | $form->addElement('date_time_picker', 'start_time'); |
2176 | 2176 | |
2177 | - $form->addElement('html','</div>'); |
|
2177 | + $form->addElement('html', '</div>'); |
|
2178 | 2178 | |
2179 | - $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
|
2179 | + $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
|
2180 | 2180 | |
2181 | 2181 | if (!empty($this->end_time)) { |
2182 | 2182 | $form->addElement('html', '<div id="end_date_div" style="display:block;">'); |
@@ -2185,7 +2185,7 @@ discard block |
||
2185 | 2185 | } |
2186 | 2186 | |
2187 | 2187 | $form->addElement('date_time_picker', 'end_time'); |
2188 | - $form->addElement('html','</div>'); |
|
2188 | + $form->addElement('html', '</div>'); |
|
2189 | 2189 | |
2190 | 2190 | //$check_option=$this->selectType(); |
2191 | 2191 | $diplay = 'block'; |
@@ -2195,10 +2195,10 @@ discard block |
||
2195 | 2195 | null, |
2196 | 2196 | get_lang('SaveTheCorrectAnswersForTheNextAttempt') |
2197 | 2197 | ); |
2198 | - $form->addElement('html','<div class="clear"> </div>'); |
|
2198 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
2199 | 2199 | $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); |
2200 | 2200 | |
2201 | - $form->addElement('html','<div id="divtimecontrol" style="display:'.$diplay.';">'); |
|
2201 | + $form->addElement('html', '<div id="divtimecontrol" style="display:'.$diplay.';">'); |
|
2202 | 2202 | |
2203 | 2203 | //Timer control |
2204 | 2204 | //$time_hours_option = range(0,12); |
@@ -2215,12 +2215,12 @@ discard block |
||
2215 | 2215 | ) |
2216 | 2216 | ); |
2217 | 2217 | |
2218 | - $expired_date = (int)$this->selectExpiredTime(); |
|
2218 | + $expired_date = (int) $this->selectExpiredTime(); |
|
2219 | 2219 | |
2220 | - if (($expired_date!='0')) { |
|
2221 | - $form->addElement('html','<div id="timercontrol" style="display:block;">'); |
|
2220 | + if (($expired_date != '0')) { |
|
2221 | + $form->addElement('html', '<div id="timercontrol" style="display:block;">'); |
|
2222 | 2222 | } else { |
2223 | - $form->addElement('html','<div id="timercontrol" style="display:none;">'); |
|
2223 | + $form->addElement('html', '<div id="timercontrol" style="display:none;">'); |
|
2224 | 2224 | } |
2225 | 2225 | $form->addText( |
2226 | 2226 | 'enabletimercontroltotalminutes', |
@@ -2231,7 +2231,7 @@ discard block |
||
2231 | 2231 | 'cols-size' => [2, 2, 8] |
2232 | 2232 | ] |
2233 | 2233 | ); |
2234 | - $form->addElement('html','</div>'); |
|
2234 | + $form->addElement('html', '</div>'); |
|
2235 | 2235 | |
2236 | 2236 | $form->addElement( |
2237 | 2237 | 'text', |
@@ -2256,7 +2256,7 @@ discard block |
||
2256 | 2256 | $defaults = array(); |
2257 | 2257 | |
2258 | 2258 | if (api_get_setting('search_enabled') === 'true') { |
2259 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
2259 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
2260 | 2260 | |
2261 | 2261 | $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); |
2262 | 2262 | $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); |
@@ -2264,15 +2264,15 @@ discard block |
||
2264 | 2264 | $specific_fields = get_specific_field_list(); |
2265 | 2265 | |
2266 | 2266 | foreach ($specific_fields as $specific_field) { |
2267 | - $form->addElement ('text', $specific_field['code'], $specific_field['name']); |
|
2267 | + $form->addElement('text', $specific_field['code'], $specific_field['name']); |
|
2268 | 2268 | $filter = array( |
2269 | 2269 | 'c_id' => api_get_course_int_id(), |
2270 | 2270 | 'field_id' => $specific_field['id'], |
2271 | 2271 | 'ref_id' => $this->id, |
2272 | - 'tool_id' => "'" . TOOL_QUIZ . "'" |
|
2272 | + 'tool_id' => "'".TOOL_QUIZ."'" |
|
2273 | 2273 | ); |
2274 | 2274 | $values = get_specific_field_values_list($filter, array('value')); |
2275 | - if ( !empty($values) ) { |
|
2275 | + if (!empty($values)) { |
|
2276 | 2276 | $arr_str_values = array(); |
2277 | 2277 | foreach ($values as $value) { |
2278 | 2278 | $arr_str_values[] = $value['value']; |
@@ -2282,8 +2282,8 @@ discard block |
||
2282 | 2282 | } |
2283 | 2283 | } |
2284 | 2284 | |
2285 | - $form->addElement('html','</div>'); //End advanced setting |
|
2286 | - $form->addElement('html','</div>'); |
|
2285 | + $form->addElement('html', '</div>'); //End advanced setting |
|
2286 | + $form->addElement('html', '</div>'); |
|
2287 | 2287 | } |
2288 | 2288 | |
2289 | 2289 | // submit |
@@ -2303,10 +2303,10 @@ discard block |
||
2303 | 2303 | } |
2304 | 2304 | |
2305 | 2305 | // defaults |
2306 | - if ($type=='full') { |
|
2306 | + if ($type == 'full') { |
|
2307 | 2307 | if ($this->id > 0) { |
2308 | 2308 | if ($this->random > $this->selectNbrQuestions()) { |
2309 | - $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
2309 | + $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
2310 | 2310 | } else { |
2311 | 2311 | $defaults['randomQuestions'] = $this->random; |
2312 | 2312 | } |
@@ -2335,7 +2335,7 @@ discard block |
||
2335 | 2335 | } |
2336 | 2336 | |
2337 | 2337 | $defaults['start_time'] = !empty($this->start_time) ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); |
2338 | - $defaults['end_time'] = empty($this->end_time) ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600); |
|
2338 | + $defaults['end_time'] = empty($this->end_time) ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600); |
|
2339 | 2339 | |
2340 | 2340 | // Get expired time |
2341 | 2341 | if ($this->expired_time != '0') { |
@@ -2356,7 +2356,7 @@ discard block |
||
2356 | 2356 | $defaults['text_when_finished'] = ''; |
2357 | 2357 | $defaults['start_time'] = date('Y-m-d 12:00:00'); |
2358 | 2358 | $defaults['display_category_name'] = 1; |
2359 | - $defaults['end_time'] = date('Y-m-d 12:00:00', time()+84600); |
|
2359 | + $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); |
|
2360 | 2360 | $defaults['pass_percentage'] = ''; |
2361 | 2361 | $defaults['end_button'] = $this->selectEndButton(); |
2362 | 2362 | $defaults['question_selection_type'] = 1; |
@@ -2456,9 +2456,9 @@ discard block |
||
2456 | 2456 | } |
2457 | 2457 | |
2458 | 2458 | if ($form->getSubmitValue('randomAnswers') == 1) { |
2459 | - $this->random_answers=1; |
|
2459 | + $this->random_answers = 1; |
|
2460 | 2460 | } else { |
2461 | - $this->random_answers=0; |
|
2461 | + $this->random_answers = 0; |
|
2462 | 2462 | } |
2463 | 2463 | $this->save($type); |
2464 | 2464 | } |
@@ -2470,9 +2470,9 @@ discard block |
||
2470 | 2470 | } |
2471 | 2471 | $course_id = api_get_course_id(); |
2472 | 2472 | |
2473 | - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
2474 | - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; |
|
2475 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
2473 | + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
2474 | + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
2475 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
2476 | 2476 | |
2477 | 2477 | $specific_fields = get_specific_field_list(); |
2478 | 2478 | $ic_slide = new IndexableChunk(); |
@@ -2482,7 +2482,7 @@ discard block |
||
2482 | 2482 | if (isset($_REQUEST[$specific_field['code']])) { |
2483 | 2483 | $sterms = trim($_REQUEST[$specific_field['code']]); |
2484 | 2484 | if (!empty($sterms)) { |
2485 | - $all_specific_terms .= ' '. $sterms; |
|
2485 | + $all_specific_terms .= ' '.$sterms; |
|
2486 | 2486 | $sterms = explode(',', $sterms); |
2487 | 2487 | foreach ($sterms as $sterm) { |
2488 | 2488 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -2499,15 +2499,15 @@ discard block |
||
2499 | 2499 | $xapian_data = array( |
2500 | 2500 | SE_COURSE_ID => $course_id, |
2501 | 2501 | SE_TOOL_ID => TOOL_QUIZ, |
2502 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
2503 | - SE_USER => (int)api_get_user_id(), |
|
2502 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
2503 | + SE_USER => (int) api_get_user_id(), |
|
2504 | 2504 | ); |
2505 | 2505 | $ic_slide->xapian_data = serialize($xapian_data); |
2506 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
2506 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
2507 | 2507 | $ic_slide->addValue("content", $exercise_description); |
2508 | 2508 | |
2509 | 2509 | $di = new ChamiloIndexer(); |
2510 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
2510 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
2511 | 2511 | $di->connectDb(NULL, NULL, $lang); |
2512 | 2512 | $di->addChunk($ic_slide); |
2513 | 2513 | |
@@ -2526,7 +2526,7 @@ discard block |
||
2526 | 2526 | function search_engine_edit() |
2527 | 2527 | { |
2528 | 2528 | // update search enchine and its values table if enabled |
2529 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { |
|
2529 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
2530 | 2530 | $course_id = api_get_course_id(); |
2531 | 2531 | |
2532 | 2532 | // actually, it consists on delete terms from db, |
@@ -2538,9 +2538,9 @@ discard block |
||
2538 | 2538 | $res = Database::query($sql); |
2539 | 2539 | |
2540 | 2540 | if (Database::num_rows($res) > 0) { |
2541 | - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); |
|
2542 | - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); |
|
2543 | - require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'); |
|
2541 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
2542 | + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); |
|
2543 | + require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'); |
|
2544 | 2544 | |
2545 | 2545 | $se_ref = Database::fetch_array($res); |
2546 | 2546 | $specific_fields = get_specific_field_list(); |
@@ -2551,7 +2551,7 @@ discard block |
||
2551 | 2551 | delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id); |
2552 | 2552 | if (isset($_REQUEST[$specific_field['code']])) { |
2553 | 2553 | $sterms = trim($_REQUEST[$specific_field['code']]); |
2554 | - $all_specific_terms .= ' '. $sterms; |
|
2554 | + $all_specific_terms .= ' '.$sterms; |
|
2555 | 2555 | $sterms = explode(',', $sterms); |
2556 | 2556 | foreach ($sterms as $sterm) { |
2557 | 2557 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -2567,17 +2567,17 @@ discard block |
||
2567 | 2567 | $xapian_data = array( |
2568 | 2568 | SE_COURSE_ID => $course_id, |
2569 | 2569 | SE_TOOL_ID => TOOL_QUIZ, |
2570 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
2571 | - SE_USER => (int)api_get_user_id(), |
|
2570 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
2571 | + SE_USER => (int) api_get_user_id(), |
|
2572 | 2572 | ); |
2573 | 2573 | $ic_slide->xapian_data = serialize($xapian_data); |
2574 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
2574 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
2575 | 2575 | $ic_slide->addValue("content", $exercise_description); |
2576 | 2576 | |
2577 | 2577 | $di = new ChamiloIndexer(); |
2578 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
2578 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
2579 | 2579 | $di->connectDb(NULL, NULL, $lang); |
2580 | - $di->remove_document((int)$se_ref['search_did']); |
|
2580 | + $di->remove_document((int) $se_ref['search_did']); |
|
2581 | 2581 | $di->addChunk($ic_slide); |
2582 | 2582 | |
2583 | 2583 | //index and return search engine document id |
@@ -2602,7 +2602,7 @@ discard block |
||
2602 | 2602 | function search_engine_delete() |
2603 | 2603 | { |
2604 | 2604 | // remove from search engine if enabled |
2605 | - if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) { |
|
2605 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
2606 | 2606 | $course_id = api_get_course_id(); |
2607 | 2607 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
2608 | 2608 | $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1'; |
@@ -2610,19 +2610,19 @@ discard block |
||
2610 | 2610 | $res = Database::query($sql); |
2611 | 2611 | if (Database::num_rows($res) > 0) { |
2612 | 2612 | $row = Database::fetch_array($res); |
2613 | - require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php'); |
|
2613 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
2614 | 2614 | $di = new ChamiloIndexer(); |
2615 | - $di->remove_document((int)$row['search_did']); |
|
2615 | + $di->remove_document((int) $row['search_did']); |
|
2616 | 2616 | unset($di); |
2617 | 2617 | $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); |
2618 | - foreach ( $this->questionList as $question_i) { |
|
2618 | + foreach ($this->questionList as $question_i) { |
|
2619 | 2619 | $sql = 'SELECT type FROM %s WHERE id=%s'; |
2620 | 2620 | $sql = sprintf($sql, $tbl_quiz_question, $question_i); |
2621 | 2621 | $qres = Database::query($sql); |
2622 | 2622 | if (Database::num_rows($qres) > 0) { |
2623 | 2623 | $qrow = Database::fetch_array($qres); |
2624 | 2624 | $objQuestion = Question::getInstance($qrow['type']); |
2625 | - $objQuestion = Question::read((int)$question_i); |
|
2625 | + $objQuestion = Question::read((int) $question_i); |
|
2626 | 2626 | $objQuestion->search_engine_edit($this->id, FALSE, TRUE); |
2627 | 2627 | unset($objQuestion); |
2628 | 2628 | } |
@@ -2633,7 +2633,7 @@ discard block |
||
2633 | 2633 | Database::query($sql); |
2634 | 2634 | |
2635 | 2635 | // remove terms from db |
2636 | - require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php'; |
|
2636 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
2637 | 2637 | delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id); |
2638 | 2638 | } |
2639 | 2639 | } |
@@ -2799,25 +2799,25 @@ discard block |
||
2799 | 2799 | $lp_id = 0; |
2800 | 2800 | } |
2801 | 2801 | if (empty($lp_item_id)) { |
2802 | - $lp_item_id = 0; |
|
2802 | + $lp_item_id = 0; |
|
2803 | 2803 | } |
2804 | 2804 | if (empty($lp_item_view_id)) { |
2805 | 2805 | $lp_item_view_id = 0; |
2806 | 2806 | } |
2807 | - $condition = ' WHERE exe_exo_id = ' . "'" . $this->id . "'" .' AND |
|
2808 | - exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND |
|
2809 | - c_id = ' . api_get_course_int_id() . ' AND |
|
2810 | - status = ' . "'" . Database::escape_string($status). "'" . ' AND |
|
2811 | - orig_lp_id = ' . "'" . $lp_id . "'" . ' AND |
|
2812 | - orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND |
|
2813 | - orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND |
|
2814 | - session_id = ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case |
|
2807 | + $condition = ' WHERE exe_exo_id = '."'".$this->id."'".' AND |
|
2808 | + exe_user_id = ' . "'".api_get_user_id()."'".' AND |
|
2809 | + c_id = ' . api_get_course_int_id().' AND |
|
2810 | + status = ' . "'".Database::escape_string($status)."'".' AND |
|
2811 | + orig_lp_id = ' . "'".$lp_id."'".' AND |
|
2812 | + orig_lp_item_id = ' . "'".$lp_item_id."'".' AND |
|
2813 | + orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND |
|
2814 | + session_id = ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case |
|
2815 | 2815 | |
2816 | 2816 | $sql_track = 'SELECT * FROM '.$track_exercises.$condition; |
2817 | 2817 | |
2818 | 2818 | $result = Database::query($sql_track); |
2819 | 2819 | $new_array = array(); |
2820 | - if (Database::num_rows($result) > 0 ) { |
|
2820 | + if (Database::num_rows($result) > 0) { |
|
2821 | 2821 | $new_array = Database::fetch_array($result, 'ASSOC'); |
2822 | 2822 | $new_array['num_exe'] = Database::num_rows($result); |
2823 | 2823 | } |
@@ -2861,12 +2861,12 @@ discard block |
||
2861 | 2861 | $questionList = array_map('intval', $questionList); |
2862 | 2862 | |
2863 | 2863 | $params = array( |
2864 | - 'exe_exo_id' => $this->id , |
|
2864 | + 'exe_exo_id' => $this->id, |
|
2865 | 2865 | 'exe_user_id' => api_get_user_id(), |
2866 | 2866 | 'c_id' => api_get_course_int_id(), |
2867 | 2867 | 'status' => 'incomplete', |
2868 | 2868 | 'session_id' => api_get_session_id(), |
2869 | - 'data_tracking' => implode(',', $questionList) , |
|
2869 | + 'data_tracking' => implode(',', $questionList), |
|
2870 | 2870 | 'start_date' => api_get_utc_datetime(), |
2871 | 2871 | 'orig_lp_id' => $safe_lp_id, |
2872 | 2872 | 'orig_lp_item_id' => $safe_lp_item_id, |
@@ -2900,7 +2900,7 @@ discard block |
||
2900 | 2900 | $nbrQuestions = $this->get_count_question_list(); |
2901 | 2901 | |
2902 | 2902 | $all_button = $html = $label = ''; |
2903 | - $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null; |
|
2903 | + $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null; |
|
2904 | 2904 | |
2905 | 2905 | if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) { |
2906 | 2906 | $urlTitle = get_lang('ContinueTest'); |
@@ -2911,7 +2911,7 @@ discard block |
||
2911 | 2911 | |
2912 | 2912 | $html .= Display::url( |
2913 | 2913 | $urlTitle, |
2914 | - 'exercise_submit_modal.php?' . http_build_query([ |
|
2914 | + 'exercise_submit_modal.php?'.http_build_query([ |
|
2915 | 2915 | 'learnpath_id' => $safe_lp_id, |
2916 | 2916 | 'learnpath_item_id' => $safe_lp_item_id, |
2917 | 2917 | 'learnpath_item_view_id' => $safe_lp_item_view_id, |
@@ -2928,7 +2928,7 @@ discard block |
||
2928 | 2928 | 'data-size' => 'md' |
2929 | 2929 | ] |
2930 | 2930 | ); |
2931 | - $html .='<br />'; |
|
2931 | + $html .= '<br />'; |
|
2932 | 2932 | } else { |
2933 | 2933 | // User |
2934 | 2934 | if (api_is_allowed_to_session_edit()) { |
@@ -2953,7 +2953,7 @@ discard block |
||
2953 | 2953 | |
2954 | 2954 | //Next question |
2955 | 2955 | if (!empty($questions_in_media)) { |
2956 | - $questions_in_media = "['".implode("','",$questions_in_media)."']"; |
|
2956 | + $questions_in_media = "['".implode("','", $questions_in_media)."']"; |
|
2957 | 2957 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>'; |
2958 | 2958 | } else { |
2959 | 2959 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>'; |
@@ -2971,7 +2971,7 @@ discard block |
||
2971 | 2971 | } |
2972 | 2972 | $class .= ' question-validate-btn'; // used to select it with jquery |
2973 | 2973 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
2974 | - $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
|
2974 | + $all_button .= ' '.Display::span(null, ['id' => 'save_all_reponse']); |
|
2975 | 2975 | $html .= $all_button; |
2976 | 2976 | } |
2977 | 2977 | } |
@@ -3265,11 +3265,11 @@ discard block |
||
3265 | 3265 | $answer = $objAnswerTmp->selectAnswer($answerId); |
3266 | 3266 | $answerComment = $objAnswerTmp->selectComment($answerId); |
3267 | 3267 | $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
3268 | - $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId); |
|
3268 | + $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId); |
|
3269 | 3269 | $answerAutoId = $objAnswerTmp->selectAutoId($answerId); |
3270 | 3270 | $answerIid = isset($objAnswerTmp->iid[$answerId]) ? $objAnswerTmp->iid[$answerId] : ''; |
3271 | 3271 | |
3272 | - $answer_correct_array[$answerId] = (bool)$answerCorrect; |
|
3272 | + $answer_correct_array[$answerId] = (bool) $answerCorrect; |
|
3273 | 3273 | |
3274 | 3274 | if ($debug) { |
3275 | 3275 | error_log("answer auto id: $answerAutoId "); |
@@ -3278,7 +3278,7 @@ discard block |
||
3278 | 3278 | |
3279 | 3279 | // Delineation |
3280 | 3280 | $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); |
3281 | - $answer_delineation_destination=$objAnswerTmp->selectDestination(1); |
|
3281 | + $answer_delineation_destination = $objAnswerTmp->selectDestination(1); |
|
3282 | 3282 | |
3283 | 3283 | switch ($answerType) { |
3284 | 3284 | // for unique answer |
@@ -3291,7 +3291,7 @@ discard block |
||
3291 | 3291 | exe_id = '".$exeId."' AND |
3292 | 3292 | question_id= '".$questionId."'"; |
3293 | 3293 | $result = Database::query($sql); |
3294 | - $choice = Database::result($result,0,"answer"); |
|
3294 | + $choice = Database::result($result, 0, "answer"); |
|
3295 | 3295 | |
3296 | 3296 | $studentChoice = $choice == $answerAutoId ? 1 : 0; |
3297 | 3297 | if ($studentChoice) { |
@@ -3342,7 +3342,7 @@ discard block |
||
3342 | 3342 | } else { |
3343 | 3343 | // If no result then the user just hit don't know |
3344 | 3344 | $studentChoice = 3; |
3345 | - $questionScore += $doubt_score; |
|
3345 | + $questionScore += $doubt_score; |
|
3346 | 3346 | } |
3347 | 3347 | $totalScore = $questionScore; |
3348 | 3348 | break; |
@@ -3358,17 +3358,17 @@ discard block |
||
3358 | 3358 | } |
3359 | 3359 | |
3360 | 3360 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
3361 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
3361 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
3362 | 3362 | |
3363 | 3363 | if ($studentChoice) { |
3364 | - $questionScore +=$answerWeighting; |
|
3364 | + $questionScore += $answerWeighting; |
|
3365 | 3365 | } |
3366 | 3366 | } else { |
3367 | 3367 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
3368 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
3368 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
3369 | 3369 | |
3370 | 3370 | if (isset($studentChoice)) { |
3371 | - $questionScore += $answerWeighting; |
|
3371 | + $questionScore += $answerWeighting; |
|
3372 | 3372 | } |
3373 | 3373 | } |
3374 | 3374 | $totalScore += $answerWeighting; |
@@ -3386,16 +3386,16 @@ discard block |
||
3386 | 3386 | $choice[$ind] = 1; |
3387 | 3387 | } |
3388 | 3388 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
3389 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
3389 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
3390 | 3390 | if ($studentChoice) { |
3391 | - $questionScore +=$answerWeighting; |
|
3391 | + $questionScore += $answerWeighting; |
|
3392 | 3392 | } |
3393 | 3393 | } else { |
3394 | 3394 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
3395 | 3395 | if (isset($studentChoice)) { |
3396 | 3396 | $questionScore += $answerWeighting; |
3397 | 3397 | } |
3398 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
3398 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
3399 | 3399 | } |
3400 | 3400 | $totalScore += $answerWeighting; |
3401 | 3401 | if ($debug) error_log("studentChoice: $studentChoice"); |
@@ -3407,7 +3407,7 @@ discard block |
||
3407 | 3407 | $resultans = Database::query($sql); |
3408 | 3408 | while ($row = Database::fetch_array($resultans)) { |
3409 | 3409 | $ind = $row['answer']; |
3410 | - $result = explode(':',$ind); |
|
3410 | + $result = explode(':', $ind); |
|
3411 | 3411 | if (isset($result[0])) { |
3412 | 3412 | $my_answer_id = isset($result[0]) ? $result[0] : ''; |
3413 | 3413 | $option = isset($result[1]) ? $result[1] : ''; |
@@ -3528,10 +3528,10 @@ discard block |
||
3528 | 3528 | } |
3529 | 3529 | // adds the piece of text that is before the blank |
3530 | 3530 | //and ends with '[' into a general storage array |
3531 | - $real_text[] = api_substr($temp, 0, $pos +1); |
|
3532 | - $answer .= api_substr($temp, 0, $pos +1); |
|
3531 | + $real_text[] = api_substr($temp, 0, $pos + 1); |
|
3532 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
3533 | 3533 | //take the string remaining (after the last "[" we found) |
3534 | - $temp = api_substr($temp, $pos +1); |
|
3534 | + $temp = api_substr($temp, $pos + 1); |
|
3535 | 3535 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
3536 | 3536 | if (($pos = api_strpos($temp, ']')) === false) { |
3537 | 3537 | // adds the end of the text |
@@ -3567,7 +3567,7 @@ discard block |
||
3567 | 3567 | //put the contents of the [] answer tag into correct_tags[] |
3568 | 3568 | $correct_tags[] = api_substr($temp, 0, $pos); |
3569 | 3569 | $j++; |
3570 | - $temp = api_substr($temp, $pos +1); |
|
3570 | + $temp = api_substr($temp, $pos + 1); |
|
3571 | 3571 | } |
3572 | 3572 | $answer = ''; |
3573 | 3573 | $real_correct_tags = $correct_tags; |
@@ -3590,7 +3590,7 @@ discard block |
||
3590 | 3590 | } elseif (!empty($user_tags[$i])) { |
3591 | 3591 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
3592 | 3592 | // adds the word in red at the end of the string, and strikes it |
3593 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
3593 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
3594 | 3594 | } else { |
3595 | 3595 | // adds a tabulation if no word has been typed by the student |
3596 | 3596 | $answer .= ''; // remove that causes issue |
@@ -3609,17 +3609,17 @@ discard block |
||
3609 | 3609 | } elseif (!empty ($user_tags[$i])) { |
3610 | 3610 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
3611 | 3611 | // adds the word in red at the end of the string, and strikes it |
3612 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
3612 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
3613 | 3613 | } else { |
3614 | 3614 | // adds a tabulation if no word has been typed by the student |
3615 | - $answer .= ''; // remove that causes issue |
|
3615 | + $answer .= ''; // remove that causes issue |
|
3616 | 3616 | } |
3617 | 3617 | } |
3618 | 3618 | |
3619 | 3619 | // adds the correct word, followed by ] to close the blank |
3620 | - $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]'; |
|
3621 | - if (isset($real_text[$i +1])) { |
|
3622 | - $answer .= $real_text[$i +1]; |
|
3620 | + $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]'; |
|
3621 | + if (isset($real_text[$i + 1])) { |
|
3622 | + $answer .= $real_text[$i + 1]; |
|
3623 | 3623 | } |
3624 | 3624 | } |
3625 | 3625 | } else { |
@@ -3743,10 +3743,10 @@ discard block |
||
3743 | 3743 | } |
3744 | 3744 | // adds the piece of text that is before the blank |
3745 | 3745 | //and ends with '[' into a general storage array |
3746 | - $realText[] = api_substr($temp, 0, $pos +1); |
|
3747 | - $answer .= api_substr($temp, 0, $pos +1); |
|
3746 | + $realText[] = api_substr($temp, 0, $pos + 1); |
|
3747 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
3748 | 3748 | //take the string remaining (after the last "[" we found) |
3749 | - $temp = api_substr($temp, $pos +1); |
|
3749 | + $temp = api_substr($temp, $pos + 1); |
|
3750 | 3750 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
3751 | 3751 | if (($pos = api_strpos($temp, ']')) === false) { |
3752 | 3752 | // adds the end of the text |
@@ -3787,7 +3787,7 @@ discard block |
||
3787 | 3787 | //put the contents of the [] answer tag into correct_tags[] |
3788 | 3788 | $correctTags[] = api_substr($temp, 0, $pos); |
3789 | 3789 | $j++; |
3790 | - $temp = api_substr($temp, $pos +1); |
|
3790 | + $temp = api_substr($temp, $pos + 1); |
|
3791 | 3791 | } |
3792 | 3792 | $answer = ''; |
3793 | 3793 | $realCorrectTags = $correctTags; |
@@ -3807,7 +3807,7 @@ discard block |
||
3807 | 3807 | } elseif (!empty($userTags[$i])) { |
3808 | 3808 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
3809 | 3809 | // adds the word in red at the end of the string, and strikes it |
3810 | - $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>'; |
|
3810 | + $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>'; |
|
3811 | 3811 | } else { |
3812 | 3812 | // adds a tabulation if no word has been typed by the student |
3813 | 3813 | $answer .= ''; // remove that causes issue |
@@ -3817,19 +3817,19 @@ discard block |
||
3817 | 3817 | if ( |
3818 | 3818 | $this->results_disabled != EXERCISE_FEEDBACK_TYPE_EXAM |
3819 | 3819 | ) { |
3820 | - $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>'; |
|
3820 | + $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>'; |
|
3821 | 3821 | } |
3822 | 3822 | |
3823 | 3823 | $answer .= ']'; |
3824 | 3824 | |
3825 | - if (isset($realText[$i +1])) { |
|
3826 | - $answer .= $realText[$i +1]; |
|
3825 | + if (isset($realText[$i + 1])) { |
|
3826 | + $answer .= $realText[$i + 1]; |
|
3827 | 3827 | } |
3828 | 3828 | } |
3829 | 3829 | break; |
3830 | 3830 | case FREE_ANSWER: |
3831 | 3831 | if ($from_database) { |
3832 | - $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
3832 | + $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
3833 | 3833 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
3834 | 3834 | $resq = Database::query($query); |
3835 | 3835 | $data = Database::fetch_array($resq); |
@@ -3840,9 +3840,9 @@ discard block |
||
3840 | 3840 | $questionScore = $data['marks']; |
3841 | 3841 | |
3842 | 3842 | if ($questionScore == -1) { |
3843 | - $totalScore+= 0; |
|
3843 | + $totalScore += 0; |
|
3844 | 3844 | } else { |
3845 | - $totalScore+= $questionScore; |
|
3845 | + $totalScore += $questionScore; |
|
3846 | 3846 | } |
3847 | 3847 | if ($questionScore == '') { |
3848 | 3848 | $questionScore = 0; |
@@ -3920,7 +3920,7 @@ discard block |
||
3920 | 3920 | |
3921 | 3921 | while ($a_answers = Database::fetch_array($res_answers)) { |
3922 | 3922 | $i_answer_id = $a_answers['id']; //3 |
3923 | - $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
3923 | + $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
3924 | 3924 | $i_answer_correct_answer = $a_answers['correct']; //1 - 2 |
3925 | 3925 | $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4 |
3926 | 3926 | |
@@ -3975,8 +3975,8 @@ discard block |
||
3975 | 3975 | $user_answer = ''; |
3976 | 3976 | } |
3977 | 3977 | echo '<tr>'; |
3978 | - echo '<td>' . $s_answer_label . '</td>'; |
|
3979 | - echo '<td>' . $user_answer; |
|
3978 | + echo '<td>'.$s_answer_label.'</td>'; |
|
3979 | + echo '<td>'.$user_answer; |
|
3980 | 3980 | |
3981 | 3981 | if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
3982 | 3982 | if (isset($real_list[$i_answer_correct_answer]) && $showTotalScoreAndUserChoices == false) { |
@@ -4136,7 +4136,7 @@ discard block |
||
4136 | 4136 | if ($from_database) { |
4137 | 4137 | // getting the user answer |
4138 | 4138 | $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); |
4139 | - $query = "SELECT hotspot_correct, hotspot_coordinate |
|
4139 | + $query = "SELECT hotspot_correct, hotspot_coordinate |
|
4140 | 4140 | FROM $TBL_TRACK_HOTSPOT |
4141 | 4141 | WHERE |
4142 | 4142 | hotspot_exe_id = '".$exeId."' AND |
@@ -4144,20 +4144,20 @@ discard block |
||
4144 | 4144 | hotspot_answer_id='1'"; |
4145 | 4145 | //by default we take 1 because it's a delineation |
4146 | 4146 | $resq = Database::query($query); |
4147 | - $row = Database::fetch_array($resq,'ASSOC'); |
|
4147 | + $row = Database::fetch_array($resq, 'ASSOC'); |
|
4148 | 4148 | |
4149 | 4149 | $choice = $row['hotspot_correct']; |
4150 | 4150 | $user_answer = $row['hotspot_coordinate']; |
4151 | 4151 | |
4152 | 4152 | // THIS is very important otherwise the poly_compile will throw an error!! |
4153 | 4153 | // round-up the coordinates |
4154 | - $coords = explode('/',$user_answer); |
|
4154 | + $coords = explode('/', $user_answer); |
|
4155 | 4155 | $user_array = ''; |
4156 | 4156 | foreach ($coords as $coord) { |
4157 | - list($x,$y) = explode(';',$coord); |
|
4157 | + list($x, $y) = explode(';', $coord); |
|
4158 | 4158 | $user_array .= round($x).';'.round($y).'/'; |
4159 | 4159 | } |
4160 | - $user_array = substr($user_array,0,-1); |
|
4160 | + $user_array = substr($user_array, 0, -1); |
|
4161 | 4161 | } else { |
4162 | 4162 | if (!empty($studentChoice)) { |
4163 | 4163 | $newquestionList[] = $questionId; |
@@ -4167,13 +4167,13 @@ discard block |
||
4167 | 4167 | $studentChoice = $choice[$answerId]; |
4168 | 4168 | $questionScore += $answerWeighting; |
4169 | 4169 | |
4170 | - if ($hotspot_delineation_result[1]==1) { |
|
4170 | + if ($hotspot_delineation_result[1] == 1) { |
|
4171 | 4171 | $totalScore += $answerWeighting; //adding the total |
4172 | 4172 | } |
4173 | 4173 | } |
4174 | 4174 | } |
4175 | - $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
4176 | - $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
4175 | + $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
4176 | + $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
4177 | 4177 | break; |
4178 | 4178 | } // end switch Answertype |
4179 | 4179 | |
@@ -4225,7 +4225,7 @@ discard block |
||
4225 | 4225 | $results_disabled, |
4226 | 4226 | $showTotalScoreAndUserChoices |
4227 | 4227 | ); |
4228 | - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) { |
|
4228 | + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
|
4229 | 4229 | ExerciseShowFunctions::display_multiple_answer_combination_true_false( |
4230 | 4230 | $feedback_type, |
4231 | 4231 | $answerType, |
@@ -4307,13 +4307,13 @@ discard block |
||
4307 | 4307 | $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId]; |
4308 | 4308 | |
4309 | 4309 | //round-up the coordinates |
4310 | - $coords = explode('/',$user_answer); |
|
4310 | + $coords = explode('/', $user_answer); |
|
4311 | 4311 | $user_array = ''; |
4312 | 4312 | foreach ($coords as $coord) { |
4313 | - list($x,$y) = explode(';',$coord); |
|
4313 | + list($x, $y) = explode(';', $coord); |
|
4314 | 4314 | $user_array .= round($x).';'.round($y).'/'; |
4315 | 4315 | } |
4316 | - $user_array = substr($user_array,0,-1); |
|
4316 | + $user_array = substr($user_array, 0, -1); |
|
4317 | 4317 | |
4318 | 4318 | if ($next) { |
4319 | 4319 | |
@@ -4340,7 +4340,7 @@ discard block |
||
4340 | 4340 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); |
4341 | 4341 | // //this is an area in pixels |
4342 | 4342 | if ($debug > 0) { |
4343 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
4343 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
4344 | 4344 | } |
4345 | 4345 | |
4346 | 4346 | if ($overlap < 1) { |
@@ -4353,43 +4353,43 @@ discard block |
||
4353 | 4353 | // that is overlapped by the user's polygon |
4354 | 4354 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
4355 | 4355 | if ($debug > 1) { |
4356 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
4356 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
4357 | 4357 | } |
4358 | 4358 | // the final missing area is the percentage of the initial polygon |
4359 | 4359 | // that is not overlapped by the user's polygon |
4360 | 4360 | $final_missing = 100 - $final_overlap; |
4361 | 4361 | if ($debug > 1) { |
4362 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
4362 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
4363 | 4363 | } |
4364 | 4364 | // the final excess area is the percentage of the initial polygon's size |
4365 | 4365 | // that is covered by the user's polygon outside of the initial polygon |
4366 | 4366 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
4367 | 4367 | if ($debug > 1) { |
4368 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
4368 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
4369 | 4369 | } |
4370 | 4370 | } |
4371 | 4371 | |
4372 | 4372 | //checking the destination parameters parsing the "@@" |
4373 | - $destination_items= explode('@@', $answerDestination); |
|
4373 | + $destination_items = explode('@@', $answerDestination); |
|
4374 | 4374 | $threadhold_total = $destination_items[0]; |
4375 | - $threadhold_items=explode(';',$threadhold_total); |
|
4375 | + $threadhold_items = explode(';', $threadhold_total); |
|
4376 | 4376 | $threadhold1 = $threadhold_items[0]; // overlap |
4377 | 4377 | $threadhold2 = $threadhold_items[1]; // excess |
4378 | - $threadhold3 = $threadhold_items[2]; //missing |
|
4378 | + $threadhold3 = $threadhold_items[2]; //missing |
|
4379 | 4379 | |
4380 | 4380 | // if is delineation |
4381 | - if ($answerId===1) { |
|
4381 | + if ($answerId === 1) { |
|
4382 | 4382 | //setting colors |
4383 | - if ($final_overlap>=$threadhold1) { |
|
4384 | - $overlap_color=true; //echo 'a'; |
|
4383 | + if ($final_overlap >= $threadhold1) { |
|
4384 | + $overlap_color = true; //echo 'a'; |
|
4385 | 4385 | } |
4386 | 4386 | //echo $excess.'-'.$threadhold2; |
4387 | - if ($final_excess<=$threadhold2) { |
|
4388 | - $excess_color=true; //echo 'b'; |
|
4387 | + if ($final_excess <= $threadhold2) { |
|
4388 | + $excess_color = true; //echo 'b'; |
|
4389 | 4389 | } |
4390 | 4390 | //echo '--------'.$missing.'-'.$threadhold3; |
4391 | - if ($final_missing<=$threadhold3) { |
|
4392 | - $missing_color=true; //echo 'c'; |
|
4391 | + if ($final_missing <= $threadhold3) { |
|
4392 | + $missing_color = true; //echo 'c'; |
|
4393 | 4393 | } |
4394 | 4394 | |
4395 | 4395 | // if pass |
@@ -4398,67 +4398,67 @@ discard block |
||
4398 | 4398 | $final_missing <= $threadhold3 && |
4399 | 4399 | $final_excess <= $threadhold2 |
4400 | 4400 | ) { |
4401 | - $next=1; //go to the oars |
|
4402 | - $result_comment=get_lang('Acceptable'); |
|
4403 | - $final_answer = 1; // do not update with update_exercise_attempt |
|
4401 | + $next = 1; //go to the oars |
|
4402 | + $result_comment = get_lang('Acceptable'); |
|
4403 | + $final_answer = 1; // do not update with update_exercise_attempt |
|
4404 | 4404 | } else { |
4405 | - $next=0; |
|
4406 | - $result_comment=get_lang('Unacceptable'); |
|
4407 | - $comment=$answerDestination=$objAnswerTmp->selectComment(1); |
|
4408 | - $answerDestination=$objAnswerTmp->selectDestination(1); |
|
4405 | + $next = 0; |
|
4406 | + $result_comment = get_lang('Unacceptable'); |
|
4407 | + $comment = $answerDestination = $objAnswerTmp->selectComment(1); |
|
4408 | + $answerDestination = $objAnswerTmp->selectDestination(1); |
|
4409 | 4409 | //checking the destination parameters parsing the "@@" |
4410 | - $destination_items= explode('@@', $answerDestination); |
|
4410 | + $destination_items = explode('@@', $answerDestination); |
|
4411 | 4411 | } |
4412 | - } elseif($answerId>1) { |
|
4412 | + } elseif ($answerId > 1) { |
|
4413 | 4413 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
4414 | - if ($debug>0) { |
|
4415 | - error_log(__LINE__.' - answerId is of type noerror',0); |
|
4414 | + if ($debug > 0) { |
|
4415 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
4416 | 4416 | } |
4417 | 4417 | //type no error shouldn't be treated |
4418 | 4418 | $next = 1; |
4419 | 4419 | continue; |
4420 | 4420 | } |
4421 | - if ($debug>0) { |
|
4422 | - error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0); |
|
4421 | + if ($debug > 0) { |
|
4422 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
4423 | 4423 | } |
4424 | 4424 | //check the intersection between the oar and the user |
4425 | 4425 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
4426 | 4426 | //echo 'official';print_r($x_list);print_r($y_list); |
4427 | 4427 | //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list); |
4428 | - $inter= $result['success']; |
|
4428 | + $inter = $result['success']; |
|
4429 | 4429 | |
4430 | 4430 | //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
4431 | - $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
|
4431 | + $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); |
|
4432 | 4432 | |
4433 | - $poly_answer = convert_coordinates($delineation_cord,'|'); |
|
4434 | - $max_coord = poly_get_max($poly_user,$poly_answer); |
|
4435 | - $poly_answer_compiled = poly_compile($poly_answer,$max_coord); |
|
4436 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
4433 | + $poly_answer = convert_coordinates($delineation_cord, '|'); |
|
4434 | + $max_coord = poly_get_max($poly_user, $poly_answer); |
|
4435 | + $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
|
4436 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
4437 | 4437 | |
4438 | 4438 | if ($overlap == false) { |
4439 | 4439 | //all good, no overlap |
4440 | 4440 | $next = 1; |
4441 | 4441 | continue; |
4442 | 4442 | } else { |
4443 | - if ($debug>0) { |
|
4444 | - error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0); |
|
4443 | + if ($debug > 0) { |
|
4444 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
4445 | 4445 | } |
4446 | 4446 | $organs_at_risk_hit++; |
4447 | 4447 | //show the feedback |
4448 | - $next=0; |
|
4449 | - $comment=$answerDestination=$objAnswerTmp->selectComment($answerId); |
|
4450 | - $answerDestination=$objAnswerTmp->selectDestination($answerId); |
|
4451 | - |
|
4452 | - $destination_items= explode('@@', $answerDestination); |
|
4453 | - $try_hotspot=$destination_items[1]; |
|
4454 | - $lp_hotspot=$destination_items[2]; |
|
4455 | - $select_question_hotspot=$destination_items[3]; |
|
4456 | - $url_hotspot=$destination_items[4]; |
|
4448 | + $next = 0; |
|
4449 | + $comment = $answerDestination = $objAnswerTmp->selectComment($answerId); |
|
4450 | + $answerDestination = $objAnswerTmp->selectDestination($answerId); |
|
4451 | + |
|
4452 | + $destination_items = explode('@@', $answerDestination); |
|
4453 | + $try_hotspot = $destination_items[1]; |
|
4454 | + $lp_hotspot = $destination_items[2]; |
|
4455 | + $select_question_hotspot = $destination_items[3]; |
|
4456 | + $url_hotspot = $destination_items[4]; |
|
4457 | 4457 | } |
4458 | 4458 | } |
4459 | 4459 | } else { // the first delineation feedback |
4460 | - if ($debug>0) { |
|
4461 | - error_log(__LINE__.' first',0); |
|
4460 | + if ($debug > 0) { |
|
4461 | + error_log(__LINE__.' first', 0); |
|
4462 | 4462 | } |
4463 | 4463 | } |
4464 | 4464 | } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
@@ -4466,7 +4466,7 @@ discard block |
||
4466 | 4466 | echo Display::tag('td', $answerMatching[$answerId]); |
4467 | 4467 | echo Display::tag( |
4468 | 4468 | 'td', |
4469 | - "$user_answer / " . Display::tag( |
|
4469 | + "$user_answer / ".Display::tag( |
|
4470 | 4470 | 'strong', |
4471 | 4471 | $answerMatching[$answerCorrect], |
4472 | 4472 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -4618,7 +4618,7 @@ discard block |
||
4618 | 4618 | $questionId, |
4619 | 4619 | $objQuestionTmp->getFileUrl(), |
4620 | 4620 | $results_disabled |
4621 | - ) . '</td> |
|
4621 | + ).'</td> |
|
4622 | 4622 | </tr> |
4623 | 4623 | </table>'; |
4624 | 4624 | break; |
@@ -4680,7 +4680,7 @@ discard block |
||
4680 | 4680 | |
4681 | 4681 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels |
4682 | 4682 | if ($debug > 0) { |
4683 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
4683 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
4684 | 4684 | } |
4685 | 4685 | if ($overlap < 1) { |
4686 | 4686 | //shortcut to avoid complicated calculations |
@@ -4691,17 +4691,17 @@ discard block |
||
4691 | 4691 | // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon |
4692 | 4692 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
4693 | 4693 | if ($debug > 1) { |
4694 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
4694 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
4695 | 4695 | } |
4696 | 4696 | // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon |
4697 | 4697 | $final_missing = 100 - $final_overlap; |
4698 | 4698 | if ($debug > 1) { |
4699 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
4699 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
4700 | 4700 | } |
4701 | 4701 | // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon |
4702 | 4702 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
4703 | 4703 | if ($debug > 1) { |
4704 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
4704 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
4705 | 4705 | } |
4706 | 4706 | } |
4707 | 4707 | |
@@ -4711,7 +4711,7 @@ discard block |
||
4711 | 4711 | $threadhold_items = explode(';', $threadhold_total); |
4712 | 4712 | $threadhold1 = $threadhold_items[0]; // overlap |
4713 | 4713 | $threadhold2 = $threadhold_items[1]; // excess |
4714 | - $threadhold3 = $threadhold_items[2]; //missing |
|
4714 | + $threadhold3 = $threadhold_items[2]; //missing |
|
4715 | 4715 | // if is delineation |
4716 | 4716 | if ($answerId === 1) { |
4717 | 4717 | //setting colors |
@@ -4743,14 +4743,14 @@ discard block |
||
4743 | 4743 | } elseif ($answerId > 1) { |
4744 | 4744 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
4745 | 4745 | if ($debug > 0) { |
4746 | - error_log(__LINE__ . ' - answerId is of type noerror', 0); |
|
4746 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
4747 | 4747 | } |
4748 | 4748 | //type no error shouldn't be treated |
4749 | 4749 | $next = 1; |
4750 | 4750 | continue; |
4751 | 4751 | } |
4752 | 4752 | if ($debug > 0) { |
4753 | - error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0); |
|
4753 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
4754 | 4754 | } |
4755 | 4755 | //check the intersection between the oar and the user |
4756 | 4756 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
@@ -4764,7 +4764,7 @@ discard block |
||
4764 | 4764 | $poly_answer = convert_coordinates($delineation_cord, '|'); |
4765 | 4765 | $max_coord = poly_get_max($poly_user, $poly_answer); |
4766 | 4766 | $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
4767 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
4767 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
4768 | 4768 | |
4769 | 4769 | if ($overlap == false) { |
4770 | 4770 | //all good, no overlap |
@@ -4772,7 +4772,7 @@ discard block |
||
4772 | 4772 | continue; |
4773 | 4773 | } else { |
4774 | 4774 | if ($debug > 0) { |
4775 | - error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0); |
|
4775 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
4776 | 4776 | } |
4777 | 4777 | $organs_at_risk_hit++; |
4778 | 4778 | //show the feedback |
@@ -4784,12 +4784,12 @@ discard block |
||
4784 | 4784 | $try_hotspot = $destination_items[1]; |
4785 | 4785 | $lp_hotspot = $destination_items[2]; |
4786 | 4786 | $select_question_hotspot = $destination_items[3]; |
4787 | - $url_hotspot=$destination_items[4]; |
|
4787 | + $url_hotspot = $destination_items[4]; |
|
4788 | 4788 | } |
4789 | 4789 | } |
4790 | 4790 | } else { // the first delineation feedback |
4791 | 4791 | if ($debug > 0) { |
4792 | - error_log(__LINE__ . ' first', 0); |
|
4792 | + error_log(__LINE__.' first', 0); |
|
4793 | 4793 | } |
4794 | 4794 | } |
4795 | 4795 | break; |
@@ -4811,7 +4811,7 @@ discard block |
||
4811 | 4811 | echo Display::tag('td', $answerMatching[$answerId]); |
4812 | 4812 | echo Display::tag( |
4813 | 4813 | 'td', |
4814 | - "$user_answer / " . Display::tag( |
|
4814 | + "$user_answer / ".Display::tag( |
|
4815 | 4815 | 'strong', |
4816 | 4816 | $answerMatching[$answerCorrect], |
4817 | 4817 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -4897,7 +4897,7 @@ discard block |
||
4897 | 4897 | // we use the results from the session (from_db=0) |
4898 | 4898 | // TODO Change this, because it is wrong to show the user |
4899 | 4899 | // some results that haven't been stored in the database yet |
4900 | - if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
|
4900 | + if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) { |
|
4901 | 4901 | |
4902 | 4902 | if ($debug) error_log('$from AND this is a hotspot kind of question '); |
4903 | 4903 | |
@@ -4906,19 +4906,19 @@ discard block |
||
4906 | 4906 | if ($answerType == HOT_SPOT_DELINEATION) { |
4907 | 4907 | if (0) { |
4908 | 4908 | if ($overlap_color) { |
4909 | - $overlap_color='green'; |
|
4909 | + $overlap_color = 'green'; |
|
4910 | 4910 | } else { |
4911 | - $overlap_color='red'; |
|
4911 | + $overlap_color = 'red'; |
|
4912 | 4912 | } |
4913 | 4913 | if ($missing_color) { |
4914 | - $missing_color='green'; |
|
4914 | + $missing_color = 'green'; |
|
4915 | 4915 | } else { |
4916 | - $missing_color='red'; |
|
4916 | + $missing_color = 'red'; |
|
4917 | 4917 | } |
4918 | 4918 | if ($excess_color) { |
4919 | - $excess_color='green'; |
|
4919 | + $excess_color = 'green'; |
|
4920 | 4920 | } else { |
4921 | - $excess_color='red'; |
|
4921 | + $excess_color = 'red'; |
|
4922 | 4922 | } |
4923 | 4923 | if (!is_numeric($final_overlap)) { |
4924 | 4924 | $final_overlap = 0; |
@@ -4930,33 +4930,33 @@ discard block |
||
4930 | 4930 | $final_excess = 0; |
4931 | 4931 | } |
4932 | 4932 | |
4933 | - if ($final_overlap>100) { |
|
4933 | + if ($final_overlap > 100) { |
|
4934 | 4934 | $final_overlap = 100; |
4935 | 4935 | } |
4936 | 4936 | |
4937 | - $table_resume='<table class="data_table"> |
|
4937 | + $table_resume = '<table class="data_table"> |
|
4938 | 4938 | <tr class="row_odd" > |
4939 | 4939 | <td></td> |
4940 | - <td ><b>' . get_lang('Requirements') . '</b></td> |
|
4941 | - <td><b>' . get_lang('YourAnswer') . '</b></td> |
|
4940 | + <td ><b>' . get_lang('Requirements').'</b></td> |
|
4941 | + <td><b>' . get_lang('YourAnswer').'</b></td> |
|
4942 | 4942 | </tr> |
4943 | 4943 | <tr class="row_even"> |
4944 | - <td><b>' . get_lang('Overlap') . '</b></td> |
|
4945 | - <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td> |
|
4946 | - <td><div style="color:' . $overlap_color . '">' |
|
4947 | - . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td> |
|
4944 | + <td><b>' . get_lang('Overlap').'</b></td> |
|
4945 | + <td>' . get_lang('Min').' '.$threadhold1.'</td> |
|
4946 | + <td><div style="color:' . $overlap_color.'">' |
|
4947 | + . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td> |
|
4948 | 4948 | </tr> |
4949 | 4949 | <tr> |
4950 | - <td><b>' . get_lang('Excess') . '</b></td> |
|
4951 | - <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td> |
|
4952 | - <td><div style="color:' . $excess_color . '">' |
|
4953 | - . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td> |
|
4950 | + <td><b>' . get_lang('Excess').'</b></td> |
|
4951 | + <td>' . get_lang('Max').' '.$threadhold2.'</td> |
|
4952 | + <td><div style="color:' . $excess_color.'">' |
|
4953 | + . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td> |
|
4954 | 4954 | </tr> |
4955 | 4955 | <tr class="row_even"> |
4956 | - <td><b>' . get_lang('Missing') . '</b></td> |
|
4957 | - <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td> |
|
4958 | - <td><div style="color:' . $missing_color . '">' |
|
4959 | - . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td> |
|
4956 | + <td><b>' . get_lang('Missing').'</b></td> |
|
4957 | + <td>' . get_lang('Max').' '.$threadhold3.'</td> |
|
4958 | + <td><div style="color:' . $missing_color.'">' |
|
4959 | + . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td> |
|
4960 | 4960 | </tr> |
4961 | 4961 | </table>'; |
4962 | 4962 | if ($next == 0) { |
@@ -4971,20 +4971,20 @@ discard block |
||
4971 | 4971 | $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); |
4972 | 4972 | } |
4973 | 4973 | |
4974 | - echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1> |
|
4974 | + echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1> |
|
4975 | 4975 | <p style="text-align:center">'; |
4976 | 4976 | |
4977 | - $message = '<p>' . get_lang('YourDelineation') . '</p>'; |
|
4977 | + $message = '<p>'.get_lang('YourDelineation').'</p>'; |
|
4978 | 4978 | $message .= $table_resume; |
4979 | - $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />'; |
|
4979 | + $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />'; |
|
4980 | 4980 | if ($organs_at_risk_hit > 0) { |
4981 | - $message .= '<p><b>' . get_lang('OARHit') . '</b></p>'; |
|
4981 | + $message .= '<p><b>'.get_lang('OARHit').'</b></p>'; |
|
4982 | 4982 | } |
4983 | - $message .='<p>' . $comment . '</p>'; |
|
4983 | + $message .= '<p>'.$comment.'</p>'; |
|
4984 | 4984 | echo $message; |
4985 | 4985 | } else { |
4986 | 4986 | echo $hotspot_delineation_result[0]; //prints message |
4987 | - $from_database = 1; // the hotspot_solution.swf needs this variable |
|
4987 | + $from_database = 1; // the hotspot_solution.swf needs this variable |
|
4988 | 4988 | } |
4989 | 4989 | |
4990 | 4990 | //save the score attempts |
@@ -5007,12 +5007,12 @@ discard block |
||
5007 | 5007 | $exerciseResultCoordinates[$quesId] |
5008 | 5008 | ); |
5009 | 5009 | } else { |
5010 | - if ($final_answer==0) { |
|
5010 | + if ($final_answer == 0) { |
|
5011 | 5011 | $questionScore = 0; |
5012 | - $answer=0; |
|
5012 | + $answer = 0; |
|
5013 | 5013 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
5014 | 5014 | if (is_array($exerciseResultCoordinates[$quesId])) { |
5015 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
5015 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
5016 | 5016 | Event::saveExerciseAttemptHotspot( |
5017 | 5017 | $exeId, |
5018 | 5018 | $quesId, |
@@ -5025,7 +5025,7 @@ discard block |
||
5025 | 5025 | } else { |
5026 | 5026 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
5027 | 5027 | if (is_array($exerciseResultCoordinates[$quesId])) { |
5028 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
5028 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
5029 | 5029 | $hotspotValue = (int) $choice[$idx] === 1 ? 1 : 0; |
5030 | 5030 | Event::saveExerciseAttemptHotspot( |
5031 | 5031 | $exeId, |
@@ -5052,7 +5052,7 @@ discard block |
||
5052 | 5052 | echo " |
5053 | 5053 | <tr> |
5054 | 5054 | <td colspan=\"2\"> |
5055 | - <p><em>" . get_lang('HotSpot') . "</em></p> |
|
5055 | + <p><em>" . get_lang('HotSpot')."</em></p> |
|
5056 | 5056 | <div id=\"hotspot-solution-$questionId\"></div> |
5057 | 5057 | <script> |
5058 | 5058 | $(document).on('ready', function () { |
@@ -5087,7 +5087,7 @@ discard block |
||
5087 | 5087 | |
5088 | 5088 | if ($saved_results) { |
5089 | 5089 | if ($debug) error_log("Save question results $saved_results"); |
5090 | - if ($debug) error_log(print_r($choice ,1 )); |
|
5090 | + if ($debug) error_log(print_r($choice, 1)); |
|
5091 | 5091 | |
5092 | 5092 | if (empty($choice)) { |
5093 | 5093 | $choice = 0; |
@@ -5099,14 +5099,14 @@ discard block |
||
5099 | 5099 | $ans = $reply[$i]; |
5100 | 5100 | Event::saveQuestionAttempt( |
5101 | 5101 | $questionScore, |
5102 | - $ans . ':' . $choice[$ans], |
|
5102 | + $ans.':'.$choice[$ans], |
|
5103 | 5103 | $quesId, |
5104 | 5104 | $exeId, |
5105 | 5105 | $i, |
5106 | 5106 | $this->id |
5107 | 5107 | ); |
5108 | 5108 | if ($debug) { |
5109 | - error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]); |
|
5109 | + error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]); |
|
5110 | 5110 | } |
5111 | 5111 | } |
5112 | 5112 | } else { |
@@ -5117,7 +5117,7 @@ discard block |
||
5117 | 5117 | $reply = array_keys($choice); |
5118 | 5118 | |
5119 | 5119 | if ($debug) { |
5120 | - error_log("reply " . print_r($reply, 1) . ""); |
|
5120 | + error_log("reply ".print_r($reply, 1).""); |
|
5121 | 5121 | } |
5122 | 5122 | for ($i = 0; $i < sizeof($reply); $i++) { |
5123 | 5123 | $ans = $reply[$i]; |
@@ -5192,7 +5192,7 @@ discard block |
||
5192 | 5192 | |
5193 | 5193 | Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id); |
5194 | 5194 | } else { |
5195 | - Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id); |
|
5195 | + Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); |
|
5196 | 5196 | } |
5197 | 5197 | } |
5198 | 5198 | |
@@ -5202,8 +5202,8 @@ discard block |
||
5202 | 5202 | |
5203 | 5203 | if ($saved_results) { |
5204 | 5204 | $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
5205 | - $sql = 'UPDATE ' . $stat_table . ' SET |
|
5206 | - exe_result = exe_result + ' . floatval($questionScore) . ' |
|
5205 | + $sql = 'UPDATE '.$stat_table.' SET |
|
5206 | + exe_result = exe_result + ' . floatval($questionScore).' |
|
5207 | 5207 | WHERE exe_id = ' . $exeId; |
5208 | 5208 | Database::query($sql); |
5209 | 5209 | } |
@@ -5227,7 +5227,7 @@ discard block |
||
5227 | 5227 | */ |
5228 | 5228 | public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) |
5229 | 5229 | { |
5230 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
5230 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
5231 | 5231 | return null; |
5232 | 5232 | } |
5233 | 5233 | // Email configuration settings |
@@ -5278,7 +5278,7 @@ discard block |
||
5278 | 5278 | $msg = str_replace("#course#", $courseInfo['name'], $msg1); |
5279 | 5279 | |
5280 | 5280 | if ($origin != 'learnpath') { |
5281 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
5281 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
5282 | 5282 | } |
5283 | 5283 | $msg1 = str_replace("#url#", $url_email, $msg); |
5284 | 5284 | $mail_content = $msg1; |
@@ -5308,7 +5308,7 @@ discard block |
||
5308 | 5308 | */ |
5309 | 5309 | function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) |
5310 | 5310 | { |
5311 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
5311 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
5312 | 5312 | return null; |
5313 | 5313 | } |
5314 | 5314 | // Email configuration settings |
@@ -5371,11 +5371,11 @@ discard block |
||
5371 | 5371 | $msg .= '</table><br />'; |
5372 | 5372 | |
5373 | 5373 | |
5374 | - $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
5375 | - $msg = str_replace("#firstName#", $user_info['firstname'],$msg1); |
|
5376 | - $msg1 = str_replace("#lastName#", $user_info['lastname'],$msg); |
|
5377 | - $msg = str_replace("#mail#", $user_info['email'],$msg1); |
|
5378 | - $msg = str_replace("#course#", $course_info['name'],$msg1); |
|
5374 | + $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
5375 | + $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
|
5376 | + $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
|
5377 | + $msg = str_replace("#mail#", $user_info['email'], $msg1); |
|
5378 | + $msg = str_replace("#course#", $course_info['name'], $msg1); |
|
5379 | 5379 | |
5380 | 5380 | if ($origin != 'learnpath') { |
5381 | 5381 | $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
@@ -5404,7 +5404,7 @@ discard block |
||
5404 | 5404 | |
5405 | 5405 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
5406 | 5406 | { |
5407 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
5407 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
5408 | 5408 | return null; |
5409 | 5409 | } |
5410 | 5410 | // Email configuration settings |
@@ -5428,7 +5428,7 @@ discard block |
||
5428 | 5428 | $answer_type = $item['answer_type']; |
5429 | 5429 | |
5430 | 5430 | if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) { |
5431 | - $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
5431 | + $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
5432 | 5432 | .'<tr>' |
5433 | 5433 | .'<td width="220" valign="top" bgcolor="#E5EDF8"> '.get_lang('Question').'</td>' |
5434 | 5434 | .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>' |
@@ -5461,7 +5461,7 @@ discard block |
||
5461 | 5461 | .'<td> #mail#</td>' |
5462 | 5462 | .'</tr>' |
5463 | 5463 | .'</table>'; |
5464 | - $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />'; |
|
5464 | + $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />'; |
|
5465 | 5465 | $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
5466 | 5466 | $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
5467 | 5467 | $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
@@ -5469,7 +5469,7 @@ discard block |
||
5469 | 5469 | $msg = str_replace("#course#", $course_info['name'], $msg1); |
5470 | 5470 | |
5471 | 5471 | if ($origin != 'learnpath') { |
5472 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
5472 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
5473 | 5473 | } |
5474 | 5474 | $msg1 = str_replace("#url#", $url_email, $msg); |
5475 | 5475 | $mail_content = $msg1; |
@@ -5535,10 +5535,10 @@ discard block |
||
5535 | 5535 | } |
5536 | 5536 | $html = '<div class="question-result">'; |
5537 | 5537 | $html .= Display::page_header( |
5538 | - Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
5538 | + Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
5539 | 5539 | ); |
5540 | 5540 | $html .= Display::description($array); |
5541 | - $html .="</div>"; |
|
5541 | + $html .= "</div>"; |
|
5542 | 5542 | return $html; |
5543 | 5543 | } |
5544 | 5544 | |
@@ -5655,7 +5655,7 @@ discard block |
||
5655 | 5655 | false, |
5656 | 5656 | $objExercise->selectPropagateNeg() |
5657 | 5657 | ); |
5658 | - $totalScore += $question_result['score']; |
|
5658 | + $totalScore += $question_result['score']; |
|
5659 | 5659 | } |
5660 | 5660 | |
5661 | 5661 | if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { |
@@ -5859,7 +5859,7 @@ discard block |
||
5859 | 5859 | } |
5860 | 5860 | |
5861 | 5861 | $rawMessage = ""; |
5862 | - if (!empty($message)){ |
|
5862 | + if (!empty($message)) { |
|
5863 | 5863 | $rawMessage = $message; |
5864 | 5864 | $message = Display::return_message($message, 'warning', false); |
5865 | 5865 | } |
@@ -5875,7 +5875,7 @@ discard block |
||
5875 | 5875 | { |
5876 | 5876 | $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); |
5877 | 5877 | $sql = "SELECT max_score FROM $TBL_LP_ITEM |
5878 | - WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'"; |
|
5878 | + WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'"; |
|
5879 | 5879 | $result = Database::query($sql); |
5880 | 5880 | if (Database::num_rows($result) > 0) { |
5881 | 5881 | return true; |
@@ -6204,7 +6204,7 @@ discard block |
||
6204 | 6204 | $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id "; |
6205 | 6205 | $result = Database::query($sql_track); |
6206 | 6206 | $new_array = array(); |
6207 | - if (Database::num_rows($result) > 0 ) { |
|
6207 | + if (Database::num_rows($result) > 0) { |
|
6208 | 6208 | $new_array = Database::fetch_array($result, 'ASSOC'); |
6209 | 6209 | |
6210 | 6210 | $new_array['duration'] = null; |
@@ -6216,11 +6216,11 @@ discard block |
||
6216 | 6216 | $start_date = api_strtotime($start_date, 'UTC'); |
6217 | 6217 | $end_date = api_strtotime($end_date, 'UTC'); |
6218 | 6218 | if ($start_date && $end_date) { |
6219 | - $mytime = $end_date- $start_date; |
|
6219 | + $mytime = $end_date - $start_date; |
|
6220 | 6220 | $new_learnpath_item = new learnpathItem(null); |
6221 | 6221 | $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime); |
6222 | 6222 | $h = get_lang('h'); |
6223 | - $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); |
|
6223 | + $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp); |
|
6224 | 6224 | $new_array['duration'] = $time_attemp; |
6225 | 6225 | } |
6226 | 6226 | } |
@@ -6242,7 +6242,7 @@ discard block |
||
6242 | 6242 | Database::query($sql); |
6243 | 6243 | } |
6244 | 6244 | } else { |
6245 | - $remind_list = explode(',',$exercise_info['questions_to_check']); |
|
6245 | + $remind_list = explode(',', $exercise_info['questions_to_check']); |
|
6246 | 6246 | |
6247 | 6247 | $remind_list_string = ''; |
6248 | 6248 | if ($action == 'add') { |
@@ -6254,7 +6254,7 @@ discard block |
||
6254 | 6254 | } |
6255 | 6255 | $remind_list_string = implode(',', $remind_list); |
6256 | 6256 | } |
6257 | - } elseif ($action == 'delete') { |
|
6257 | + } elseif ($action == 'delete') { |
|
6258 | 6258 | if (!empty($remind_list)) { |
6259 | 6259 | if (in_array($question_id, $remind_list)) { |
6260 | 6260 | $remind_list = array_flip($remind_list); |
@@ -6483,7 +6483,7 @@ discard block |
||
6483 | 6483 | true |
6484 | 6484 | ); |
6485 | 6485 | |
6486 | - $counter += count($mediaQuestions[$questionId]) - 1 ; |
|
6486 | + $counter += count($mediaQuestions[$questionId]) - 1; |
|
6487 | 6487 | $before = count($questionList); |
6488 | 6488 | $wasMedia = true; |
6489 | 6489 | $nextValue += count($questionList); |
@@ -6562,7 +6562,7 @@ discard block |
||
6562 | 6562 | // If it was already seen, then merge the previous with |
6563 | 6563 | // the current category |
6564 | 6564 | $oldQuestionList = $newCategoryList[$rootElement]['question_list']; |
6565 | - $category['question_list'] = array_merge($oldQuestionList , $category['question_list']); |
|
6565 | + $category['question_list'] = array_merge($oldQuestionList, $category['question_list']); |
|
6566 | 6566 | $newCategoryList[$rootElement] = $category; |
6567 | 6567 | } |
6568 | 6568 | } |
@@ -6588,7 +6588,7 @@ discard block |
||
6588 | 6588 | |
6589 | 6589 | if ($useRootAsCategoryTitle) { |
6590 | 6590 | if (isset($category['parent_info'])) { |
6591 | - $categoryName = $category['parent_info']['title']; |
|
6591 | + $categoryName = $category['parent_info']['title']; |
|
6592 | 6592 | } |
6593 | 6593 | } |
6594 | 6594 | $html .= '<div class="row">'; |
@@ -6731,7 +6731,7 @@ discard block |
||
6731 | 6731 | // end foreach() |
6732 | 6732 | |
6733 | 6733 | if ($this->type == ALL_ON_ONE_PAGE) { |
6734 | - $exercise_actions = $this->show_button($questionId, $currentQuestion); |
|
6734 | + $exercise_actions = $this->show_button($questionId, $currentQuestion); |
|
6735 | 6735 | echo Display::div($exercise_actions, array('class'=>'exercise_actions')); |
6736 | 6736 | } |
6737 | 6737 | } |
@@ -6817,7 +6817,7 @@ discard block |
||
6817 | 6817 | |
6818 | 6818 | // Showing the question |
6819 | 6819 | |
6820 | - $exercise_actions = null; |
|
6820 | + $exercise_actions = null; |
|
6821 | 6821 | |
6822 | 6822 | echo '<a id="questionanchor'.$questionId.'"></a><br />'; |
6823 | 6823 | echo '<div id="question_div_'.$questionId.'" class="main_question '.$remind_highlight.'" >'; |
@@ -7093,7 +7093,7 @@ discard block |
||
7093 | 7093 | $header .= Display::tag('th', get_lang('Feedback')); |
7094 | 7094 | } |
7095 | 7095 | $s .= '<table class="data_table">'; |
7096 | - $s.= Display::tag('tr', $header, array('style' => 'text-align:left;')); |
|
7096 | + $s .= Display::tag('tr', $header, array('style' => 'text-align:left;')); |
|
7097 | 7097 | } |
7098 | 7098 | } |
7099 | 7099 | |
@@ -7193,7 +7193,7 @@ discard block |
||
7193 | 7193 | $s .= '<td>'; |
7194 | 7194 | $s .= $comment; |
7195 | 7195 | $s .= '</td>'; |
7196 | - $s .='</tr>'; |
|
7196 | + $s .= '</tr>'; |
|
7197 | 7197 | } else { |
7198 | 7198 | $s .= $answer_input; |
7199 | 7199 | } |
@@ -7207,7 +7207,7 @@ discard block |
||
7207 | 7207 | } |
7208 | 7208 | } |
7209 | 7209 | |
7210 | - $s .='<tr>'; |
|
7210 | + $s .= '<tr>'; |
|
7211 | 7211 | $s .= Display::tag('td', $answer); |
7212 | 7212 | |
7213 | 7213 | if (!empty($quiz_question_options)) { |
@@ -7234,7 +7234,7 @@ discard block |
||
7234 | 7234 | $s .= $comment; |
7235 | 7235 | $s .= '</td>'; |
7236 | 7236 | } |
7237 | - $s.='</tr>'; |
|
7237 | + $s .= '</tr>'; |
|
7238 | 7238 | } |
7239 | 7239 | |
7240 | 7240 | } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { |
@@ -7263,16 +7263,16 @@ discard block |
||
7263 | 7263 | $answer_input .= '</label>'; |
7264 | 7264 | |
7265 | 7265 | if ($show_comment) { |
7266 | - $s.= '<tr>'; |
|
7266 | + $s .= '<tr>'; |
|
7267 | 7267 | $s .= '<td>'; |
7268 | - $s.= $answer_input; |
|
7268 | + $s .= $answer_input; |
|
7269 | 7269 | $s .= '</td>'; |
7270 | 7270 | $s .= '<td>'; |
7271 | 7271 | $s .= $comment; |
7272 | 7272 | $s .= '</td>'; |
7273 | - $s.= '</tr>'; |
|
7273 | + $s .= '</tr>'; |
|
7274 | 7274 | } else { |
7275 | - $s.= $answer_input; |
|
7275 | + $s .= $answer_input; |
|
7276 | 7276 | } |
7277 | 7277 | } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
7278 | 7278 | $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'; |
@@ -7285,7 +7285,7 @@ discard block |
||
7285 | 7285 | } |
7286 | 7286 | } |
7287 | 7287 | $answer = Security::remove_XSS($answer); |
7288 | - $s .='<tr>'; |
|
7288 | + $s .= '<tr>'; |
|
7289 | 7289 | $s .= Display::tag('td', $answer); |
7290 | 7290 | |
7291 | 7291 | foreach ($objQuestionTmp->options as $key => $item) { |
@@ -7309,7 +7309,7 @@ discard block |
||
7309 | 7309 | $s .= $comment; |
7310 | 7310 | $s .= '</td>'; |
7311 | 7311 | } |
7312 | - $s.='</tr>'; |
|
7312 | + $s .= '</tr>'; |
|
7313 | 7313 | } elseif ($answerType == FILL_IN_BLANKS) { |
7314 | 7314 | list($answer) = explode('::', $answer); |
7315 | 7315 | |
@@ -7343,7 +7343,7 @@ discard block |
||
7343 | 7343 | $value = str_replace(' ', '', trim($value[0])); |
7344 | 7344 | } |
7345 | 7345 | $correct_item = preg_quote($correct_item); |
7346 | - $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find |
|
7346 | + $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find |
|
7347 | 7347 | $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1); |
7348 | 7348 | } |
7349 | 7349 | $i++; |
@@ -7400,7 +7400,7 @@ discard block |
||
7400 | 7400 | } |
7401 | 7401 | |
7402 | 7402 | if (!empty($answerCorrect) && !empty($selectedValue)) { |
7403 | - $s.= '<script> |
|
7403 | + $s .= '<script> |
|
7404 | 7404 | jsPlumb.ready(function() { |
7405 | 7405 | jsPlumb.connect({ |
7406 | 7406 | source: "window_'.$windowId.'", |
@@ -7415,14 +7415,14 @@ discard block |
||
7415 | 7415 | } |
7416 | 7416 | $s .= '</select></div></td>'; |
7417 | 7417 | |
7418 | - $s.='<td width="45%" valign="top" >'; |
|
7418 | + $s .= '<td width="45%" valign="top" >'; |
|
7419 | 7419 | |
7420 | 7420 | if (isset($select_items[$lines_count])) { |
7421 | - $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question"> |
|
7421 | + $s .= '<div id="window_'.$windowId.'_answer" class="window window_right_question"> |
|
7422 | 7422 | <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].' |
7423 | 7423 | </div>'; |
7424 | 7424 | } else { |
7425 | - $s.=' '; |
|
7425 | + $s .= ' '; |
|
7426 | 7426 | } |
7427 | 7427 | |
7428 | 7428 | $s .= '</td>'; |
@@ -7436,16 +7436,16 @@ discard block |
||
7436 | 7436 | $s .= '<tr> |
7437 | 7437 | <td colspan="2"></td> |
7438 | 7438 | <td valign="top">'; |
7439 | - $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>'; |
|
7439 | + $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>'; |
|
7440 | 7440 | $s .= $select_items[$lines_count]['answer']; |
7441 | - $s.="</td> |
|
7441 | + $s .= "</td> |
|
7442 | 7442 | </tr>"; |
7443 | 7443 | $lines_count++; |
7444 | 7444 | } // end while() |
7445 | 7445 | } // end if() |
7446 | 7446 | $matching_correct_answer++; |
7447 | 7447 | } |
7448 | - } elseif ($answerType == DRAGGABLE) { |
|
7448 | + } elseif ($answerType == DRAGGABLE) { |
|
7449 | 7449 | // matching type, showing suggestions and answers |
7450 | 7450 | // TODO: replace $answerId by $numAnswer |
7451 | 7451 | |
@@ -7487,7 +7487,7 @@ discard block |
||
7487 | 7487 | $s .= '</select>'; |
7488 | 7488 | |
7489 | 7489 | if (!empty($answerCorrect) && !empty($selectedValue)) { |
7490 | - $s.= '<script> |
|
7490 | + $s .= '<script> |
|
7491 | 7491 | $(function() { |
7492 | 7492 | deleteItem($("#'.$questionId.'_'.$selectedValue.'"), $("#drop_'.$windowId.'")); |
7493 | 7493 | }); |
@@ -7495,11 +7495,11 @@ discard block |
||
7495 | 7495 | } |
7496 | 7496 | |
7497 | 7497 | if (isset($select_items[$lines_count])) { |
7498 | - $s.= '<div id="window_'.$windowId.'_answer" class=""> |
|
7498 | + $s .= '<div id="window_'.$windowId.'_answer" class=""> |
|
7499 | 7499 | <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].' |
7500 | 7500 | </div>'; |
7501 | 7501 | } else { |
7502 | - $s.=' '; |
|
7502 | + $s .= ' '; |
|
7503 | 7503 | } |
7504 | 7504 | $lines_count++; |
7505 | 7505 | //if the left side of the "matching" has been completely |
@@ -7508,7 +7508,7 @@ discard block |
||
7508 | 7508 | if (($lines_count - 1) == $num_suggestions) { |
7509 | 7509 | // if it remains answers to shown at the right side |
7510 | 7510 | while (isset($select_items[$lines_count])) { |
7511 | - $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>'; |
|
7511 | + $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>'; |
|
7512 | 7512 | $s .= $select_items[$lines_count]['answer']; |
7513 | 7513 | $lines_count++; |
7514 | 7514 | } |
@@ -7611,9 +7611,9 @@ discard block |
||
7611 | 7611 | |
7612 | 7612 | if (!$only_questions) { |
7613 | 7613 | if ($show_title) { |
7614 | - $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id); |
|
7615 | - $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>'; |
|
7616 | - $html .= $questionDescription; |
|
7614 | + $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id); |
|
7615 | + $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>'; |
|
7616 | + $html .= $questionDescription; |
|
7617 | 7617 | } else { |
7618 | 7618 | $html .= '<div class="media">'; |
7619 | 7619 | $html .= '<div class="pull-left">'; |
@@ -7629,11 +7629,11 @@ discard block |
||
7629 | 7629 | $html .= '</div>'; |
7630 | 7630 | } |
7631 | 7631 | //@todo I need to the get the feedback type |
7632 | - $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />'; |
|
7633 | - $html .= '<table class="exercise_questions"> |
|
7632 | + $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />'; |
|
7633 | + $html .= '<table class="exercise_questions"> |
|
7634 | 7634 | <tr> |
7635 | 7635 | <td valign="top" colspan="2">'; |
7636 | - $html .= '</td></tr>'; |
|
7636 | + $html .= '</td></tr>'; |
|
7637 | 7637 | } |
7638 | 7638 | |
7639 | 7639 | $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
@@ -72,6 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * Return the XML flow for the possible answers. |
74 | 74 | * |
75 | + * @param string $questionStatment |
|
75 | 76 | */ |
76 | 77 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 78 | { |
@@ -147,6 +148,7 @@ discard block |
||
147 | 148 | * Export the text with missing words. |
148 | 149 | * |
149 | 150 | * |
151 | + * @param string $questionStatment |
|
150 | 152 | */ |
151 | 153 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 154 | { |
@@ -204,6 +206,7 @@ discard block |
||
204 | 206 | { |
205 | 207 | /** |
206 | 208 | * Export the question part as a matrix-choice, with only one possible answer per line. |
209 | + * @param string $questionStatment |
|
207 | 210 | */ |
208 | 211 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 212 | { |
@@ -295,6 +298,7 @@ discard block |
||
295 | 298 | /** |
296 | 299 | * TODO update this to match hot spots instead of copying matching |
297 | 300 | * Export the question part as a matrix-choice, with only one possible answer per line. |
301 | + * @param string $questionStatment |
|
298 | 302 | */ |
299 | 303 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 304 | { |
@@ -382,6 +386,7 @@ discard block |
||
382 | 386 | /** |
383 | 387 | * TODO implement |
384 | 388 | * Export the question part as a matrix-choice, with only one possible answer per line. |
389 | + * @param string $questionStatment |
|
385 | 390 | */ |
386 | 391 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | 392 | { |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | |
56 | 56 | function createAnswersForm($form) |
57 | 57 | { |
58 | - return true; |
|
58 | + return true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | function processAnswersCreation($form) |
62 | 62 | { |
63 | - return true; |
|
63 | + return true; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | - $this->answerList = $this->getAnswersList(true); |
|
79 | + $this->answerList = $this->getAnswersList(true); |
|
80 | 80 | $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
81 | 81 | $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
82 | - if (is_array($this->answerList)) { |
|
83 | - foreach ($this->answerList as $current_answer) { |
|
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
82 | + if (is_array($this->answerList)) { |
|
83 | + foreach ($this->answerList as $current_answer) { |
|
84 | + $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | - if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
86 | + if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | + $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | - } |
|
91 | - $out .= '</simpleChoice>'. "\n"; |
|
92 | - } |
|
93 | - } |
|
90 | + } |
|
91 | + $out .= '</simpleChoice>'. "\n"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | $out .= ' </choiceInteraction>'. "\n"; |
95 | 95 | |
96 | 96 | return $out; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function imsExportResponsesDeclaration($questionIdent) |
104 | 104 | { |
105 | - $this->answerList = $this->getAnswersList(true); |
|
106 | - $type = $this->getQuestionType(); |
|
105 | + $this->answerList = $this->getAnswersList(true); |
|
106 | + $type = $this->getQuestionType(); |
|
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | 109 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | 113 | $out .= ' <correctResponse>'. "\n"; |
114 | - if (is_array($this->answerList)) { |
|
115 | - foreach($this->answerList as $current_answer) { |
|
116 | - if ($current_answer['correct']) { |
|
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
114 | + if (is_array($this->answerList)) { |
|
115 | + foreach($this->answerList as $current_answer) { |
|
116 | + if ($current_answer['correct']) { |
|
117 | + $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $out .= ' </correctResponse>'. "\n"; |
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | 125 | $out .= ' <mapping>'. "\n"; |
126 | - if (is_array($this->answerList)) { |
|
127 | - foreach($this->answerList as $current_answer) { |
|
128 | - if (isset($current_answer['grade'])) { |
|
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
126 | + if (is_array($this->answerList)) { |
|
127 | + foreach($this->answerList as $current_answer) { |
|
128 | + if (isset($current_answer['grade'])) { |
|
129 | + $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | $out .= ' </mapping>'. "\n"; |
134 | 134 | $out .= ' </responseDeclaration>'. "\n"; |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 152 | { |
153 | - $this->answerList = $this->getAnswersList(true); |
|
153 | + $this->answerList = $this->getAnswersList(true); |
|
154 | 154 | $text = ''; |
155 | 155 | $text .= $this->answerText; |
156 | 156 | if (is_array($this->answerList)) { |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function imsExportResponsesDeclaration($questionIdent) |
173 | 173 | { |
174 | - $this->answerList = $this->getAnswersList(true); |
|
175 | - $this->gradeList = $this->getGradesList(); |
|
174 | + $this->answerList = $this->getAnswersList(true); |
|
175 | + $this->gradeList = $this->getGradesList(); |
|
176 | 176 | $out = ''; |
177 | - if (is_array($this->answerList)) { |
|
178 | - foreach ($this->answerList as $answer) { |
|
179 | - $answerKey = $answer['id']; |
|
180 | - $answer = $answer['answer']; |
|
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
177 | + if (is_array($this->answerList)) { |
|
178 | + foreach ($this->answerList as $answer) { |
|
179 | + $answerKey = $answer['id']; |
|
180 | + $answer = $answer['answer']; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | + $out .= ' <correctResponse>'. "\n"; |
|
183 | 183 | $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
184 | - $out .= ' </correctResponse>'. "\n"; |
|
185 | - if (isset($this->gradeList[$answerKey])) { |
|
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
189 | - } |
|
190 | - |
|
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $out; |
|
184 | + $out .= ' </correctResponse>'. "\n"; |
|
185 | + if (isset($this->gradeList[$answerKey])) { |
|
186 | + $out .= ' <mapping>'. "\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | + $out .= ' </mapping>'. "\n"; |
|
189 | + } |
|
190 | + |
|
191 | + $out .= ' </responseDeclaration>'. "\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $out; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 209 | { |
210 | - $this->answerList = $this->getAnswersList(true); |
|
211 | - $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
210 | + $this->answerList = $this->getAnswersList(true); |
|
211 | + $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | //add left column |
219 | 219 | |
220 | 220 | $out .= ' <simpleMatchSet>'. "\n"; |
221 | - if (is_array($this->leftList)) { |
|
222 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | - $out .= ' |
|
221 | + if (is_array($this->leftList)) { |
|
222 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | + $out .= ' |
|
224 | 224 | <simpleAssociableChoice identifier="left_'.$leftKey.'" > |
225 | 225 | <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]> |
226 | 226 | </simpleAssociableChoice>'. "\n"; |
227 | - } |
|
228 | - } |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | $out .= ' </simpleMatchSet>'. "\n"; |
231 | 231 | |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | - if (is_array($this->rightList)) { |
|
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | - $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
238 | + if (is_array($this->rightList)) { |
|
239 | + foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | + $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | - $i++; |
|
244 | - } |
|
245 | - } |
|
243 | + $i++; |
|
244 | + } |
|
245 | + } |
|
246 | 246 | $out .= ' </simpleMatchSet>'. "\n"; |
247 | 247 | $out .= '</matchInteraction>'. "\n"; |
248 | 248 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | - $this->answerList = $this->getAnswersList(true); |
|
257 | + $this->answerList = $this->getAnswersList(true); |
|
258 | 258 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
259 | 259 | $out .= ' <correctResponse>' . "\n"; |
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | - if (is_array($this->leftList)) { |
|
263 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | - $i=0; |
|
265 | - foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | - if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | - |
|
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | - } |
|
271 | - $i++; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
262 | + if (is_array($this->leftList)) { |
|
263 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | + $i=0; |
|
265 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | + if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | + $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | + |
|
269 | + $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | + } |
|
271 | + $i++; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $out .= ' </correctResponse>'. "\n"; |
276 | 276 | $out .= ' <mapping>' . "\n"; |
277 | 277 | if (is_array($gradeArray)) { |
278 | - foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | - } |
|
278 | + foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | $out .= ' </mapping>' . "\n"; |
283 | 283 | $out .= ' </responseDeclaration>'. "\n"; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 300 | { |
301 | - $this->answerList = $this->getAnswersList(true); |
|
302 | - $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | - $mimetype = mime_content_type($questionMedia); |
|
304 | - if(empty($mimetype)){ |
|
305 | - $mimetype = 'image/jpeg'; |
|
306 | - } |
|
307 | - |
|
308 | - $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | - $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | - $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | - $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
301 | + $this->answerList = $this->getAnswersList(true); |
|
302 | + $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | + $mimetype = mime_content_type($questionMedia); |
|
304 | + if(empty($mimetype)){ |
|
305 | + $mimetype = 'image/jpeg'; |
|
306 | + } |
|
307 | + |
|
308 | + $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | + $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | + $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | + $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
312 | 312 | if (is_array($this->answerList)) { |
313 | - foreach ($this->answerList as $key=>$answer) { |
|
314 | - $key = $answer['id']; |
|
315 | - $answerTxt = $answer['answer']; |
|
316 | - $len = api_strlen($answerTxt); |
|
317 | - //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | - $coords = ''; |
|
319 | - $type = 'default'; |
|
320 | - switch($answer['hotspot_type']){ |
|
321 | - case 'square': |
|
322 | - $type = 'rect'; |
|
323 | - $res = array(); |
|
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | - break; |
|
327 | - case 'circle': |
|
328 | - $type = 'circle'; |
|
329 | - $res = array(); |
|
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | - break; |
|
333 | - case 'poly': |
|
334 | - $type = 'poly'; |
|
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | - break; |
|
337 | - case 'delineation' : |
|
338 | - $type = 'delineation'; |
|
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | - break; |
|
341 | - } |
|
342 | - $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | - } |
|
313 | + foreach ($this->answerList as $key=>$answer) { |
|
314 | + $key = $answer['id']; |
|
315 | + $answerTxt = $answer['answer']; |
|
316 | + $len = api_strlen($answerTxt); |
|
317 | + //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | + $coords = ''; |
|
319 | + $type = 'default'; |
|
320 | + switch($answer['hotspot_type']){ |
|
321 | + case 'square': |
|
322 | + $type = 'rect'; |
|
323 | + $res = array(); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | + break; |
|
327 | + case 'circle': |
|
328 | + $type = 'circle'; |
|
329 | + $res = array(); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | + break; |
|
333 | + case 'poly': |
|
334 | + $type = 'poly'; |
|
335 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | + break; |
|
337 | + case 'delineation' : |
|
338 | + $type = 'delineation'; |
|
339 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | + break; |
|
341 | + } |
|
342 | + $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | + } |
|
344 | 344 | } |
345 | 345 | $text .= ' </graphicOrderInteraction>'."\n"; |
346 | 346 | $out = $text; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function imsExportResponsesDeclaration($questionIdent) |
355 | 355 | { |
356 | - $this->answerList = $this->getAnswersList(true); |
|
357 | - $this->gradeList = $this->getGradesList(); |
|
356 | + $this->answerList = $this->getAnswersList(true); |
|
357 | + $this->gradeList = $this->getGradesList(); |
|
358 | 358 | $out = ''; |
359 | 359 | $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
360 | 360 | $out .= ' <correctResponse>'. "\n"; |
361 | 361 | |
362 | - if (is_array($this->answerList)) { |
|
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | - $answerKey = $answer['id']; |
|
365 | - $answer = $answer['answer']; |
|
366 | - $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | - } |
|
368 | - } |
|
362 | + if (is_array($this->answerList)) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | + $answerKey = $answer['id']; |
|
365 | + $answer = $answer['answer']; |
|
366 | + $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $out .= ' </correctResponse>'. "\n"; |
370 | 370 | $out .= ' </responseDeclaration>'. "\n"; |
371 | 371 | |
372 | - return $out; |
|
372 | + return $out; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | 386 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | - { |
|
388 | - return ''; |
|
389 | - } |
|
387 | + { |
|
388 | + return ''; |
|
389 | + } |
|
390 | 390 | /** |
391 | 391 | * |
392 | 392 | */ |
393 | 393 | public function imsExportResponsesDeclaration($questionIdent) |
394 | 394 | { |
395 | - return ''; |
|
395 | + return ''; |
|
396 | 396 | } |
397 | 397 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function setAnswer() |
16 | 16 | { |
17 | - switch($this->type) { |
|
17 | + switch ($this->type) { |
|
18 | 18 | case MCUA: |
19 | 19 | $answer = new ImsAnswerMultipleChoice($this->id); |
20 | 20 | |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | 79 | $this->answerList = $this->getAnswersList(true); |
80 | - $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
|
81 | - $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
|
80 | + $out = ' <choiceInteraction responseIdentifier="'.$questionIdent.'" >'."\n"; |
|
81 | + $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment).']]></prompt>'."\n"; |
|
82 | 82 | if (is_array($this->answerList)) { |
83 | 83 | foreach ($this->answerList as $current_answer) { |
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
84 | + $out .= '<simpleChoice identifier="answer_'.$current_answer['id'].'" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | 86 | if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
87 | + $out .= '<feedbackInline identifier="answer_'.$current_answer['id'].'"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | 90 | } |
91 | - $out .= '</simpleChoice>'. "\n"; |
|
91 | + $out .= '</simpleChoice>'."\n"; |
|
92 | 92 | } |
93 | 93 | } |
94 | - $out .= ' </choiceInteraction>'. "\n"; |
|
94 | + $out .= ' </choiceInteraction>'."\n"; |
|
95 | 95 | |
96 | 96 | return $out; |
97 | 97 | } |
@@ -106,32 +106,32 @@ discard block |
||
106 | 106 | $type = $this->getQuestionType(); |
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | - $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
|
109 | + $out = ' <responseDeclaration identifier="'.$questionIdent.'" cardinality="'.$cardinality.'" baseType="identifier">'."\n"; |
|
110 | 110 | |
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | - $out .= ' <correctResponse>'. "\n"; |
|
113 | + $out .= ' <correctResponse>'."\n"; |
|
114 | 114 | if (is_array($this->answerList)) { |
115 | - foreach($this->answerList as $current_answer) { |
|
115 | + foreach ($this->answerList as $current_answer) { |
|
116 | 116 | if ($current_answer['correct']) { |
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
117 | + $out .= ' <value>answer_'.$current_answer['id'].'</value>'."\n"; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | - $out .= ' </correctResponse>'. "\n"; |
|
121 | + $out .= ' </correctResponse>'."\n"; |
|
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | - $out .= ' <mapping>'. "\n"; |
|
125 | + $out .= ' <mapping>'."\n"; |
|
126 | 126 | if (is_array($this->answerList)) { |
127 | - foreach($this->answerList as $current_answer) { |
|
127 | + foreach ($this->answerList as $current_answer) { |
|
128 | 128 | if (isset($current_answer['grade'])) { |
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
129 | + $out .= ' <mapEntry mapKey="answer_'.$current_answer['id'].'" mappedValue="'.$current_answer['grade'].'" />'."\n"; |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
133 | - $out .= ' </mapping>'. "\n"; |
|
134 | - $out .= ' </responseDeclaration>'. "\n"; |
|
133 | + $out .= ' </mapping>'."\n"; |
|
134 | + $out .= ' </responseDeclaration>'."\n"; |
|
135 | 135 | |
136 | 136 | return $out; |
137 | 137 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $key = $answer['id']; |
159 | 159 | $answer = $answer['answer']; |
160 | 160 | $len = api_strlen($answer); |
161 | - $text = str_replace('['.$answer.']','<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text); |
|
161 | + $text = str_replace('['.$answer.']', '<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | $out = $text; |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | foreach ($this->answerList as $answer) { |
179 | 179 | $answerKey = $answer['id']; |
180 | 180 | $answer = $answer['answer']; |
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
183 | - $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
|
184 | - $out .= ' </correctResponse>'. "\n"; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_'.$answerKey.'" cardinality="single" baseType="identifier">'."\n"; |
|
182 | + $out .= ' <correctResponse>'."\n"; |
|
183 | + $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'."\n"; |
|
184 | + $out .= ' </correctResponse>'."\n"; |
|
185 | 185 | if (isset($this->gradeList[$answerKey])) { |
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
186 | + $out .= ' <mapping>'."\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'."\n"; |
|
188 | + $out .= ' </mapping>'."\n"; |
|
189 | 189 | } |
190 | 190 | |
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
191 | + $out .= ' </responseDeclaration>'."\n"; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
215 | - $out .= '<matchInteraction responseIdentifier="' . $questionIdent . '" maxAssociations="'. $maxAssociation .'">'. "\n"; |
|
215 | + $out .= '<matchInteraction responseIdentifier="'.$questionIdent.'" maxAssociations="'.$maxAssociation.'">'."\n"; |
|
216 | 216 | $out .= $questionStatment; |
217 | 217 | |
218 | 218 | //add left column |
219 | 219 | |
220 | - $out .= ' <simpleMatchSet>'. "\n"; |
|
220 | + $out .= ' <simpleMatchSet>'."\n"; |
|
221 | 221 | if (is_array($this->leftList)) { |
222 | 222 | foreach ($this->leftList as $leftKey=>$leftElement) { |
223 | 223 | $out .= ' |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - $out .= ' </simpleMatchSet>'. "\n"; |
|
230 | + $out .= ' </simpleMatchSet>'."\n"; |
|
231 | 231 | |
232 | 232 | //add right column |
233 | 233 | |
234 | - $out .= ' <simpleMatchSet>'. "\n"; |
|
234 | + $out .= ' <simpleMatchSet>'."\n"; |
|
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | 238 | if (is_array($this->rightList)) { |
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
239 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
240 | 240 | $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | 243 | $i++; |
244 | 244 | } |
245 | 245 | } |
246 | - $out .= ' </simpleMatchSet>'. "\n"; |
|
247 | - $out .= '</matchInteraction>'. "\n"; |
|
246 | + $out .= ' </simpleMatchSet>'."\n"; |
|
247 | + $out .= '</matchInteraction>'."\n"; |
|
248 | 248 | |
249 | 249 | return $out; |
250 | 250 | } |
@@ -255,32 +255,32 @@ discard block |
||
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | 257 | $this->answerList = $this->getAnswersList(true); |
258 | - $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
|
259 | - $out .= ' <correctResponse>' . "\n"; |
|
258 | + $out = ' <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n"; |
|
259 | + $out .= ' <correctResponse>'."\n"; |
|
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | 262 | if (is_array($this->leftList)) { |
263 | 263 | foreach ($this->leftList as $leftKey=>$leftElement) { |
264 | - $i=0; |
|
264 | + $i = 0; |
|
265 | 265 | foreach ($this->rightList as $rightKey=>$rightElement) { |
266 | 266 | if (($leftElement['match'] == $rightElement['code'])) { |
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
267 | + $out .= ' <value>left_'.$leftKey.' right_'.$i.'</value>'."\n"; |
|
268 | 268 | |
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
269 | + $gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade']; |
|
270 | 270 | } |
271 | 271 | $i++; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | } |
275 | - $out .= ' </correctResponse>'. "\n"; |
|
276 | - $out .= ' <mapping>' . "\n"; |
|
275 | + $out .= ' </correctResponse>'."\n"; |
|
276 | + $out .= ' <mapping>'."\n"; |
|
277 | 277 | if (is_array($gradeArray)) { |
278 | 278 | foreach ($gradeArray as $gradeKey=>$grade) { |
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>'."\n"; |
|
280 | 280 | } |
281 | 281 | } |
282 | - $out .= ' </mapping>' . "\n"; |
|
283 | - $out .= ' </responseDeclaration>'. "\n"; |
|
282 | + $out .= ' </mapping>'."\n"; |
|
283 | + $out .= ' </responseDeclaration>'."\n"; |
|
284 | 284 | |
285 | 285 | return $out; |
286 | 286 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * TODO update this to match hot spots instead of copying matching |
297 | 297 | * Export the question part as a matrix-choice, with only one possible answer per line. |
298 | 298 | */ |
299 | - public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
|
299 | + public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '') |
|
300 | 300 | { |
301 | 301 | $this->answerList = $this->getAnswersList(true); |
302 | 302 | $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
303 | 303 | $mimetype = mime_content_type($questionMedia); |
304 | - if(empty($mimetype)){ |
|
304 | + if (empty($mimetype)) { |
|
305 | 305 | $mimetype = 'image/jpeg'; |
306 | 306 | } |
307 | 307 | |
@@ -317,26 +317,26 @@ discard block |
||
317 | 317 | //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
318 | 318 | $coords = ''; |
319 | 319 | $type = 'default'; |
320 | - switch($answer['hotspot_type']){ |
|
320 | + switch ($answer['hotspot_type']) { |
|
321 | 321 | case 'square': |
322 | 322 | $type = 'rect'; |
323 | 323 | $res = array(); |
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]); |
|
326 | 326 | break; |
327 | 327 | case 'circle': |
328 | 328 | $type = 'circle'; |
329 | 329 | $res = array(); |
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4]))); |
|
332 | 332 | break; |
333 | 333 | case 'poly': |
334 | 334 | $type = 'poly'; |
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
335 | + $coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']); |
|
336 | 336 | break; |
337 | 337 | case 'delineation' : |
338 | 338 | $type = 'delineation'; |
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
339 | + $coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']); |
|
340 | 340 | break; |
341 | 341 | } |
342 | 342 | $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
@@ -356,18 +356,18 @@ discard block |
||
356 | 356 | $this->answerList = $this->getAnswersList(true); |
357 | 357 | $this->gradeList = $this->getGradesList(); |
358 | 358 | $out = ''; |
359 | - $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
|
360 | - $out .= ' <correctResponse>'. "\n"; |
|
359 | + $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">'."\n"; |
|
360 | + $out .= ' <correctResponse>'."\n"; |
|
361 | 361 | |
362 | 362 | if (is_array($this->answerList)) { |
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | 364 | $answerKey = $answer['id']; |
365 | 365 | $answer = $answer['answer']; |
366 | 366 | $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
367 | 367 | } |
368 | 368 | } |
369 | - $out .= ' </correctResponse>'. "\n"; |
|
370 | - $out .= ' </responseDeclaration>'. "\n"; |
|
369 | + $out .= ' </correctResponse>'."\n"; |
|
370 | + $out .= ' </responseDeclaration>'."\n"; |
|
371 | 371 | |
372 | 372 | return $out; |
373 | 373 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * TODO implement |
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | - public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
|
386 | + public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '') |
|
387 | 387 | { |
388 | 388 | return ''; |
389 | 389 | } |
@@ -104,7 +104,11 @@ |
||
104 | 104 | { |
105 | 105 | $this->answerList = $this->getAnswersList(true); |
106 | 106 | $type = $this->getQuestionType(); |
107 | - if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
|
107 | + if ($type == MCMA) { |
|
108 | + $cardinality = 'multiple'; |
|
109 | + } else { |
|
110 | + $cardinality = 'single'; |
|
111 | + } |
|
108 | 112 | |
109 | 113 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
110 | 114 |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param reference Reference to the array to search |
260 | 260 | * @param string Node we are looking for in the array |
261 | 261 | * @param string $node |
262 | - * @return mixed Node name or false if not found |
|
262 | + * @return false|string Node name or false if not found |
|
263 | 263 | */ |
264 | 264 | function myarraysearch(&$array, $node) |
265 | 265 | { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * Searches an image name into an array. |
281 | 281 | * @param reference Reference to an array to search |
282 | 282 | * @param string String to look for |
283 | - * @return mixed String given if found, false otherwise |
|
283 | + * @return false|string String given if found, false otherwise |
|
284 | 284 | * @uses myarraysearch This function is just an additional layer on the myarraysearch() function |
285 | 285 | */ |
286 | 286 | function CheckImageName(&$imgparams, $string) |
@@ -344,7 +344,7 @@ |
||
344 | 344 | if (is_dir($full_name)) { |
345 | 345 | $filelist[] = $file; |
346 | 346 | } |
347 | - } |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if ($title == '') { |
67 | 67 | $title = basename($fname); |
68 | 68 | } |
69 | - return (string)$title; |
|
69 | + return (string) $title; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ($src == '') { |
177 | 177 | return ''; |
178 | 178 | } else { |
179 | - $tmp_src = basename($src) ; |
|
179 | + $tmp_src = basename($src); |
|
180 | 180 | if ($tmp_src == '') { |
181 | 181 | return $src; |
182 | 182 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | { |
199 | 199 | // Select src tag from img tag. |
200 | 200 | $match = array(); |
201 | - preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
201 | + preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
202 | 202 | list($key, $srctag) = each($match); |
203 | 203 | $src = substr($srctag, 5, (strlen($srctag) - 7)); |
204 | 204 | if (stristr($src, 'http') === false) { |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | while (list($key, $imgtag) = each($match)) { |
231 | 231 | $imgname = GetImgName($imgtag); |
232 | 232 | if ($imgname != '' && !in_array($imgname, $imgparams)) { |
233 | - array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
234 | - $imgcount = $imgcount + 1; // number of images in the html test |
|
233 | + array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
234 | + $imgcount = $imgcount + 1; // number of images in the html test |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | if ($file != '..') { |
405 | 405 | $full_name = $folder.'/'.$file; |
406 | 406 | if (is_dir($full_name)) { |
407 | - $dflag = 1; // first directory |
|
407 | + $dflag = 1; // first directory |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
@@ -1143,10 +1143,11 @@ |
||
1143 | 1143 | $result_last_attempt = Database::query($sql); |
1144 | 1144 | if (Database :: num_rows($result_last_attempt) > 0) { |
1145 | 1145 | $id_last_attempt = Database :: result($result_last_attempt, 0, 0); |
1146 | - if ($count_attempts > 0) |
|
1147 | - echo '<a href="../exercise/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'"> |
|
1146 | + if ($count_attempts > 0) { |
|
1147 | + echo '<a href="../exercise/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'"> |
|
1148 | 1148 | '.Display::return_icon('quiz.gif').' |
1149 | 1149 | </a>'; |
1150 | + } |
|
1150 | 1151 | } |
1151 | 1152 | echo '</td>'; |
1152 | 1153 |
@@ -67,52 +67,52 @@ discard block |
||
67 | 67 | if (isset($_GET['details'])) { |
68 | 68 | if ($origin === 'user_course') { |
69 | 69 | if (empty ($cidReq)) { |
70 | - $interbreadcrumb[] = array ( |
|
71 | - "url" => api_get_path(WEB_COURSE_PATH) . $courseInfo['directory'], |
|
70 | + $interbreadcrumb[] = array( |
|
71 | + "url" => api_get_path(WEB_COURSE_PATH).$courseInfo['directory'], |
|
72 | 72 | 'name' => $courseInfo['title'] |
73 | 73 | ); |
74 | 74 | } |
75 | - $interbreadcrumb[] = array ( |
|
76 | - "url" => "../user/user.php?cidReq=" . $course_code, |
|
75 | + $interbreadcrumb[] = array( |
|
76 | + "url" => "../user/user.php?cidReq=".$course_code, |
|
77 | 77 | "name" => get_lang("Users") |
78 | 78 | ); |
79 | 79 | } else |
80 | 80 | if ($origin === 'tracking_course') { |
81 | - $interbreadcrumb[] = array ( |
|
82 | - "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session=' . api_get_session_id(), |
|
81 | + $interbreadcrumb[] = array( |
|
82 | + "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session='.api_get_session_id(), |
|
83 | 83 | "name" => get_lang("Tracking") |
84 | 84 | ); |
85 | 85 | } else |
86 | 86 | if ($origin === 'resume_session') { |
87 | - $interbreadcrumb[] = array ( |
|
87 | + $interbreadcrumb[] = array( |
|
88 | 88 | 'url' => "../session/session_list.php", |
89 | 89 | "name" => get_lang('SessionList') |
90 | 90 | ); |
91 | - $interbreadcrumb[] = array ( |
|
92 | - 'url' => "../session/resume_session.php?id_session=" . $sessionId, |
|
91 | + $interbreadcrumb[] = array( |
|
92 | + 'url' => "../session/resume_session.php?id_session=".$sessionId, |
|
93 | 93 | "name" => get_lang('SessionOverview') |
94 | 94 | ); |
95 | 95 | } else { |
96 | - $interbreadcrumb[] = array ( |
|
97 | - "url" => api_is_student_boss()?"#":"index.php", |
|
96 | + $interbreadcrumb[] = array( |
|
97 | + "url" => api_is_student_boss() ? "#" : "index.php", |
|
98 | 98 | "name" => get_lang('MySpace') |
99 | 99 | ); |
100 | 100 | if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { |
101 | - $interbreadcrumb[] = array ( |
|
102 | - "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']), |
|
101 | + $interbreadcrumb[] = array( |
|
102 | + "url" => "student.php?id_coach=".Security :: remove_XSS($_GET['id_coach']), |
|
103 | 103 | "name" => get_lang("CoachStudents") |
104 | 104 | ); |
105 | - $interbreadcrumb[] = array ( |
|
106 | - "url" => "myStudents.php?student=" . $student_id. '&id_coach=' . Security :: remove_XSS($_GET['id_coach']), |
|
105 | + $interbreadcrumb[] = array( |
|
106 | + "url" => "myStudents.php?student=".$student_id.'&id_coach='.Security :: remove_XSS($_GET['id_coach']), |
|
107 | 107 | "name" => get_lang("StudentDetails") |
108 | 108 | ); |
109 | 109 | } else { |
110 | - $interbreadcrumb[] = array ( |
|
110 | + $interbreadcrumb[] = array( |
|
111 | 111 | "url" => "student.php", |
112 | 112 | "name" => get_lang("MyStudents") |
113 | 113 | ); |
114 | - $interbreadcrumb[] = array ( |
|
115 | - "url" => "myStudents.php?student=" . $student_id, |
|
114 | + $interbreadcrumb[] = array( |
|
115 | + "url" => "myStudents.php?student=".$student_id, |
|
116 | 116 | "name" => get_lang("StudentDetails") |
117 | 117 | ); |
118 | 118 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $nameTools = get_lang("DetailsStudentInCourse"); |
121 | 121 | } else { |
122 | 122 | if ($origin == 'resume_session') { |
123 | - $interbreadcrumb[] = array ( |
|
123 | + $interbreadcrumb[] = array( |
|
124 | 124 | 'url' => "../session/session_list.php", |
125 | 125 | "name" => get_lang('SessionList') |
126 | 126 | ); |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | ); |
132 | 132 | } |
133 | 133 | } else { |
134 | - $interbreadcrumb[] = array ( |
|
135 | - "url" => api_is_student_boss()?"#":"index.php", |
|
134 | + $interbreadcrumb[] = array( |
|
135 | + "url" => api_is_student_boss() ? "#" : "index.php", |
|
136 | 136 | "name" => get_lang('MySpace') |
137 | 137 | ); |
138 | 138 | if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { |
139 | 139 | if ($sessionId) { |
140 | - $interbreadcrumb[] = array ( |
|
141 | - "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']) . "&id_session=" . $sessionId, |
|
140 | + $interbreadcrumb[] = array( |
|
141 | + "url" => "student.php?id_coach=".Security :: remove_XSS($_GET['id_coach'])."&id_session=".$sessionId, |
|
142 | 142 | "name" => get_lang("CoachStudents") |
143 | 143 | ); |
144 | 144 | } else { |
145 | - $interbreadcrumb[] = array ( |
|
146 | - "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']), |
|
145 | + $interbreadcrumb[] = array( |
|
146 | + "url" => "student.php?id_coach=".Security :: remove_XSS($_GET['id_coach']), |
|
147 | 147 | "name" => get_lang("CoachStudents") |
148 | 148 | ); |
149 | 149 | } |
150 | 150 | } else { |
151 | - $interbreadcrumb[] = array ( |
|
151 | + $interbreadcrumb[] = array( |
|
152 | 152 | "url" => "student.php", |
153 | 153 | "name" => get_lang("MyStudents") |
154 | 154 | ); |
@@ -330,28 +330,28 @@ discard block |
||
330 | 330 | // Actions bar |
331 | 331 | echo '<div class="actions">'; |
332 | 332 | echo '<a href="javascript: window.history.go(-1);">'. |
333 | - Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
333 | + Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
334 | 334 | |
335 | 335 | echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'. |
336 | - Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
336 | + Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
337 | 337 | |
338 | - echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">'. |
|
339 | - Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
338 | + echo '<a href="'.api_get_self().'?'.Security :: remove_XSS($_SERVER['QUERY_STRING']).'&export=csv">'. |
|
339 | + Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
340 | 340 | |
341 | - echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=xls">'. |
|
342 | - Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
341 | + echo '<a href="'.api_get_self().'?'.Security :: remove_XSS($_SERVER['QUERY_STRING']).'&export=xls">'. |
|
342 | + Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
343 | 343 | |
344 | 344 | if (!empty ($user_info['email'])) { |
345 | 345 | $send_mail = '<a href="mailto:'.$user_info['email'].'">'. |
346 | - Display :: return_icon('mail_send.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
346 | + Display :: return_icon('mail_send.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
347 | 347 | } else { |
348 | - $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM); |
|
348 | + $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM); |
|
349 | 349 | } |
350 | 350 | echo $send_mail; |
351 | 351 | if (!empty($student_id) && !empty($course_code)) { |
352 | 352 | // Only show link to connection details if course and student were defined in the URL |
353 | - echo '<a href="access_details.php?student=' . $student_id . '&course=' . $course_code . '&origin=' . $origin. '&cidReq='.$course_code.'&id_session='.$sessionId.'">'. |
|
354 | - Display :: return_icon('statistics.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
353 | + echo '<a href="access_details.php?student='.$student_id.'&course='.$course_code.'&origin='.$origin.'&cidReq='.$course_code.'&id_session='.$sessionId.'">'. |
|
354 | + Display :: return_icon('statistics.png', get_lang('AccessDetails'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
355 | 355 | } |
356 | 356 | if (api_can_login_as($student_id)) { |
357 | 357 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$student_id.'&sec_token='.$token.'">'. |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | echo Display::url( |
362 | 362 | Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_MEDIUM), |
363 | - api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $student_id]) |
|
363 | + api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $student_id]) |
|
364 | 364 | ); |
365 | 365 | |
366 | 366 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $csv_content[] = array( |
422 | 422 | get_lang('Information', '') |
423 | 423 | ); |
424 | - $csv_content[] = array ( |
|
424 | + $csv_content[] = array( |
|
425 | 425 | get_lang('Name', ''), |
426 | 426 | get_lang('Email', ''), |
427 | 427 | get_lang('Tel', '') |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | strip_tags($first_connection_date), |
450 | 450 | strip_tags($last_connection_date), |
451 | 451 | $time_spent_on_the_course, |
452 | - $avg_student_progress . '%', |
|
452 | + $avg_student_progress.'%', |
|
453 | 453 | $avg_student_score |
454 | 454 | ); |
455 | 455 | |
@@ -479,19 +479,19 @@ discard block |
||
479 | 479 | </thead> |
480 | 480 | <tbody> |
481 | 481 | <tr> |
482 | - <td><?php echo get_lang('Name') . ' : '.$user_info['complete_name']; ?></td> |
|
482 | + <td><?php echo get_lang('Name').' : '.$user_info['complete_name']; ?></td> |
|
483 | 483 | </tr> |
484 | 484 | <tr> |
485 | - <td><?php echo get_lang('Email') . ' : '; |
|
485 | + <td><?php echo get_lang('Email').' : '; |
|
486 | 486 | if (!empty ($user_info['email'])) { |
487 | - echo '<a href="mailto:' . $user_info['email'] . '">' . $user_info['email'] . '</a>'; |
|
487 | + echo '<a href="mailto:'.$user_info['email'].'">'.$user_info['email'].'</a>'; |
|
488 | 488 | } else { |
489 | 489 | echo get_lang('NoEmail'); |
490 | 490 | } ?> |
491 | 491 | </td> |
492 | 492 | </tr> |
493 | 493 | <tr> |
494 | - <td> <?php echo get_lang('Tel') . ' : '; |
|
494 | + <td> <?php echo get_lang('Tel').' : '; |
|
495 | 495 | if (!empty ($user_info['phone'])) { |
496 | 496 | echo $user_info['phone']; |
497 | 497 | } else { |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | </td> |
502 | 502 | </tr> |
503 | 503 | <tr> |
504 | - <td> <?php echo get_lang('OfficialCode') . ' : '; |
|
504 | + <td> <?php echo get_lang('OfficialCode').' : '; |
|
505 | 505 | if (!empty ($user_info['official_code'])) { |
506 | 506 | echo $user_info['official_code']; |
507 | 507 | } else { |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | </td> |
512 | 512 | </tr> |
513 | 513 | <tr> |
514 | - <td><?php echo get_lang('OnLine') . ' : '.$online; ?> </td> |
|
514 | + <td><?php echo get_lang('OnLine').' : '.$online; ?> </td> |
|
515 | 515 | </tr> |
516 | 516 | <?php |
517 | 517 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | if ($timezone !== null) { |
526 | 526 | ?> |
527 | 527 | <tr> |
528 | - <td> <?php echo get_lang('Timezone') . ' : '.$timezone; ?> </td> |
|
528 | + <td> <?php echo get_lang('Timezone').' : '.$timezone; ?> </td> |
|
529 | 529 | </tr> |
530 | 530 | <?php |
531 | 531 | } |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | } |
673 | 673 | |
674 | 674 | if (!empty($access_start_date) && !empty($access_end_date)) { |
675 | - $date_session = get_lang('From') . ' ' . $access_start_date . ' ' . get_lang('Until') . ' ' . $access_end_date; |
|
675 | + $date_session = get_lang('From').' '.$access_start_date.' '.get_lang('Until').' '.$access_end_date; |
|
676 | 676 | } |
677 | - $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':''); |
|
677 | + $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session ? ' ('.$date_session.')' : ''); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | // Courses |
@@ -729,16 +729,16 @@ discard block |
||
729 | 729 | $scoretotal = array(); |
730 | 730 | if (isset($cats) && isset($cats[0])) { |
731 | 731 | if (!empty($sId)) { |
732 | - $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem, $sId); |
|
732 | + $scoretotal = $cats[0]->calc_score($student_id, null, $courseCodeItem, $sId); |
|
733 | 733 | } else { |
734 | - $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem); |
|
734 | + $scoretotal = $cats[0]->calc_score($student_id, null, $courseCodeItem); |
|
735 | 735 | } |
736 | 736 | } |
737 | 737 | |
738 | 738 | $scoretotal_display = '0/0 (0%)'; |
739 | 739 | if (!empty($scoretotal)) { |
740 | 740 | $scoretotal_display = |
741 | - round($scoretotal[0], 1 ).'/'. |
|
741 | + round($scoretotal[0], 1).'/'. |
|
742 | 742 | round($scoretotal[1], 1). |
743 | 743 | ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)'; |
744 | 744 | } |
@@ -759,9 +759,9 @@ discard block |
||
759 | 759 | ); |
760 | 760 | |
761 | 761 | echo '<tr> |
762 | - <td ><a href="' .$courseInfoItem['course_public_url'] .'?id_session=' . $sId . '">'. |
|
762 | + <td ><a href="' .$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'. |
|
763 | 763 | $courseInfoItem['title'].'</a></td> |
764 | - <td >'.$time_spent_on_course .'</td> |
|
764 | + <td >'.$time_spent_on_course.'</td> |
|
765 | 765 | <td >'.$progress.'</td> |
766 | 766 | <td >'.$score.'</td> |
767 | 767 | <td >'.$attendances_faults_avg.'</td> |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | <table class="table table-striped table-hover"> |
830 | 830 | <thead> |
831 | 831 | <tr> |
832 | - <th><?php echo get_lang('LearningPath');?></th> |
|
832 | + <th><?php echo get_lang('LearningPath'); ?></th> |
|
833 | 833 | <th> |
834 | 834 | <?php |
835 | 835 | echo get_lang('Time').' '; |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | if (!empty($start_time)) { |
932 | 932 | $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG); |
933 | 933 | } else { |
934 | - $start_time = '-'; |
|
934 | + $start_time = '-'; |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | if (!empty($total_time)) { |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | $csv_content[] = array( |
969 | 969 | api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset), |
970 | 970 | api_time_to_hms($total_time), |
971 | - $score . '%', |
|
972 | - $score_latest . '%', |
|
971 | + $score.'%', |
|
972 | + $score_latest.'%', |
|
973 | 973 | $progress.'%', |
974 | 974 | $start_time |
975 | 975 | ); |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | if ($any_result === true) { |
1009 | 1009 | $from = ''; |
1010 | 1010 | if ($from_myspace) { |
1011 | - $from ='&from=myspace'; |
|
1011 | + $from = '&from=myspace'; |
|
1012 | 1012 | } |
1013 | 1013 | $link = Display::url( |
1014 | 1014 | Display::return_icon('2rightarrow.png', get_lang('Details')), |
@@ -1021,14 +1021,14 @@ discard block |
||
1021 | 1021 | echo '<td>'; |
1022 | 1022 | if ($any_result === true) { |
1023 | 1023 | echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.$course_code.'&course='.$course_code.'&details='.Security::remove_XSS($_GET['details']).'&origin='.$origin.'&lp_id='.$learnpath->getId().'&student='.$user_info['user_id'].'&details=true&id_session='.$sessionId.'">'; |
1024 | - echo Display::return_icon('clean.png', get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>'; |
|
1024 | + echo Display::return_icon('clean.png', get_lang('Clean'), '', ICON_SIZE_SMALL).'</a>'; |
|
1025 | 1025 | echo '</a>'; |
1026 | 1026 | } |
1027 | 1027 | echo '</td>'; |
1028 | 1028 | echo '</tr>'; |
1029 | 1029 | } |
1030 | 1030 | $data_learnpath[$i][] = $lp_name; |
1031 | - $data_learnpath[$i][] = $progress . '%'; |
|
1031 | + $data_learnpath[$i][] = $progress.'%'; |
|
1032 | 1032 | } |
1033 | 1033 | ?> |
1034 | 1034 | </tbody> |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | <thead> |
1045 | 1045 | <tr> |
1046 | 1046 | <th><?php echo get_lang('Exercises'); ?></th> |
1047 | - <th><?php echo get_lang('LearningPath');?></th> |
|
1047 | + <th><?php echo get_lang('LearningPath'); ?></th> |
|
1048 | 1048 | <th><?php echo get_lang('AvgCourseScore').' '.Display :: return_icon('info3.gif', get_lang('AverageScore'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th> |
1049 | 1049 | <th><?php echo get_lang('Attempts'); ?></th> |
1050 | 1050 | <th><?php echo get_lang('LatestAttempt'); ?></th> |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | ); |
1064 | 1064 | |
1065 | 1065 | $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST); |
1066 | - $sql = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz |
|
1066 | + $sql = "SELECT quiz.title, id FROM ".$t_quiz." AS quiz |
|
1067 | 1067 | WHERE |
1068 | 1068 | quiz.c_id = ".$courseInfo['real_id']." AND |
1069 | 1069 | (quiz.session_id = $sessionId OR quiz.session_id = 0) AND |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | echo '<td>'; |
1129 | 1129 | |
1130 | 1130 | if ($count_attempts > 0) { |
1131 | - echo $score_percentage . '%'; |
|
1131 | + echo $score_percentage.'%'; |
|
1132 | 1132 | } else { |
1133 | 1133 | echo '-'; |
1134 | 1134 | $score_percentage = 0; |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | echo '<td>'.$count_attempts.'</td>'; |
1139 | 1139 | echo '<td>'; |
1140 | 1140 | |
1141 | - $sql = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' |
|
1141 | + $sql = 'SELECT exe_id FROM '.$tbl_stats_exercices.' |
|
1142 | 1142 | WHERE |
1143 | 1143 | exe_exo_id = "'.$exercise_id.'" AND |
1144 | 1144 | exe_user_id ="'.$student_id.'" AND |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | if (Database :: num_rows($result_last_attempt) > 0) { |
1152 | 1152 | $id_last_attempt = Database :: result($result_last_attempt, 0, 0); |
1153 | 1153 | if ($count_attempts > 0) |
1154 | - echo '<a href="../exercise/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'"> |
|
1154 | + echo '<a href="../exercise/exercise_show.php?id='.$id_last_attempt.'&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin) ? 'tracking' : $origin).'"> |
|
1155 | 1155 | '.Display::return_icon('quiz.gif').' |
1156 | 1156 | </a>'; |
1157 | 1157 | } |
@@ -1159,11 +1159,11 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | echo '<td>'; |
1161 | 1161 | $all_attempt_url = "../exercise/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$sessionId"; |
1162 | - echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url ); |
|
1162 | + echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url); |
|
1163 | 1163 | |
1164 | 1164 | echo '</td></tr>'; |
1165 | 1165 | $data_exercices[$i][] = $exercices['title']; |
1166 | - $data_exercices[$i][] = $score_percentage . '%'; |
|
1166 | + $data_exercices[$i][] = $score_percentage.'%'; |
|
1167 | 1167 | $data_exercices[$i][] = $count_attempts; |
1168 | 1168 | |
1169 | 1169 | $csv_content[] = array( |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | $survey_list = SurveyManager::get_surveys($course_code, $sessionId); |
1192 | 1192 | |
1193 | 1193 | $survey_data = array(); |
1194 | - foreach($survey_list as $survey) { |
|
1194 | + foreach ($survey_list as $survey) { |
|
1195 | 1195 | $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $courseInfo['real_id']); |
1196 | 1196 | $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL); |
1197 | 1197 | if (in_array($student_id, $user_list)) { |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | $column = 0; |
1217 | 1217 | $table->setCellContents($row, $column, $data); |
1218 | 1218 | $class = 'class="row_odd"'; |
1219 | - if($row % 2) { |
|
1219 | + if ($row % 2) { |
|
1220 | 1220 | $class = 'class="row_even"'; |
1221 | 1221 | } |
1222 | 1222 | $table->setRowAttributes($row, $class, true); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $result = $objExercise->read($exercise_id); |
18 | 18 | |
19 | 19 | if (!$result) { |
20 | - api_not_allowed(true); |
|
20 | + api_not_allowed(true); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $interbreadcrumb[] = array( |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes; |
42 | 42 | |
43 | 43 | //The order is important you need to check the the $column variable in the model.ajax.php file |
44 | -$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score')); |
|
44 | +$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score')); |
|
45 | 45 | |
46 | 46 | //Column config |
47 | 47 | $column_model = array( |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | $(function() { |
95 | 95 | <?php |
96 | - echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true); |
|
96 | + echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true); |
|
97 | 97 | ?> |
98 | 98 | refreshGrid(); |
99 | 99 | }); |
100 | 100 | </script> |
101 | 101 | <?php |
102 | 102 | |
103 | -$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">' . |
|
104 | - Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
103 | +$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'. |
|
104 | + Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
105 | 105 | echo $actions = Display::div($actions, array('class'=> 'actions')); |
106 | 106 | |
107 | 107 | echo Display::grid_html('live_stats'); |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | - * abstract function which creates the form to create/edit the answers of the question |
|
182 | - * @param FormValidator $form |
|
183 | - */ |
|
181 | + * abstract function which creates the form to create/edit the answers of the question |
|
182 | + * @param FormValidator $form |
|
183 | + */ |
|
184 | 184 | public function processAnswersCreation($form) |
185 | 185 | { |
186 | 186 | $questionWeighting = $nbrGoodAnswers = 0; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | // sets the total weighting of the question |
222 | 222 | $this->updateWeighting($questionWeighting); |
223 | 223 | $this->save(); |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | 226 | function return_header($feedback_type = null, $counter = null, $score = null) |
227 | 227 | { |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $html = '<table class="table table-striped table-hover">'; |
40 | 40 | $html .= '<thead>'; |
41 | 41 | $html .= '<tr>'; |
42 | - $html .= '<th width="10">' . get_lang('Number') . '</th>'; |
|
43 | - $html .= '<th width="10">' . get_lang('True') . '</th>'; |
|
44 | - $html .= '<th width="50%">' . get_lang('Comment') . '</th>'; |
|
45 | - $html .= '<th width="50%">' . get_lang('Answer') . '</th>'; |
|
42 | + $html .= '<th width="10">'.get_lang('Number').'</th>'; |
|
43 | + $html .= '<th width="10">'.get_lang('True').'</th>'; |
|
44 | + $html .= '<th width="50%">'.get_lang('Comment').'</th>'; |
|
45 | + $html .= '<th width="50%">'.get_lang('Answer').'</th>'; |
|
46 | 46 | $html .= '</tr>'; |
47 | 47 | $html .= '</thead>'; |
48 | 48 | $html .= '<tbody>'; |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | $form->addHtml('<tr>'); |
75 | 75 | |
76 | 76 | if (is_object($answer)) { |
77 | - $defaults['answer[' . $i . ']'] = $answer->answer[$i]; |
|
78 | - $defaults['comment[' . $i . ']'] = $answer->comment[$i]; |
|
79 | - $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1); |
|
80 | - $defaults['correct[' . $i . ']'] = $answer->correct[$i]; |
|
77 | + $defaults['answer['.$i.']'] = $answer->answer[$i]; |
|
78 | + $defaults['comment['.$i.']'] = $answer->comment[$i]; |
|
79 | + $defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1); |
|
80 | + $defaults['correct['.$i.']'] = $answer->correct[$i]; |
|
81 | 81 | } else { |
82 | 82 | $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2'); |
83 | 83 | $defaults['comment[1]'] = get_lang('DefaultMultipleComment2'); |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | |
94 | 94 | $renderer->setElementTemplate( |
95 | 95 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
96 | - 'correct[' . $i . ']' |
|
96 | + 'correct['.$i.']' |
|
97 | 97 | ); |
98 | 98 | $renderer->setElementTemplate( |
99 | 99 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
100 | - 'counter[' . $i . ']' |
|
100 | + 'counter['.$i.']' |
|
101 | 101 | ); |
102 | 102 | $renderer->setElementTemplate( |
103 | 103 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
104 | - 'answer[' . $i . ']' |
|
104 | + 'answer['.$i.']' |
|
105 | 105 | ); |
106 | 106 | $renderer->setElementTemplate( |
107 | 107 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
108 | - 'comment[' . $i . ']' |
|
108 | + 'comment['.$i.']' |
|
109 | 109 | ); |
110 | 110 | |
111 | - $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); |
|
111 | + $answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"'); |
|
112 | 112 | $answer_number->freeze(); |
113 | 113 | |
114 | 114 | $form->addElement('checkbox', |
115 | - 'correct[' . $i . ']', |
|
115 | + 'correct['.$i.']', |
|
116 | 116 | null, |
117 | 117 | null, |
118 | 118 | 'class="checkbox" style="margin-left: 0em;"' |
119 | 119 | ); |
120 | - $boxes_names[] = 'correct[' . $i . ']'; |
|
120 | + $boxes_names[] = 'correct['.$i.']'; |
|
121 | 121 | |
122 | 122 | $form->addElement( |
123 | 123 | 'html_editor', |
124 | - 'answer[' . $i . ']', |
|
124 | + 'answer['.$i.']', |
|
125 | 125 | null, |
126 | 126 | array(), |
127 | 127 | array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100') |
128 | 128 | ); |
129 | - $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); |
|
129 | + $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); |
|
130 | 130 | |
131 | 131 | $form->addElement( |
132 | 132 | 'html_editor', |
133 | - 'comment[' . $i . ']', |
|
133 | + 'comment['.$i.']', |
|
134 | 134 | null, |
135 | 135 | array(), |
136 | 136 | array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100') |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | function return_header($feedback_type = null, $counter = null, $score = null) |
227 | 227 | { |
228 | 228 | $header = parent::return_header($feedback_type, $counter, $score); |
229 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
229 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
230 | 230 | <tr> |
231 | 231 | <th>'.get_lang("Choice").'</th> |
232 | 232 | <th>'. get_lang("ExpectedChoice").'</th> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | api_not_allowed($show_headers); |
27 | 27 | } |
28 | 28 | |
29 | -$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor; |
|
29 | +$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor; |
|
30 | 30 | |
31 | 31 | //Getting results from the exe_id. This variable also contain all the information about the exercise |
32 | 32 | $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id); |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | -$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">'; |
|
57 | -$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
|
56 | +$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">'; |
|
57 | +$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>'; |
|
58 | 58 | |
59 | 59 | if ($show_headers) { |
60 | 60 | $interbreadcrumb[] = array( |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $htmlHeadXtra[] = '<style> |
71 | 71 | body { background: none;} |
72 | 72 | </style>'; |
73 | - Display::display_reduced_header(); |
|
73 | + Display::display_reduced_header(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $message = Session::read('attempt_remaining'); |