23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
126 $this->parameters = array();
139 $params_array = split(
"<separator>", $params);
140 foreach ($params_array as $pair)
142 if (preg_match(
"/(.*?)\=(.*)/", $pair, $matches))
147 $this->java_code = $matches[2];
149 case "java_codebase" :
150 $this->java_codebase = $matches[2];
152 case "java_archive" :
153 $this->java_archive = $matches[2];
156 $this->java_width = $matches[2];
159 $this->java_height = $matches[2];
162 if (preg_match(
"/param_name_(\d+)/", $matches[1], $found_key))
164 $this->parameters[$found_key[1]][
"name"] = $matches[2];
166 if (preg_match(
"/param_value_(\d+)/", $matches[1], $found_key))
168 $this->parameters[$found_key[1]][
"value"] = $matches[2];
184 $params_array = array();
185 if ($this->java_code)
187 array_push($params_array,
"java_code=$this->java_code");
189 if ($this->java_codebase)
191 array_push($params_array,
"java_codebase=$this->java_codebase");
193 if ($this->java_archive)
195 array_push($params_array,
"java_archive=$this->java_archive");
197 if ($this->java_width)
199 array_push($params_array,
"java_width=$this->java_width");
201 if ($this->java_height)
203 array_push($params_array,
"java_height=$this->java_height");
205 foreach ($this->parameters as $key => $value)
207 array_push($params_array,
"param_name_$key=" . $value[
"name"]);
208 array_push($params_array,
"param_value_$key=" . $value[
"value"]);
210 return join($params_array,
"<separator>");
223 $params_array = array();
224 if ($this->java_code)
226 array_push($params_array,
"java_code=$this->java_code");
227 array_push($params_array,
"java_codebase=$this->java_codebase");
228 array_push($params_array,
"java_archive=$this->java_archive");
230 foreach ($this->parameters as $key => $value)
232 array_push($params_array,
"param_name_$key=" . $value[
"name"]);
233 array_push($params_array,
"param_value_$key=" . $value[
"value"]);
235 return join($params_array,
"<separator>");
248 if (($this->title) and ($this->author) and ($this->question) and ($this->javaapplet_filename) and ($this->java_width) and ($this->java_height) and ($this->
getMaximumPoints() > 0))
283 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
295 include_once(
"./Services/RTE/classes/class.ilRTE.php");
301 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
302 $query = sprintf(
"INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, points, working_time, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
303 $ilDB->quote($question_type .
""),
304 $ilDB->quote($this->obj_id .
""),
305 $ilDB->quote($this->title .
""),
306 $ilDB->quote($this->comment .
""),
307 $ilDB->quote($this->author .
""),
308 $ilDB->quote($this->owner .
""),
310 $ilDB->quote($this->points .
""),
311 $ilDB->quote($estw_time .
""),
312 $ilDB->quote($complete .
""),
313 $ilDB->quote($created .
""),
317 $result = $ilDB->query($query);
318 if (PEAR::isError($result))
321 $ilias->raiseError($result->getMessage());
325 $this->
id = $ilDB->getLastInsertId();
326 $query = sprintf(
"INSERT INTO qpl_question_javaapplet (question_fi, image_file, params) VALUES (%s, %s, %s)",
327 $ilDB->quote($this->id .
""),
328 $ilDB->quote($this->javaapplet_filename .
""),
329 $ilDB->quote($params .
"")
331 $ilDB->query($query);
345 $query = sprintf(
"UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %s, working_time=%s, complete = %s WHERE question_id = %s",
346 $ilDB->quote($this->obj_id.
""),
347 $ilDB->quote($this->title .
""),
348 $ilDB->quote($this->comment .
""),
349 $ilDB->quote($this->author .
""),
351 $ilDB->quote($this->points .
""),
352 $ilDB->quote($estw_time .
""),
353 $ilDB->quote($complete .
""),
354 $ilDB->quote($this->
id .
"")
356 $result = $ilDB->query($query);
357 $query = sprintf(
"UPDATE qpl_question_javaapplet SET image_file = %s, params = %s WHERE question_fi = %s",
358 $ilDB->quote($this->javaapplet_filename .
""),
359 $ilDB->quote($params .
""),
360 $ilDB->quote($this->
id .
"")
362 $result = $ilDB->query($query);
380 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_javaapplet.* FROM qpl_questions, qpl_question_javaapplet WHERE question_id = %s AND qpl_questions.question_id = qpl_question_javaapplet.question_fi",
381 $ilDB->quote($question_id)
383 $result = $ilDB->query($query);
385 if ($result->numRows() == 1)
387 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
388 $this->
id = $question_id;
389 $this->title =
$data->title;
390 $this->comment =
$data->comment;
391 $this->obj_id =
$data->obj_fi;
392 $this->author =
$data->author;
393 $this->points =
$data->points;
394 $this->owner =
$data->owner;
395 $this->original_id =
$data->original_id;
396 $this->javaapplet_filename =
$data->image_file;
397 include_once(
"./Services/RTE/classes/class.ilRTE.php");
399 $this->solution_hint =
$data->solution_hint;
421 $this_id = $this->
getId();
423 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
448 $clone->copyPageOfQuestion($this_id);
450 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
452 $clone->duplicateFeedbackGeneric($this_id);
455 $clone->duplicateApplet($this_id);
475 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
478 $source_questionpool = $this->
getObjId();
479 $clone->setObjId($target_questionpool);
501 $javapath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $javapath);
502 if (!file_exists($javapath))
507 if (!copy($javapath_original .
$filename, $javapath . $filename)) {
508 print
"java applet could not be duplicated!!!! ";
515 $javapath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $javapath);
516 $javapath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $javapath_original);
517 if (!file_exists($javapath))
522 if (!copy($javapath_original .
$filename, $javapath . $filename)) {
523 print
"java applet could not be copied!!!! ";
685 $found_values = array();
690 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
691 $ilDB->quote($active_id .
""),
692 $ilDB->quote($this->
getId() .
""),
693 $ilDB->quote(
$pass .
"")
695 $result = $ilDB->query($query);
697 while (
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
719 $found_values = array();
724 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
725 $ilDB->quote($active_id .
""),
726 $ilDB->quote($this->
getId() .
""),
727 $ilDB->quote(
$pass .
"")
729 $result = $ilDB->query($query);
731 $user_result = array();
732 while (
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
735 if (
$data->points > 0)
740 "order" =>
"$counter",
741 "points" =>
"$data->points",
743 "value1" =>
"$data->value1",
744 "value2" =>
"$data->value2",
747 array_push($user_result, $solution);
767 $this->parameters[$index] = array(
"name" => $name,
"value" => $value);
771 array_push($this->parameters, array(
"name" => $name,
"value" => $value));
788 $this->parameters[$index] = array(
"name" => $name,
"value" => $value);
802 foreach ($this->parameters as $key => $value)
804 if (strcmp($name, $value[
"name"]) == 0)
806 array_splice($this->parameters, $key, 1);
824 if (($index < 0) or ($index >= count($this->parameters)))
828 return $this->parameters[$index];
843 foreach ($this->parameters as $key => $value)
845 if (array_key_exists($name, $value))
864 return count($this->parameters);
877 $this->parameters = array();
925 if (!empty($javaapplet_tempfilename))
928 if (!file_exists($javapath))
936 print
"java applet not uploaded!!!! ";
949 $this->javaapplet_filename =
"";
962 return "assJavaApplet";
975 return "qpl_question_javaapplet";
1001 include_once (
"./classes/class.ilExcelUtils.php");
1006 foreach ($solutions as $solution)
1013 return $startrow + $i + 1;