00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once "./assessment/classes/class.assQuestionGUI.php";
00025 include_once "./assessment/classes/inc.AssessmentConstants.php";
00026
00038 class ASS_OrderingQuestionGUI extends ASS_QuestionGUI
00039 {
00040
00049 function ASS_OrderingQuestionGUI(
00050 $id = -1
00051 )
00052 {
00053 $this->ASS_QuestionGUI();
00054 include_once "./assessment/classes/class.assOrderingQuestion.php";
00055 $this->object = new ASS_OrderingQuestion();
00056 if ($id >= 0)
00057 {
00058 $this->object->loadFromDb($id);
00059 }
00060 }
00061
00070 function getQuestionType()
00071 {
00072 return "qt_ordering";
00073 }
00074
00075 function getCommand($cmd)
00076 {
00077 if (substr($cmd, 0, 6) == "delete")
00078 {
00079 $cmd = "delete";
00080 }
00081 if (substr($cmd, 0, 6) == "upload")
00082 {
00083 $cmd = "upload";
00084 }
00085
00086 return $cmd;
00087 }
00088
00089
00097 function editQuestion($ok = true)
00098 {
00099
00100 $this->getQuestionTemplate("qt_ordering");
00101 $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_ordering.html", true);
00102
00103
00104 for ($i = 0; $i < $this->object->get_answer_count(); $i++)
00105 {
00106 $this->tpl->setCurrentBlock("deletebutton");
00107 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00108 $this->tpl->setVariable("ANSWER_ORDER", $i);
00109 $this->tpl->parseCurrentBlock();
00110
00111 $thisanswer = $this->object->get_answer($i);
00112 if ($this->object->get_ordering_type() == OQ_PICTURES)
00113 {
00114 $this->tpl->setCurrentBlock("order_pictures");
00115 $this->tpl->setVariable("ANSWER_ORDER", $i);
00116 $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $thisanswer->get_order() + 1);
00117 $this->tpl->setVariable("TEXT_ANSWER_PICTURE", $this->lng->txt("answer_picture"));
00118
00119 $filename = $thisanswer->get_answertext();
00120 $extension = "jpg";
00121 if (preg_match("/.*\.(png|jpg|gif|jpeg)$/", $filename, $matches))
00122 {
00123 $extension = $matches[1];
00124 }
00125 if ($filename)
00126 {
00127 $imagepath = $this->object->getImagePathWeb() . $thisanswer->get_answertext();
00128 $this->tpl->setVariable("UPLOADED_IMAGE", "<img src=\"$imagepath.thumb.jpg\" alt=\"" . $thisanswer->get_answertext() . "\" border=\"\" />");
00129 $this->tpl->setVariable("IMAGE_FILENAME", htmlspecialchars($thisanswer->get_answertext()));
00130 $this->tpl->setVariable("VALUE_ANSWER", "");
00131
00132 }
00133 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
00134 }
00135 elseif ($this->object->get_ordering_type() == OQ_TERMS)
00136 {
00137 $this->tpl->setCurrentBlock("order_terms");
00138 $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $thisanswer->get_order() + 1);
00139 $this->tpl->setVariable("TEXT_ANSWER_TEXT", $this->lng->txt("answer_text"));
00140 $this->tpl->setVariable("ANSWER_ORDER", $i);
00141 $this->tpl->setVariable("VALUE_ANSWER", htmlspecialchars($thisanswer->get_answertext()));
00142 }
00143 $this->tpl->parseCurrentBlock();
00144
00145 $this->tpl->setCurrentBlock("answers");
00146 $anchor = "#answer_" . ($thisanswer->get_order() + 1);
00147 $this->tpl->setVariable("TEXT_SOLUTION_ORDER", $this->lng->txt("solution_order"));
00148 $this->tpl->setVariable("ANSWER_ORDER", $thisanswer->get_order());
00149 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00150 $this->tpl->setVariable("VALUE_ORDER", $thisanswer->get_solution_order());
00151 $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
00152 $this->tpl->setVariable("VALUE_ORDERING_POINTS", sprintf("%d", $thisanswer->get_points()));
00153 $this->tpl->parseCurrentBlock();
00154 }
00155
00156 if (($this->ctrl->getCmd() == "addItem") and ($ok))
00157 {
00158 if ($this->object->get_ordering_type() == OQ_PICTURES)
00159 {
00160 $this->tpl->setCurrentBlock("order_pictures");
00161 $this->tpl->setVariable("ANSWER_ORDER", $this->object->get_answer_count());
00162 $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $this->object->get_answer_count() + 1);
00163 $this->tpl->setVariable("VALUE_ANSWER", "");
00164 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
00165 $this->tpl->setVariable("TEXT_ANSWER_PICTURE", $this->lng->txt("answer_picture"));
00166 }
00167 elseif ($this->object->get_ordering_type() == OQ_TERMS)
00168 {
00169 $this->tpl->setCurrentBlock("order_terms");
00170 $this->tpl->setVariable("TEXT_ANSWER_TEXT", $this->lng->txt("answer_text"));
00171 $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $this->object->get_answer_count() + 1);
00172 $this->tpl->setVariable("ANSWER_ORDER", $this->object->get_answer_count());
00173 $this->tpl->setVariable("VALUE_ASNWER", "");
00174 }
00175 $this->tpl->parseCurrentBlock();
00176
00177
00178 $this->tpl->setCurrentBlock("answers");
00179
00180 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00181 $anchor = "#answer_" . ($this->object->get_answer_count() + 1);
00182 $this->tpl->setVariable("TEXT_SOLUTION_ORDER", $this->lng->txt("solution_order"));
00183 $this->tpl->setVariable("ANSWER_ORDER", $this->object->get_answer_count());
00184 $this->tpl->setVariable("VALUE_ORDER", $this->object->get_max_solution_order() + 1);
00185 $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
00186 $this->tpl->setVariable("VALUE_ORDERING_POINTS", sprintf("%d", 0));
00187 $this->tpl->parseCurrentBlock();
00188 }
00189
00190 $this->outOtherQuestionData();
00191
00192 $internallinks = array(
00193 "lm" => $this->lng->txt("obj_lm"),
00194 "st" => $this->lng->txt("obj_st"),
00195 "pg" => $this->lng->txt("obj_pg"),
00196 "glo" => $this->lng->txt("glossary_term")
00197 );
00198 foreach ($internallinks as $key => $value)
00199 {
00200 $this->tpl->setCurrentBlock("internallink");
00201 $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00202 $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00203 $this->tpl->parseCurrentBlock();
00204 }
00205
00206 $this->tpl->setCurrentBlock("HeadContent");
00207 $javascript = "<script type=\"text/javascript\">function initialSelect() {\n%s\n}</script>";
00208 switch ($this->ctrl->getCmd())
00209 {
00210 case "addItem":
00211 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_ordering.answer_".($this->object->get_answer_count()).".focus(); document.frm_ordering.answer_".($this->object->get_answer_count()).".scrollIntoView(\"true\");"));
00212 break;
00213 default:
00214 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_ordering.title.focus();"));
00215 break;
00216 }
00217 $this->tpl->parseCurrentBlock();
00218 $this->tpl->setCurrentBlock("question_data");
00219 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00220 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00221 $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
00222 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00223 $this->tpl->setVariable("TEXT_SHUFFLE_ANSWERS", $this->lng->txt("shuffle_answers"));
00224 $this->tpl->setVariable("TXT_YES", $this->lng->txt("yes"));
00225 $this->tpl->setVariable("TXT_NO", $this->lng->txt("no"));
00226 if ($this->object->getShuffle())
00227 {
00228 $this->tpl->setVariable("SELECTED_YES", " selected=\"selected\"");
00229 }
00230 else
00231 {
00232 $this->tpl->setVariable("SELECTED_NO", " selected=\"selected\"");
00233 }
00234 $this->tpl->setVariable("ORDERING_ID", $this->object->getId());
00235 $this->tpl->setVariable("VALUE_ORDERING_TITLE", htmlspecialchars($this->object->getTitle()));
00236 $this->tpl->setVariable("VALUE_ORDERING_COMMENT", htmlspecialchars($this->object->getComment()));
00237 $this->tpl->setVariable("VALUE_ORDERING_AUTHOR", htmlspecialchars($this->object->getAuthor()));
00238 $questiontext = $this->object->get_question();
00239 $questiontext = preg_replace("/<br \/>/", "\n", $questiontext);
00240 $this->tpl->setVariable("VALUE_QUESTION", htmlspecialchars($questiontext));
00241 $this->tpl->setVariable("VALUE_ADD_ANSWER", $this->lng->txt("add_answer"));
00242 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("type"));
00243 $this->tpl->setVariable("TEXT_TYPE_PICTURES", $this->lng->txt("order_pictures"));
00244 $this->tpl->setVariable("TEXT_TYPE_TERMS", $this->lng->txt("order_terms"));
00245 if ($this->object->get_ordering_type() == OQ_TERMS)
00246 {
00247 $this->tpl->setVariable("SELECTED_TERMS", " selected=\"selected\"");
00248 }
00249 elseif ($this->object->get_ordering_type() == OQ_PICTURES)
00250 {
00251 $this->tpl->setVariable("SELECTED_PICTURES", " selected=\"selected\"");
00252 }
00253
00254 $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
00255 if (count($this->object->suggested_solutions))
00256 {
00257 $solution_array = $this->object->getSuggestedSolution(0);
00258 include_once "./assessment/classes/class.assQuestion.php";
00259 $href = ASS_Question::_getInternalLinkHref($solution_array["internal_link"]);
00260 $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
00261 $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
00262 $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
00263 $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
00264 }
00265 else
00266 {
00267 $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
00268 }
00269
00270 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00271 $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
00272 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00273 $this->ctrl->setParameter($this, "sel_question_types", "qt_ordering");
00274 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("qt_ordering"));
00275 $this->tpl->setVariable("ACTION_ORDERING_QUESTION", $this->ctrl->getFormAction($this));
00276 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00277 $this->tpl->parseCurrentBlock();
00278
00279 if ($this->error)
00280 {
00281 sendInfo($this->error);
00282 }
00283
00284 $this->tpl->setCurrentBlock("adm_content");
00285 $this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\"");
00286 $this->tpl->parseCurrentBlock();
00287 }
00288
00289
00290 function addItem()
00291 {
00292 $ok = true;
00293 if (!$this->checkInput())
00294 {
00295
00296 $this->error .= $this->lng->txt("fill_out_all_required_fields_add_answer") . "<br />";
00297 $ok = false;
00298 }
00299 else
00300 {
00301 foreach ($_POST as $key => $value)
00302 {
00303 if (preg_match("/answer_(\d+)/", $key, $matches))
00304 {
00305 if (!$value)
00306 {
00307 $ok = false;
00308 }
00309 }
00310 }
00311 }
00312 if (!$ok)
00313 {
00314 $this->error .= $this->lng->txt("fill_out_all_answer_fields") . "<br />";
00315 }
00316
00317 $this->writePostData();
00318 $this->editQuestion($ok);
00319 }
00320
00324 function delete()
00325 {
00326 $this->writePostData();
00327
00328
00329 foreach ($_POST[cmd] as $key => $value)
00330 {
00331 if (preg_match("/delete_(\d+)/", $key, $matches))
00332 {
00333 $this->object->delete_answer($matches[1]);
00334 }
00335 }
00336
00337 $this->editQuestion();
00338 }
00339
00343 function upload()
00344 {
00345 $this->writePostData();
00346 $this->editQuestion();
00347 }
00348
00356 function outOtherQuestionData()
00357 {
00358 $this->tpl->setCurrentBlock("other_question_data");
00359 $est_working_time = $this->object->getEstimatedWorkingTime();
00360 $this->tpl->setVariable("TEXT_WORKING_TIME", $this->lng->txt("working_time"));
00361 $this->tpl->setVariable("TIME_FORMAT", $this->lng->txt("time_format"));
00362 $this->tpl->setVariable("VALUE_WORKING_TIME", ilUtil::makeTimeSelect("Estimated", false, $est_working_time[h], $est_working_time[m], $est_working_time[s]));
00363 $this->tpl->parseCurrentBlock();
00364 }
00365
00374 function writePostData()
00375 {
00376 $result = 0;
00377 $saved = false;
00378
00379
00380 $this->object->flush_answers();
00381
00382 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00383 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00384 $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
00385 $questiontext = ilUtil::stripSlashes($_POST["question"], true, "<strong><em><code><cite>");
00386 $questiontext = preg_replace("/\n/", "<br />", $questiontext);
00387 $this->object->set_question($questiontext);
00388 $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
00389 $this->object->setShuffle($_POST["shuffle"]);
00390
00391
00392 $saved = $saved | $this->writeOtherPostData($result);
00393 $this->object->set_ordering_type($_POST["ordering_type"]);
00394
00395
00396 foreach ($_POST as $key => $value)
00397 {
00398 if (preg_match("/answer_(\d+)/", $key, $matches))
00399 {
00400 if ($this->object->get_ordering_type() == OQ_PICTURES)
00401 {
00402 if ($_FILES[$key]["tmp_name"])
00403 {
00404
00405 if ($this->object->getId() <= 0)
00406 {
00407 $this->object->saveToDb();
00408 $saved = true;
00409 $this->error .= $this->lng->txt("question_saved_for_upload") . "<br />";
00410 }
00411 $image_file = $_FILES[$key]["name"];
00412 $image_file = str_replace(" ", "_", $image_file);
00413 $upload_result = $this->object->set_image_file($image_file, $_FILES[$key]['tmp_name']);
00414 switch ($upload_result)
00415 {
00416 case 0:
00417 $_POST[$key] = $image_file;
00418 break;
00419 case 1:
00420 $this->error .= $this->lng->txt("error_image_upload_wrong_format") . "<br />";
00421 break;
00422 case 2:
00423 $this->error .= $this->lng->txt("error_image_upload_copy_file") . "<br />";
00424 break;
00425 }
00426 }
00427 }
00428 $points = $_POST["points_$matches[1]"];
00429 if (preg_match("/\d+/", $points))
00430 {
00431 if ($points < 0)
00432 {
00433 $points = 0.0;
00434 $this->error .= $this->lng->txt("negative_points_not_allowed") . "<br />";
00435 }
00436 }
00437 else
00438 {
00439 $points = 0.0;
00440 }
00441 $this->object->add_answer(
00442 ilUtil::stripSlashes($_POST["$key"]),
00443 ilUtil::stripSlashes($points),
00444 ilUtil::stripSlashes($matches[1]),
00445 ilUtil::stripSlashes($_POST["order_$matches[1]"])
00446 );
00447 }
00448 }
00449
00450 if ($saved)
00451 {
00452
00453
00454
00455
00456 $this->object->saveToDb();
00457 $_GET["q_id"] = $this->object->getId();
00458 }
00459 return $result;
00460 }
00461
00477 function outWorkingForm(
00478 $test_id = "",
00479 $is_postponed = false,
00480 $showsolution = 0,
00481 $show_question_page = true,
00482 $show_solution_only = false,
00483 $ilUser = NULL,
00484 $pass = NULL,
00485 $mixpass = false,
00486 $user_post_solution = false
00487 )
00488 {
00489 if (!is_object($ilUser))
00490 {
00491 global $ilUser;
00492 }
00493
00494 $output = $this->outQuestionPage(($show_solution_only)?"":"ORDERING_QUESTION", $is_postponed,$test_id);
00495 $output = preg_replace("/{/", "{", $output);
00496 $output = preg_replace("/}/", "}", $output);
00497
00498 if ($showsolution && !$show_solution_only)
00499 {
00500 $solutionintroduction = "<p>" . $this->lng->txt("tst_your_answer_was") . "</p>";
00501 $output = preg_replace("/(<div[^<]*?ilc_PageTitle.*?<\/div>)/", "\\1" . $solutionintroduction, $output);
00502 }
00503 $solutionoutput = preg_replace("/.*?(<div[^<]*?ilc_Question.*?<\/div>).*/", "\\1", $output);
00504 $solutionoutput = preg_replace("/\"ord/", "\"solution_ord", $solutionoutput);
00505 $solutionoutput = preg_replace("/name\=\"order_/", "name=\"solution_order_", $solutionoutput);
00506
00507
00508 if (!$show_question_page)
00509 $output = preg_replace("/.*?(<div[^<]*?ilc_Question.*?<\/div>).*/", "\\1", $output);
00510
00511
00512 if ($show_solution_only)
00513 {
00514 $output = preg_replace("/(<div[^<]*?ilc_Question[^>]*>.*?<\/div>)/", "", $output);
00515 }
00516
00517
00518 $solution_script = "";
00519 if ($test_id)
00520 {
00521 $solutions = NULL;
00522 include_once "./assessment/classes/class.ilObjTest.php";
00523 if ((!$showsolution) && ilObjTest::_getHidePreviousResults($test_id, true))
00524 {
00525 if ($show_question_page)
00526 {
00527 if (is_null($pass)) $pass = ilObjTest::_getPass($ilUser->id, $test_id);
00528 }
00529 }
00530 if ($mixpass) $pass = NULL;
00531 if (is_array($user_post_solution))
00532 {
00533 $solutions = array();
00534 foreach ($user_post_solution as $key => $value)
00535 {
00536 if (preg_match("/order_(\d+)/", $key, $matches))
00537 {
00538 array_push($solutions, array("value1" => $matches[1], "value2" => $value));
00539 }
00540 }
00541 }
00542 else
00543 {
00544 $solutions =& $this->object->getSolutionValues($test_id, $ilUser, $pass);
00545 }
00546 $solution_script .= "";
00547 $jssolutions = array();
00548 foreach ($solutions as $idx => $solution_value)
00549 {
00550 if ($this->object->getOutputType() == OUTPUT_HTML || !$show_question_page)
00551 {
00552 $repl_str = "dummy=\"ord".$solution_value["value1"]."\"";
00553
00554 if (!$show_question_page)
00555 $output = $this->replaceInputElements($repl_str, $solution_value["value2"], $output, "[","]");
00556 else
00557 $output = str_replace($repl_str, $repl_str." value=\"".$solution_value["value2"]."\"", $output);
00558 }
00559 else
00560 {
00561 if ((strcmp($solution_value["value2"], "") != 0) && (strcmp($solution_value["value1"], "") != 0))
00562 {
00563 $jssolutions[$solution_value["value2"]] = $solution_value["value1"];
00564 }
00565 }
00566 }
00567 if (!$show_question_page)
00568 {
00569
00570 $output = $this->removeFormElements($output);
00571 }
00572 if (count($jssolutions))
00573 {
00574 ksort($jssolutions);
00575 $js = "";
00576 foreach ($jssolutions as $key => $value)
00577 {
00578 $js .= "initialorder.push($value);";
00579 }
00580 $js .= "restoreInitialOrder();";
00581 $output = str_replace("/*solution*/", $js, $output);
00582 }
00583 }
00584
00585 if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
00586 {
00587 if ($this->object->get_ordering_type() == OQ_PICTURES)
00588 {
00589 foreach ($this->object->answers as $key => $answer)
00590 {
00591 $extension = "jpg";
00592 if (preg_match("/.*\.(png|jpg|gif|jpeg)$/", $answer->get_answertext(), $matches))
00593 {
00594 $extension = $matches[1];
00595 }
00596 $sizethumb = GetImageSize ($this->object->getImagePath() . $answer->get_answertext() . ".thumb.jpg");
00597 $sizeorig = GetImageSize ($this->object->getImagePath() . $answer->get_answertext());
00598 if ($sizethumb[0] >= $sizeorig[0])
00599 {
00600
00601 $output = preg_replace("/<a[^>]*?>\s*<img[^>]*?enlarge[^>]*?>\s*<\/a>/", "", $output);
00602 }
00603
00604 $output = preg_replace("/(<img[^>]*?".$answer->get_answertext()."[^>]*?)(\/{0,1}\s*)?>/", "\\1 " . $sizethumb[3] . "\\2", $output);
00605 }
00606 }
00607
00608
00609
00610 $this->tpl->addBlockFile("CONTENT_BLOCK", "head_content", "tpl.il_as_execute_ordering_javascript.html", true);
00611 $this->tpl->setCurrentBlock("head_content");
00612 $this->tpl->setVariable("JS_LOCATION", "./assessment/js/toolman/");
00613 $this->tpl->parseCurrentBlock();
00614
00615
00616
00617 $this->tpl->setCurrentBlock("AdditionalStyle");
00618 $this->tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", "./assessment/templates/default/test_javascript.css");
00619 $this->tpl->parseCurrentBlock();
00620
00621
00622
00623 $this->tpl->setVariable("ON_SUBMIT", "return saveOrder('orderlist');");
00624
00625
00626
00627
00628 }
00629
00630 foreach ($this->object->answers as $idx => $answer)
00631 {
00632 $repl_str = "dummy=\"solution_ord$idx\"";
00633 $solutionoutput = str_replace($repl_str, $repl_str." value=\"" . $answer->get_solution_order() . "\"", $solutionoutput);
00634 $solutionoutput = preg_replace("/(<tr.*?dummy=\"solution_ord$idx" . "[^\d].*?)<\/tr>/", "\\1<td>" . "<em>(" . $answer->get_points() . " " . $this->lng->txt("points") . ")</em>" . "</td></tr>", $solutionoutput);
00635 if ($show_solution_only)
00636 $solutionoutput = $this->replaceInputElements($repl_str, $answer->get_solution_order(), $solutionoutput , "[" , "]");
00637 }
00638
00639 if (!$show_solution_only)
00640 {
00641 $solutionoutput = "<p>" . $this->lng->txt("correct_solution_is") . ":</p><p>$solutionoutput</p>";
00642 }
00643 if ($test_id)
00644 {
00645 $reached_points = $this->object->getReachedPoints($ilUser->id, $test_id);
00646 $received_points = "<p>" . sprintf($this->lng->txt("you_received_a_of_b_points"), $reached_points, $this->object->getMaximumPoints());
00647 $count_comment = "";
00648 if ($reached_points == 0)
00649 {
00650 $count_comment = $this->object->getSolutionCommentCountSystem($test_id);
00651 if (strlen($count_comment))
00652 {
00653 if (strlen($mc_comment) == 0)
00654 {
00655 $count_comment = "<span class=\"asterisk\">*</span><br /><br /><span class=\"asterisk\">*</span>$count_comment";
00656 }
00657 else
00658 {
00659 $count_comment = "<br /><span class=\"asterisk\">*</span>$count_comment";
00660 }
00661 }
00662 }
00663 $received_points .= $count_comment;
00664 $received_points .= "</p>";
00665 }
00666 if (!$showsolution)
00667 {
00668 $solutionoutput = "";
00669 $received_points = "";
00670 }
00671 $this->tpl->setVariable("ORDERING_QUESTION", $output.$solutionoutput.$received_points);
00672 }
00673
00677 function checkInput()
00678 {
00679 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00680 {
00681 return false;
00682 }
00683 return true;
00684 }
00685
00686 function addSuggestedSolution()
00687 {
00688 $_SESSION["subquestion_index"] = 0;
00689 if ($_POST["cmd"]["addSuggestedSolution"])
00690 {
00691 $this->writePostData();
00692 if (!$this->checkInput())
00693 {
00694 sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00695 $this->editQuestion();
00696 return;
00697 }
00698 }
00699 $this->object->saveToDb();
00700 $_GET["q_id"] = $this->object->getId();
00701 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00702 $this->getQuestionTemplate("qt_ordering");
00703 parent::addSuggestedSolution();
00704 }
00705 }
00706 ?>