• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

survey/classes/class.ilSurveyEvaluationGUI.php

Go to the documentation of this file.
00001 <?php
00002  /*
00003    +----------------------------------------------------------------------------+
00004    | ILIAS open source                                                          |
00005    +----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne           |
00007    |                                                                            |
00008    | This program is free software; you can redistribute it and/or              |
00009    | modify it under the terms of the GNU General Public License                |
00010    | as published by the Free Software Foundation; either version 2             |
00011    | of the License, or (at your option) any later version.                     |
00012    |                                                                            |
00013    | This program is distributed in the hope that it will be useful,            |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
00016    | GNU General Public License for more details.                               |
00017    |                                                                            |
00018    | You should have received a copy of the GNU General Public License          |
00019    | along with this program; if not, write to the Free Software                |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
00021    +----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once "./survey/classes/inc.SurveyConstants.php";
00025 
00038 class ilSurveyEvaluationGUI
00039 {
00040         var $object;
00041         var $lng;
00042         var $tpl;
00043         var $ctrl;
00044         
00053   function ilSurveyEvaluationGUI($a_object)
00054   {
00055                 global $lng, $tpl, $ilCtrl;
00056 
00057     $this->lng =& $lng;
00058     $this->tpl =& $tpl;
00059                 $this->ctrl =& $ilCtrl;
00060                 $this->object =& $a_object;
00061         }
00062         
00066         function &executeCommand()
00067         {
00068                 $cmd = $this->ctrl->getCmd();
00069                 $next_class = $this->ctrl->getNextClass($this);
00070 
00071                 $cmd = $this->getCommand($cmd);
00072                 switch($next_class)
00073                 {
00074                         default:
00075                                 $ret =& $this->$cmd();
00076                                 break;
00077                 }
00078                 return $ret;
00079         }
00080 
00081         function getCommand($cmd)
00082         {
00083                 return $cmd;
00084         }
00085 
00093         function checkAnonymizedEvaluationAccess()
00094         {
00095                 global $rbacsystem;
00096                 
00097                 if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
00098                 {
00099                         // people with write access always have access to the evaluation
00100                         $_SESSION["anon_evaluation_access"] = 1;
00101                         return $this->evaluation();
00102                 }
00103                 if ($this->object->getEvaluationAccess() == EVALUATION_ACCESS_ALL)
00104                 {
00105                         // if the evaluation access is open for all users, grant it
00106                         $_SESSION["anon_evaluation_access"] = 1;
00107                         return $this->evaluation();
00108                 }
00109                 $surveycode = $this->object->getUserSurveyCode();
00110                 if ($this->object->isAnonymizedParticipant($surveycode))
00111                 {
00112                         $_SESSION["anon_evaluation_access"] = 1;
00113                         return $this->evaluation();
00114                 }
00115                 $this->tpl->setVariable("TABS", "");
00116                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation_checkaccess.html", true);
00117                 $this->tpl->setCurrentBlock("adm_content");
00118                 $this->tpl->setVariable("AUTHENTICATION_NEEDED", $this->lng->txt("svy_check_evaluation_authentication_needed"));
00119                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00120                 $this->tpl->setVariable("EVALUATION_CHECKACCESS_INTRODUCTION", $this->lng->txt("svy_check_evaluation_access_introduction"));
00121                 $this->tpl->setVariable("VALUE_CHECK", $this->lng->txt("ok"));
00122                 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
00123                 $this->tpl->setVariable("TEXT_SURVEY_CODE", $this->lng->txt("survey_code"));
00124                 $this->tpl->parseCurrentBlock();
00125         }
00126 
00134         function checkEvaluationAccess()
00135         {
00136                 $surveycode = $_POST["surveycode"];
00137                 if ($this->object->isAnonymizedParticipant($surveycode))
00138                 {
00139                         $_SESSION["anon_evaluation_access"] = 1;
00140                         $this->evaluation();
00141                 }
00142                 else
00143                 {
00144                         sendInfo($this->lng->txt("svy_check_evaluation_wrong_key", true));
00145                         $this->cancelEvaluationAccess();
00146                 }
00147         }
00148         
00156         function cancelEvaluationAccess()
00157         {
00158                 include_once "./classes/class.ilUtil.php";
00159                 global $tree;
00160                 $path = $tree->getPathFull($this->object->getRefID());
00161                 ilUtil::redirect("repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]);
00162         }
00163         
00171         function evaluationdetails()
00172         {
00173                 $this->evaluation(1);
00174         }
00175         
00176         function evaluation($details = 0)
00177         {
00178                 global $ilUser;
00179                 if (($this->object->getAnonymize() == 1) && ($_SESSION["anon_evaluation_access"] != 1))
00180                 {
00181                         $this->checkAnonymizedEvaluationAccess();
00182                         return;
00183                 }
00184                 $result = @include_once 'Spreadsheet/Excel/Writer.php';
00185                 if (!$result)
00186                 {
00187                         include_once './classes/Spreadsheet/Excel/Writer.php';
00188                 }
00189                 $format_bold = "";
00190                 $format_percent = "";
00191                 $format_datetime = "";
00192                 $format_title = "";
00193                 $object_title = preg_replace("/[^a-zA-Z0-9\s]/", "", $this->object->getTitle());
00194                 $surveyname = preg_replace("/\s/", "_", $object_title);
00195 
00196                 if (!$_POST["export_format"])
00197                 {
00198                         $_POST["export_format"] = TYPE_PRINT;
00199                 }
00200                 switch ($_POST["export_format"])
00201                 {
00202                         case TYPE_XLS:
00203                                 // Creating a workbook
00204                                 $workbook = new Spreadsheet_Excel_Writer();
00205 
00206                                 // sending HTTP headers
00207                                 $workbook->send("$surveyname.xls");
00208 
00209                                 // Creating a worksheet
00210                                 $format_bold =& $workbook->addFormat();
00211                                 $format_bold->setBold();
00212                                 $format_percent =& $workbook->addFormat();
00213                                 $format_percent->setNumFormat("0.00%");
00214                                 $format_datetime =& $workbook->addFormat();
00215                                 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
00216                                 $format_title =& $workbook->addFormat();
00217                                 $format_title->setBold();
00218                                 $format_title->setColor('black');
00219                                 $format_title->setPattern(1);
00220                                 $format_title->setFgColor('silver');
00221                                 // Creating a worksheet
00222                                 include_once ("./classes/class.ilExcelUtils.php");
00223                                 $mainworksheet =& $workbook->addWorksheet();
00224                                 include_once ("./classes/class.ilExcelUtils.php");
00225                                 $mainworksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_bold);
00226                                 $mainworksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->lng->txt("question"), $_POST["export_format"]), $format_bold);
00227                                 $mainworksheet->writeString(0, 2, ilExcelUtils::_convert_text($this->lng->txt("question_type"), $_POST["export_format"]), $format_bold);
00228                                 $mainworksheet->writeString(0, 3, ilExcelUtils::_convert_text($this->lng->txt("users_answered"), $_POST["export_format"]), $format_bold);
00229                                 $mainworksheet->writeString(0, 4, ilExcelUtils::_convert_text($this->lng->txt("users_skipped"), $_POST["export_format"]), $format_bold);
00230                                 $mainworksheet->writeString(0, 5, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
00231                                 $mainworksheet->writeString(0, 6, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
00232                                 $mainworksheet->writeString(0, 7, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
00233                                 $mainworksheet->writeString(0, 8, ilExcelUtils::_convert_text($this->lng->txt("median"), $_POST["export_format"]), $format_bold);
00234                                 $mainworksheet->writeString(0, 9, ilExcelUtils::_convert_text($this->lng->txt("arithmetic_mean"), $_POST["export_format"]), $format_bold);
00235                                 break;
00236                         case (TYPE_SPSS || TYPE_PRINT):
00237                                 $csvfile = array();
00238                                 $csvrow = array();
00239                                 array_push($csvrow, $this->lng->txt("title"));
00240                                 array_push($csvrow, $this->lng->txt("question"));
00241                                 array_push($csvrow, $this->lng->txt("question_type"));
00242                                 array_push($csvrow, $this->lng->txt("users_answered"));
00243                                 array_push($csvrow, $this->lng->txt("users_skipped"));
00244                                 array_push($csvrow, $this->lng->txt("mode"));
00245 
00246                                 //array_push($csvrow, $this->lng->txt("mode_text"));
00247 
00248 
00249                                 array_push($csvrow, $this->lng->txt("mode_nr_of_selections"));
00250                                 array_push($csvrow, $this->lng->txt("median"));
00251                                 array_push($csvrow, $this->lng->txt("arithmetic_mean"));
00252                                 array_push($csvfile, $csvrow);
00253                                 break;
00254                 }
00255 
00256                 $this->setEvalTabs();
00257                 sendInfo();
00258                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation.html", true);
00259                 $counter = 0;
00260                 $classes = array("tblrow1", "tblrow2");
00261                 $questions =& $this->object->getSurveyQuestions();
00262                 foreach ($questions as $data)
00263                 {
00264                         $eval = $this->object->getEvaluation($data["question_id"], $ilUser->id);
00265                         $this->tpl->setCurrentBlock("row");
00266                         $this->tpl->setVariable("QUESTION_TITLE", ($counter+1) . ". " . $data["title"]);
00267                         $maxlen = 37;
00268                         if (strlen($data["questiontext"]) > $maxlen + 3)
00269                         {
00270                                 $questiontext = substr($data["questiontext"], 0, $maxlen) . "...";
00271                         }
00272                         else
00273                         {
00274                                 $questiontext = $data["questiontext"];
00275                         }
00276                         $this->tpl->setVariable("QUESTION_TEXT", $questiontext);
00277                         $this->tpl->setVariable("USERS_ANSWERED", $eval["USERS_ANSWERED"]);
00278                         $this->tpl->setVariable("USERS_SKIPPED", $eval["USERS_SKIPPED"]);
00279                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($eval["QUESTION_TYPE"]));
00280                         $this->tpl->setVariable("MODE", $eval["MODE"]);
00281                         $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
00282                         $this->tpl->setVariable("MEDIAN", $eval["MEDIAN"]);
00283                         $this->tpl->setVariable("ARITHMETIC_MEAN", $eval["ARITHMETIC_MEAN"]);
00284                         $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
00285                         switch ($_POST["export_format"])
00286                         {
00287                                 case TYPE_XLS:
00288                                         include_once ("./classes/class.ilExcelUtils.php");
00289                                         $mainworksheet->writeString($counter+1, 0, ilExcelUtils::_convert_text($data["title"], $_POST["export_format"]));
00290                                         $mainworksheet->writeString($counter+1, 1, ilExcelUtils::_convert_text($data["questiontext"], $_POST["export_format"]));
00291                                         $mainworksheet->writeString($counter+1, 2, ilExcelUtils::_convert_text($this->lng->txt($eval["QUESTION_TYPE"]), $_POST["export_format"]));
00292                                         $mainworksheet->write($counter+1, 3, $eval["USERS_ANSWERED"]);
00293                                         $mainworksheet->write($counter+1, 4, $eval["USERS_SKIPPED"]);
00294                                         preg_match("/(.*?)\s+-\s+(.*)/", $eval["MODE"], $matches);
00295                                         switch ($eval["QUESTION_TYPE"])
00296                                         {
00297                                                 case "qt_metric":
00298                                                         $mainworksheet->write($counter+1, 5, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
00299                                                         $mainworksheet->write($counter+1, 6, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
00300                                                         break;
00301                                                 default:
00302                                                         $mainworksheet->write($counter+1, 5, ilExcelUtils::_convert_text($matches[1], $_POST["export_format"]));
00303                                                         $mainworksheet->write($counter+1, 6, ilExcelUtils::_convert_text($matches[2], $_POST["export_format"]));
00304                                                         break;
00305                                         }
00306                                         $mainworksheet->write($counter+1, 7, $eval["MODE_NR_OF_SELECTIONS"]);
00307                                         $mainworksheet->write($counter+1, 8, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval["MEDIAN"]), $_POST["export_format"]));
00308                                         $mainworksheet->write($counter+1, 9, $eval["ARITHMETIC_MEAN"]);
00309                                         break;
00310                                 case (TYPE_SPSS || TYPE_PRINT):
00311                                         $csvrow = array();
00312                                         array_push($csvrow, $data["title"]);
00313                                         array_push($csvrow, $data["questiontext"]);
00314                                         array_push($csvrow, $this->lng->txt($eval["QUESTION_TYPE"]));
00315                                         array_push($csvrow, $eval["USERS_ANSWERED"]);
00316                                         array_push($csvrow, $eval["USERS_SKIPPED"]);
00317                                         array_push($csvrow, $eval["MODE"]);
00318                                         array_push($csvrow, $eval["MODE_NR_OF_SELECTIONS"]);
00319                                         array_push($csvrow, $eval["MEDIAN"]);
00320                                         array_push($csvrow, $eval["ARITHMETIC_MEAN"]);
00321                                         array_push($csvfile, $csvrow);
00322                                         break;
00323                         }
00324                         $this->tpl->parseCurrentBlock();
00325                         if ($details)
00326                         {
00327                                 $printDetail = array();
00328                                 switch ($_POST["export_format"])
00329                                 {
00330                                         case TYPE_XLS:
00331                                                 include_once ("./classes/class.ilExcelUtils.php");
00332                                                 $worksheet =& $workbook->addWorksheet();
00333                                                 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_bold);
00334                                                 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($data["title"], $_POST["export_format"]));
00335                                                 $worksheet->writeString(1, 0, ilExcelUtils::_convert_text($this->lng->txt("question"), $_POST["export_format"]), $format_bold);
00336                                                 $worksheet->writeString(1, 1, ilExcelUtils::_convert_text($data["questiontext"], $_POST["export_format"]));
00337                                                 $worksheet->writeString(2, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type"), $_POST["export_format"]), $format_bold);
00338                                                 $worksheet->writeString(2, 1, ilExcelUtils::_convert_text($this->lng->txt($eval["QUESTION_TYPE"]), $_POST["export_format"]));
00339                                                 $worksheet->writeString(3, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered"), $_POST["export_format"]), $format_bold);
00340                                                 $worksheet->write(3, 1, $eval["USERS_ANSWERED"]);
00341                                                 $worksheet->writeString(4, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped"), $_POST["export_format"]), $format_bold);
00342                                                 $worksheet->write(4, 1, $eval["USERS_SKIPPED"]);
00343                                                 $rowcounter = 5;
00344                                                 break;
00345                                         case TYPE_PRINT:
00346                                                 array_push($printDetail, $this->lng->txt("title"));
00347                                                 array_push($printDetail, $data["title"]);
00348                                                 array_push($printDetail, $this->lng->txt("question"));
00349                                                 array_push($printDetail, $data["questiontext"]);
00350                                                 array_push($printDetail, $this->lng->txt("question_type"));
00351                                                 array_push($printDetail, $this->lng->txt($eval["QUESTION_TYPE"]));
00352                                                 array_push($printDetail, $this->lng->txt("users_answered"));
00353                                                 array_push($printDetail, $eval["USERS_ANSWERED"]);
00354                                                 array_push($printDetail, $this->lng->txt("users_skipped"));
00355                                                 array_push($printDetail, $eval["USERS_SKIPPED"]);
00356                                                 break;
00357                                 }
00358                                 $this->tpl->setCurrentBlock("detail");
00359                                 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
00360                                 $this->tpl->setVariable("TEXT_QUESTION_TEXT", $this->lng->txt("question"));
00361                                 $this->tpl->setVariable("QUESTION_TEXT", $data["questiontext"]);
00362                                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("question_type"));
00363                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($eval["QUESTION_TYPE"]));
00364                                 $this->tpl->setVariable("TEXT_USERS_ANSWERED", $this->lng->txt("users_answered"));
00365                                 $this->tpl->setVariable("USERS_ANSWERED", $eval["USERS_ANSWERED"]);
00366                                 $this->tpl->setVariable("TEXT_USERS_SKIPPED", $this->lng->txt("users_skipped"));
00367                                 $this->tpl->setVariable("USERS_SKIPPED", $eval["USERS_SKIPPED"]);
00368                                 switch ($eval["QUESTION_TYPE"])
00369                                 {
00370                                         case "qt_ordinal":
00371                                                 switch ($_POST["export_format"])
00372                                                 {
00373                                                         case TYPE_XLS:
00374                                                                 preg_match("/(.*?)\s+-\s+(.*)/", $eval["MODE"], $matches);
00375                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
00376                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1], $_POST["export_format"]));
00377                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
00378                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2], $_POST["export_format"]));
00379                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
00380                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE_NR_OF_SELECTIONS"], $_POST["export_format"]));
00381                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median"), $_POST["export_format"]), $format_bold);
00382                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval["MEDIAN"]), $_POST["export_format"]));
00383                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories"), $_POST["export_format"]), $format_bold);
00384                                                                 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_title);
00385                                                                 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value"), $_POST["export_format"]), $format_title);
00386                                                                 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected"), $_POST["export_format"]), $format_title);
00387                                                                 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections"), $_POST["export_format"]), $format_title);
00388                                                                 break;
00389                                                 }
00390                                                 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("mode"));
00391                                                 $this->tpl->setVariable("MODE", $eval["MODE"]);
00392                                                 $this->tpl->setVariable("TEXT_MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
00393                                                 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
00394                                                 $this->tpl->setVariable("TEXT_MEDIAN", $this->lng->txt("median"));
00395                                                 $this->tpl->setVariable("MEDIAN", $eval["MEDIAN"]);
00396                                                 $this->tpl->setVariable("TEXT_CATEGORIES", $this->lng->txt("categories"));
00397                                                 $categories = "";
00398                                                 foreach ($eval["variables"] as $key => $value)
00399                                                 {
00400                                                         $categories .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
00401                                                                 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
00402                                                                 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
00403                                                                 switch ($_POST["export_format"])
00404                                                                 {
00405                                                                         case TYPE_XLS:
00406                                                                                 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"], $_POST["export_format"]));
00407                                                                                 $worksheet->write($rowcounter, 2, $key+1);
00408                                                                                 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"], $_POST["export_format"]));
00409                                                                                 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"], $_POST["export_format"]), $format_percent);
00410                                                                                 break;
00411                                                                 }
00412                                                 }
00413                                                 $categories = "<ol>$categories</ol>";
00414                                                 $this->tpl->setVariable("VALUE_CATEGORIES", $categories);
00415                                                 
00416                                                 // display chart for ordinal question for array $eval["variables"]
00417                                                 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
00418                                                 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
00419                                                 $this->tpl->setVariable("CHART","./survey/displaychart.php?grName=" . urlencode($data["title"]) . 
00420                                                         "&type=bars" . 
00421                                                         "&x=" . urlencode($this->lng->txt("answers")) . 
00422                                                         "&y=" . urlencode($this->lng->txt("users_answered")) . 
00423                                                         "&arr=".base64_encode(serialize($eval["variables"])));
00424                                                 switch ($_POST["export_format"])
00425                                                 {
00426                                                         case TYPE_PRINT:
00427                                                                 array_push($printDetail, $this->lng->txt("mode"));
00428                                                                 array_push($printDetail, $eval["MODE"]);
00429                                                                 array_push($printDetail, $this->lng->txt("mode_nr_of_selections"));
00430                                                                 array_push($printDetail, $eval["MODE_NR_OF_SELECTIONS"]);
00431                                                                 array_push($printDetail, $this->lng->txt("median"));
00432                                                                 array_push($printDetail, $eval["MEDIAN"]);
00433                                                                 array_push($printDetail, $this->lng->txt("categories"));
00434                                                                 array_push($printDetail, $categories);
00435                                                                 break;
00436                                                 }
00437                                                 break;
00438                                         case "qt_nominal":
00439                                                 switch ($_POST["export_format"])
00440                                                 {
00441                                                         case TYPE_XLS:
00442                                                                 preg_match("/(.*?)\s+-\s+(.*)/", $eval["MODE"], $matches);
00443                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
00444                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1], $_POST["export_format"]));
00445                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
00446                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2], $_POST["export_format"]));
00447                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
00448                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE_NR_OF_SELECTIONS"], $_POST["export_format"]));
00449                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories"), $_POST["export_format"]), $format_bold);
00450                                                                 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_title);
00451                                                                 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value"), $_POST["export_format"]), $format_title);
00452                                                                 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected"), $_POST["export_format"]), $format_title);
00453                                                                 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections"), $_POST["export_format"]), $format_title);
00454                                                                 break;
00455                                                 }
00456                                                 array_push($printDetail, $this->lng->txt("subtype"));
00457                                                 $this->tpl->setVariable("TEXT_QUESTION_SUBTYPE", $this->lng->txt("subtype"));
00458                                                 $charttype = "bars";
00459                                                 switch ($data["subtype"])
00460                                                 {
00461                                                         case SUBTYPE_MCSR:
00462                                                                 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("multiple_choice_single_response"));
00463                                                                 array_push($printDetail, $this->lng->txt("multiple_choice_single_response"));
00464                                                                 break;
00465                                                         case SUBTYPE_MCMR:
00466                                                                 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("multiple_choice_multiple_response"));
00467                                                                 array_push($printDetail, $this->lng->txt("multiple_choice_multiple_response"));
00468                                                                 break;
00469                                                 }
00470                                                 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("mode"));
00471                                                 $this->tpl->setVariable("MODE", $eval["MODE"]);
00472                                                 $this->tpl->setVariable("TEXT_MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
00473                                                 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
00474                                                 $this->tpl->setVariable("TEXT_CATEGORIES", $this->lng->txt("categories"));
00475                                                 $categories = "";
00476                                                 foreach ($eval["variables"] as $key => $value)
00477                                                 {
00478                                                         $categories .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
00479                                                                 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
00480                                                                 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
00481                                                         switch ($_POST["export_format"])
00482                                                         {
00483                                                                 case TYPE_XLS:
00484                                                                         $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"], $_POST["export_format"]));
00485                                                                         $worksheet->write($rowcounter, 2, $key+1);
00486                                                                         $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"], $_POST["export_format"]));
00487                                                                         $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"], $_POST["export_format"]), $format_percent);
00488                                                                         break;
00489                                                         }
00490                                                 }
00491                                                 $categories = "<ol>$categories</ol>";
00492                                                 $this->tpl->setVariable("VALUE_CATEGORIES", $categories);
00493 
00494                                                 // display chart for nominal question for array $eval["variables"]
00495                                                 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
00496                                                 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
00497                                                 $this->tpl->setVariable("CHART","./survey/displaychart.php?grName=" . urlencode($data["title"]) .
00498                                                         "&type=bars" . 
00499                                                         "&x=" . urlencode($this->lng->txt("answers")) . 
00500                                                         "&y=" . urlencode($this->lng->txt("users_answered")) . 
00501                                                         "&arr=".base64_encode(serialize($eval["variables"])));
00502 
00503                                                 switch ($_POST["export_format"])
00504                                                 {
00505                                                         case TYPE_PRINT:
00506                                                                 array_push($printDetail, $this->lng->txt("mode"));
00507                                                                 array_push($printDetail, $eval["MODE"]);
00508                                                                 array_push($printDetail, $this->lng->txt("mode_nr_of_selections"));
00509                                                                 array_push($printDetail, $eval["MODE_NR_OF_SELECTIONS"]);
00510                                                                 array_push($printDetail, $this->lng->txt("categories"));
00511                                                                 array_push($printDetail, $categories);
00512                                                                 break;
00513                                                 }
00514                                                 break;
00515                                         case "qt_metric":
00516                                                 switch ($_POST["export_format"])
00517                                                 {
00518                                                         case TYPE_XLS:
00519                                                                 $worksheet->write($rowcounter, 0, $this->lng->txt("subtype"), $format_bold);
00520                                                                 switch ($data["subtype"])
00521                                                                 {
00522                                                                         case SUBTYPE_NON_RATIO:
00523                                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("non_ratio"), $_POST["export_format"]), $format_bold);
00524                                                                                 break;
00525                                                                         case SUBTYPE_RATIO_NON_ABSOLUTE:
00526                                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_non_absolute"), $_POST["export_format"]), $format_bold);
00527                                                                                 break;
00528                                                                         case SUBTYPE_RATIO_ABSOLUTE:
00529                                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_absolute"), $_POST["export_format"]), $format_bold);
00530                                                                                 break;
00531                                                                 }
00532                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
00533                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
00534                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
00535                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
00536                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
00537                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE_NR_OF_SELECTIONS"], $_POST["export_format"]));
00538                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median"), $_POST["export_format"]), $format_bold);
00539                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MEDIAN"], $_POST["export_format"]));
00540                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("arithmetic_mean"), $_POST["export_format"]), $format_bold);
00541                                                                 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["ARITHMETIC_MEAN"], $_POST["export_format"]));
00542                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("values"), $_POST["export_format"]), $format_bold);
00543                                                                 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("value"), $_POST["export_format"]), $format_title);
00544                                                                 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected"), $_POST["export_format"]), $format_title);
00545                                                                 $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections"), $_POST["export_format"]), $format_title);
00546                                                                 break;
00547                                                 }
00548                                                 $this->tpl->setVariable("TEXT_QUESTION_SUBTYPE", $this->lng->txt("subtype"));
00549                                                 array_push($printDetail, $this->lng->txt("subtype"));
00550                                                 switch ($data["subtype"])
00551                                                 {
00552                                                         case SUBTYPE_NON_RATIO:
00553                                                                 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("non_ratio"));
00554                                                                 array_push($printDetail, $this->lng->txt("non_ratio"));
00555                                                                 break;
00556                                                         case SUBTYPE_RATIO_NON_ABSOLUTE:
00557                                                                 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("ratio_non_absolute"));
00558                                                                 array_push($printDetail, $this->lng->txt("ratio_non_absolute"));
00559                                                                 break;
00560                                                         case SUBTYPE_RATIO_ABSOLUTE:
00561                                                                 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("ratio_absolute"));
00562                                                                 array_push($printDetail, $this->lng->txt("ratio_absolute"));
00563                                                                 break;
00564                                                 }
00565                                                 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("mode"));
00566                                                 $this->tpl->setVariable("MODE", $eval["MODE"]);
00567                                                 $this->tpl->setVariable("TEXT_MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
00568                                                 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
00569                                                 $this->tpl->setVariable("TEXT_MEDIAN", $this->lng->txt("median"));
00570                                                 $this->tpl->setVariable("MEDIAN", $eval["MEDIAN"]);
00571                                                 $this->tpl->setVariable("TEXT_ARITHMETIC_MEAN", $this->lng->txt("arithmetic_mean"));
00572                                                 $this->tpl->setVariable("ARITHMETIC_MEAN", $eval["ARITHMETIC_MEAN"]);
00573                                                 $this->tpl->setVariable("TEXT_VALUES", $this->lng->txt("values"));
00574                                                 $values = "";
00575                                                 if (is_array($eval["values"]))
00576                                                 {
00577                                                         foreach ($eval["values"] as $key => $value)
00578                                                         {
00579                                                                 $values .= "<li>" . $this->lng->txt("value") . ": " . "<span class=\"bold\">" . $value["value"] . "</span><br />" .
00580                                                                         $this->lng->txt("value_nr_entered") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
00581                                                                         $this->lng->txt("percentage_of_entered_values") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
00582                                                                 switch ($_POST["export_format"])
00583                                                                 {
00584                                                                         case TYPE_XLS:
00585                                                                                 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["value"], $_POST["export_format"]));
00586                                                                                 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($value["selected"], $_POST["export_format"]));
00587                                                                                 $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($value["percentage"], $_POST["export_format"]), $format_percent);
00588                                                                                 break;
00589                                                                 }
00590                                                         }
00591                                                 }
00592                                                 $values = "<ol>$values</ol>";
00593                                                 $this->tpl->setVariable("VALUE_VALUES", $values);
00594                                                 // display chart for metric question for array $eval["values"]
00595                                                 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
00596                                                 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
00597                                                 $this->tpl->setVariable("CHART","./survey/displaychart.php?grName=" . urlencode($data["title"]) . 
00598                                                         "&type=bars" . 
00599                                                         "&x=" . urlencode($this->lng->txt("answers")) . 
00600                                                         "&y=" . urlencode($this->lng->txt("users_answered")) . 
00601                                                         "&arr=".base64_encode(serialize($eval["values"])));
00602 
00603                                                 switch ($_POST["export_format"])
00604                                                 {
00605                                                         case TYPE_PRINT:
00606                                                                 array_push($printDetail, $this->lng->txt("mode"));
00607                                                                 array_push($printDetail, $eval["MODE"]);
00608                                                                 array_push($printDetail, $this->lng->txt("mode_nr_of_selections"));
00609                                                                 array_push($printDetail, $eval["MODE_NR_OF_SELECTIONS"]);
00610                                                                 array_push($printDetail, $this->lng->txt("median"));
00611                                                                 array_push($printDetail, $eval["MEDIAN"]);
00612                                                                 array_push($printDetail, $this->lng->txt("values"));
00613                                                                 array_push($printDetail, $values);
00614                                                                 break;
00615                                                 }
00616                                                 break;
00617                                         case "qt_text":
00618                                                 switch ($_POST["export_format"])
00619                                                 {
00620                                                         case TYPE_XLS:
00621                                                                 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("given_answers"), $_POST["export_format"]), $format_bold);
00622                                                                 break;
00623                                                 }
00624                                                 $this->tpl->setVariable("TEXT_TEXTVALUES", $this->lng->txt("given_answers"));
00625                                                 $textvalues = "";
00626                                                 if (is_array($eval["textvalues"]))
00627                                                 {
00628                                                         foreach ($eval["textvalues"] as $textvalue)
00629                                                         {
00630                                                                 $textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>";
00631                                                                 switch ($_POST["export_format"])
00632                                                                 {
00633                                                                         case TYPE_XLS:
00634                                                                                 $worksheet->write($rowcounter++, 1, $textvalue);
00635                                                                                 break;
00636                                                                 }
00637                                                         }
00638                                                 }
00639                                                 $textvalues = "<ul>$textvalues</ul>";
00640                                                 $this->tpl->setVariable("VALUE_TEXTVALUES", $textvalues);
00641                                                 switch ($_POST["export_format"])
00642                                                 {
00643                                                         case TYPE_PRINT:
00644                                                                 array_push($printDetail, $this->lng->txt("given_answers"));
00645                                                                 array_push($printDetail, $textvalues);
00646                                                                 break;
00647                                                 }
00648                                                 break;
00649                                 }
00650 
00651                                 if ($_POST["export_format"]==TYPE_PRINT)
00652                                 {
00653                                         $printdetail_file = array();
00654                                         array_push($printdetail_file, $printDetail);
00655                                         $s_question = $counter+1;
00656                                         $_SESSION[$this->lng->txt("question").$s_question] = $printdetail_file;
00657                                         $this->tpl->setVariable("PRINT_ACTION", $this->ctrl->getLinkTarget($this, "printEvaluation") . "&".$this->lng->txt("question")."=".$s_question);
00658                                         $this->tpl->setVariable("PRINT_TEXT", $this->lng->txt("print"));
00659                                         include_once "./classes/class.ilUtil.php";
00660                                         $this->tpl->setVariable("PRINT_IMAGE", ilUtil::getImagePath("icon_print.gif"));
00661                                 }
00662                                 $this->tpl->parseCurrentBlock();
00663                         }
00664                         $counter++;
00665                 }
00666                 if ($_POST["export_format"]==TYPE_PRINT)
00667                 {
00668                         $_SESSION["print_eval"] = $csvfile;
00669                 }
00670 
00671 
00672                 switch ($_POST["export_format"])
00673                 {
00674                         case TYPE_XLS:
00675                                 // Let's send the file
00676                                 $workbook->close();
00677                                 exit();
00678                                 break;
00679                         case TYPE_SPSS:
00680                                 $csv = "";
00681                                 $separator = ";";
00682                                 foreach ($csvfile as $csvrow)
00683                                 {
00684                                         $csvrow =& $this->object->processCSVRow($csvrow, TRUE, $separator);
00685                                         $csv .= join($csvrow, $separator) . "\n";
00686                                 }
00687                                 include_once "./classes/class.ilUtil.php";
00688                                 ilUtil::deliverData($csv, "$surveyname.csv");
00689                                 exit();
00690                                 break;
00691                 }
00692                 $this->tpl->setCurrentBlock("generic_css");
00693                 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./survey/templates/default/evaluation_print.css");
00694                 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
00695                 $this->tpl->parseCurrentBlock();
00696                 $this->tpl->setCurrentBlock("adm_content");
00697                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("title"));
00698                 $this->tpl->setVariable("QUESTION_TEXT", $this->lng->txt("question"));
00699                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("question_type"));
00700                 $this->tpl->setVariable("USERS_ANSWERED", $this->lng->txt("users_answered"));
00701                 $this->tpl->setVariable("USERS_SKIPPED", $this->lng->txt("users_skipped"));
00702                 $this->tpl->setVariable("MODE", $this->lng->txt("mode"));
00703                 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
00704                 $this->tpl->setVariable("MEDIAN", $this->lng->txt("median"));
00705                 $this->tpl->setVariable("ARITHMETIC_MEAN", $this->lng->txt("arithmetic_mean"));
00706                 $this->tpl->setVariable("EXPORT_DATA", $this->lng->txt("export_data_as"));
00707                 $this->tpl->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
00708                 $this->tpl->setVariable("TEXT_CSV", $this->lng->txt("exp_type_csv"));
00709                 $this->tpl->setVariable("VALUE_DETAIL", $details);
00710                 $this->tpl->setVariable("BTN_EXPORT", $this->lng->txt("export"));
00711                 $this->tpl->setVariable("BTN_PRINT", $this->lng->txt("print"));
00712                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00713                 $this->tpl->setVariable("PRINT_ACTION", $this->ctrl->getFormAction($this));
00714                 if ($details)
00715                 {
00716                         $this->tpl->setVariable("CMD_EXPORT", "evaluationdetails");
00717                 }
00718                 else
00719                 {
00720                         $this->tpl->setVariable("CMD_EXPORT", "evaluation");
00721                 }
00722                 $this->tpl->parseCurrentBlock();
00723         }
00724         
00732         function evaluationuser()
00733         {
00734                 if (!is_array($_POST))
00735                 {
00736                         $_POST = array();
00737                 }
00738                 $result = @include_once 'Spreadsheet/Excel/Writer.php';
00739                 if (!$result)
00740                 {
00741                         include_once './classes/Spreadsheet/Excel/Writer.php';
00742                 }
00743                 $format_bold = "";
00744                 $format_percent = "";
00745                 $format_datetime = "";
00746                 $format_title = "";
00747                 $format_title_plain = "";
00748                 $object_title = preg_replace("/[^a-zA-Z0-9\s]/", "", $this->object->getTitle());
00749                 $surveyname = preg_replace("/\s/", "_", $object_title);
00750 
00751                 if (!$_POST["export_format"])
00752                 {
00753                         $_POST["export_format"] = TYPE_PRINT;
00754                 }
00755 
00756                 $eval =& $this->object->getEvaluationForAllUsers();
00757                 $this->setEvalTabs();
00758                 sendInfo();
00759                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation_user.html", true);
00760                 $counter = 0;
00761                 $classes = array("tblrow1top", "tblrow2top");
00762                 $csvrow = array();
00763                 $questions =& $this->object->getSurveyQuestions(true);
00764                 $this->tpl->setCurrentBlock("headercell");
00765                 $this->tpl->setVariable("TEXT_HEADER_CELL", $this->lng->txt("username"));
00766                 $this->tpl->parseCurrentBlock();
00767                 if ($this->object->getAnonymize() == ANONYMIZE_OFF)
00768                 {
00769                         $this->tpl->setCurrentBlock("headercell");
00770                         $this->tpl->setVariable("TEXT_HEADER_CELL", $this->lng->txt("gender"));
00771                         $this->tpl->parseCurrentBlock();
00772                 }
00773                 if (array_key_exists("export_format", $_POST))
00774                 {
00775                         array_push($csvrow, $this->lng->txt("username"));
00776                         if ($this->object->getAnonymize() == ANONYMIZE_OFF)
00777                         {
00778                                 array_push($csvrow, $this->lng->txt("gender"));
00779                         }
00780                 }
00781                 $char = "A";
00782                 $cellcounter = 1;
00783                 foreach ($questions as $question_id => $question_data)
00784                 {
00785                         $this->tpl->setCurrentBlock("headercell");
00786                         $this->tpl->setVariable("TEXT_HEADER_CELL", $char);
00787                         $this->tpl->parseCurrentBlock();
00788                         $this->tpl->setCurrentBlock("legendrow");
00789                         $this->tpl->setVariable("TEXT_KEY", $char++);
00790                         $this->tpl->setVariable("TEXT_VALUE", $question_data["title"]);
00791                         if (array_key_exists("export_format", $_POST))
00792                         {
00793                                 array_push($csvrow, $question_data["title"]);
00794                                 switch ($question_data["questiontype_fi"])
00795                                 {
00796                                         case 1:
00797                                                 if ($question_data["subtype"] == SUBTYPE_MCMR)
00798                                                 {
00799                                                         foreach ($question_data["answers"] as $cat => $cattext)
00800                                                         {
00801                                                                 array_push($csvrow, ($cat+1) . " - $cattext");
00802                                                         }
00803                                                 }
00804                                                 break;
00805                                         case 2:
00806                                         case 3:
00807                                         case 4:
00808                                                 break;
00809                                 }
00810                         }
00811                         $this->tpl->parseCurrentBlock();
00812                 }
00813                 $csvfile = array();
00814                 array_push($csvfile, $csvrow);
00815 
00816                 foreach ($eval as $user_id => $resultset)
00817                 {
00818                         $csvrow = array();
00819                         $this->tpl->setCurrentBlock("bodycell");
00820                         $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
00821                         $this->tpl->setVariable("TEXT_BODY_CELL", $resultset["name"]);
00822                         array_push($csvrow, $resultset["name"]);
00823                         $this->tpl->parseCurrentBlock();
00824                         if ($this->object->getAnonymize() == ANONYMIZE_OFF)
00825                         {
00826                                 $this->tpl->setCurrentBlock("bodycell");
00827                                 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
00828                                 $this->tpl->setVariable("TEXT_BODY_CELL", $resultset["gender"]);
00829                                 array_push($csvrow, $resultset["gender"]);
00830                                 $this->tpl->parseCurrentBlock();
00831                         }
00832                         foreach ($questions as $question_id => $question_data)
00833                         {
00834                                 // csv output
00835                                 if (array_key_exists("export_format", $_POST))
00836                                 {
00837                                         switch ($question_data["questiontype_fi"])
00838                                         {
00839                                                 case 1:
00840                                                         // nominal question
00841                                                         if (count($resultset["answers"][$question_id]))
00842                                                         {
00843                                                                 if ($question_data["subtype"] == SUBTYPE_MCMR)
00844                                                                 {
00845                                                                         array_push($csvrow, "");
00846                                                                         foreach ($question_data["answers"] as $cat => $cattext)
00847                                                                         {
00848                                                                                 $found = 0;
00849                                                                                 foreach ($resultset["answers"][$question_id] as $answerdata)
00850                                                                                 {
00851                                                                                         if (strcmp($cat, $answerdata["value"]) == 0)
00852                                                                                         {
00853                                                                                                 $found = 1;
00854                                                                                         }
00855                                                                                 }
00856                                                                                 if ($found)
00857                                                                                 {
00858                                                                                         array_push($csvrow, "1");
00859                                                                                 }
00860                                                                                 else
00861                                                                                 {
00862                                                                                         array_push($csvrow, "0");
00863                                                                                 }
00864                                                                         }
00865                                                                 }
00866                                                                 else
00867                                                                 {
00868                                                                         array_push($csvrow, $resultset["answers"][$question_id][0]["value"]+1);
00869                                                                 }
00870                                                         }
00871                                                         else
00872                                                         {
00873                                                                 array_push($csvrow, $this->lng->txt("skipped"));
00874                                                                 if ($question_data["subtype"] == SUBTYPE_MCMR)
00875                                                                 {
00876                                                                         foreach ($question_data["answers"] as $cat => $cattext)
00877                                                                         {
00878                                                                                 array_push($csvrow, "");
00879                                                                         }
00880                                                                 }
00881                                                         }
00882                                                         break;
00883                                                 case 2:
00884                                                         // ordinal question
00885                                                         if (count($resultset["answers"][$question_id]))
00886                                                         {
00887                                                                 foreach ($resultset["answers"][$question_id] as $key => $answer)
00888                                                                 {
00889                                                                         array_push($csvrow, $answer["value"]+1);
00890                                                                 }
00891                                                         }
00892                                                         else
00893                                                         {
00894                                                                 array_push($csvrow, $this->lng->txt("skipped"));
00895                                                         }
00896                                                         break;
00897                                                 case 3:
00898                                                         // metric question
00899                                                         if (count($resultset["answers"][$question_id]))
00900                                                         {
00901                                                                 foreach ($resultset["answers"][$question_id] as $key => $answer)
00902                                                                 {
00903                                                                         array_push($csvrow, $answer["value"]);
00904                                                                 }
00905                                                         }
00906                                                         else
00907                                                         {
00908                                                                 array_push($csvrow, $this->lng->txt("skipped"));
00909                                                         }
00910                                                         break;
00911                                                 case 4:
00912                                                         // text question
00913                                                         if (count($resultset["answers"][$question_id]))
00914                                                         {
00915                                                                 foreach ($resultset["answers"][$question_id] as $key => $answer)
00916                                                                 {
00917                                                                         array_push($csvrow, $answer["textanswer"]);
00918                                                                 }
00919                                                         }
00920                                                         else
00921                                                         {
00922                                                                 array_push($csvrow, $this->lng->txt("skipped"));
00923                                                         }
00924                                                         break;
00925                                         }
00926                                 }
00927                                 // html output
00928                                 if (count($resultset["answers"][$question_id]))
00929                                 {
00930                                         $answervalues = array();
00931                                         include_once "./classes/class.ilUtil.php";
00932                                         foreach ($resultset["answers"][$question_id] as $key => $answer)
00933                                         {
00934                                                 switch ($question_data["questiontype_fi"])
00935                                                 {
00936                                                         case 1:
00937                                                                 // nominal question
00938                                                                 if (strcmp($answer["value"], "") != 0)
00939                                                                 {
00940                                                                         array_push($answervalues, ($answer["value"]+1) . " - " . ilUtil::prepareFormOutput($questions[$question_id]["answers"][$answer["value"]]));
00941                                                                 }
00942                                                                 break;
00943                                                         case 2:
00944                                                                 // ordinal question
00945                                                                 array_push($answervalues, ($answer["value"]+1) . " - " . ilUtil::prepareFormOutput($questions[$question_id]["answers"][$answer["value"]]));
00946                                                                 break;
00947                                                         case 3:
00948                                                                 // metric question
00949                                                                 array_push($answervalues, $answer["value"]);
00950                                                                 break;
00951                                                         case 4:
00952                                                                 // text question
00953                                                                 array_push($answervalues, $answer["textanswer"]);
00954                                                                 break;
00955                                                 }
00956                                         }
00957                                         $this->tpl->setCurrentBlock("bodycell");
00958                                         $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
00959                                         $this->tpl->setVariable("TEXT_BODY_CELL", join($answervalues, "<br />"));
00960                                         $this->tpl->parseCurrentBlock();
00961                                 }
00962                                 else
00963                                 {
00964                                         $this->tpl->setCurrentBlock("bodycell");
00965                                         $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
00966                                         $this->tpl->setVariable("TEXT_BODY_CELL", $this->lng->txt("skipped"));
00967                                         $this->tpl->parseCurrentBlock();
00968                                 }
00969                         }
00970                         $this->tpl->setCurrentBlock("row");
00971                         $this->tpl->parse("row");
00972                         $counter++;
00973                         array_push($csvfile, $csvrow);
00974                 }
00975                 $this->tpl->setCurrentBlock("generic_css");
00976                 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./survey/templates/default/evaluation_print.css");
00977                 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
00978                 $this->tpl->parseCurrentBlock();
00979                 $this->tpl->setCurrentBlock("adm_content");
00980                 $this->tpl->setVariable("EXPORT_DATA", $this->lng->txt("export_data_as"));
00981                 $this->tpl->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
00982                 $this->tpl->setVariable("TEXT_CSV", $this->lng->txt("exp_type_csv"));
00983                 $this->tpl->setVariable("BTN_EXPORT", $this->lng->txt("export"));
00984                 $this->tpl->setVariable("BTN_PRINT", $this->lng->txt("print"));
00985                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00986                 $this->tpl->setVariable("PRINT_ACTION", $this->ctrl->getFormAction($this));
00987                 $this->tpl->setVariable("TEXT_LEGEND", $this->lng->txt("legend"));
00988                 $this->tpl->setVariable("TEXT_LEGEND_LINK", $this->lng->txt("eval_legend_link"));
00989                 $this->tpl->setVariable("CMD_EXPORT", "evaluationuser");
00990                 $this->tpl->parseCurrentBlock();
00991                 switch ($_POST["export_format"])
00992                 {
00993                         case TYPE_XLS:
00994                                 // Let's send the file
00995                                 // Creating a workbook
00996                                 $workbook = new Spreadsheet_Excel_Writer();
00997 
00998                                 // sending HTTP headers
00999                                 $workbook->send("$surveyname.xls");
01000 
01001                                 // Creating a worksheet
01002                                 $format_bold =& $workbook->addFormat();
01003                                 $format_bold->setBold();
01004                                 $format_percent =& $workbook->addFormat();
01005                                 $format_percent->setNumFormat("0.00%");
01006                                 $format_datetime =& $workbook->addFormat();
01007                                 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
01008                                 $format_title =& $workbook->addFormat();
01009                                 $format_title->setBold();
01010                                 $format_title->setColor('black');
01011                                 $format_title->setPattern(1);
01012                                 $format_title->setFgColor('silver');
01013                                 $format_title_plain =& $workbook->addFormat();
01014                                 $format_title_plain->setColor('black');
01015                                 $format_title_plain->setPattern(1);
01016                                 $format_title_plain->setFgColor('silver');
01017                                 // Creating a worksheet
01018                                 $mainworksheet =& $workbook->addWorksheet();
01019                                 $row = 0;
01020                                 include_once "./classes/class.ilExcelUtils.php";
01021                                 foreach ($csvfile as $csvrow)
01022                                 {
01023                                         $col = 0;
01024                                         if ($row == 0)
01025                                         {
01026                                                 foreach ($csvrow as $text)
01027                                                 {
01028                                                         $mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]), $format_title);
01029                                                 }
01030                                         }
01031                                         else
01032                                         {
01033                                                 foreach ($csvrow as $text)
01034                                                 {
01035                                                         if (is_numeric($text))
01036                                                         {
01037                                                                 $mainworksheet->writeNumber($row, $col++, $text);
01038                                                         }
01039                                                         else
01040                                                         {
01041                                                                 $mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]));
01042                                                         }
01043                                                 }
01044                                         }
01045                                         $row++;
01046                                 }
01047                                 $workbook->close();
01048                                 exit();
01049                                 break;
01050                         case TYPE_SPSS:
01051                                 $csv = "";
01052                                 $separator = ";";
01053                                 foreach ($csvfile as $csvrow)
01054                                 {
01055                                         $csvrow =& $this->object->processCSVRow($csvrow, TRUE, $separator);
01056                                         $csv .= join($csvrow, $separator) . "\n";
01057                                 }
01058                                 include_once "./classes/class.ilUtil.php";
01059                                 ilUtil::deliverData($csv, "$surveyname.csv");
01060                                 exit();
01061                                 break;
01062                 }
01063         }
01064         
01072         function setEvalTabs()
01073         {
01074                 global $rbacsystem,$ilTabs;
01075 
01076                 include_once "./classes/class.ilTabsGUI.php";
01077                 $tabs_gui =& new ilTabsGUI();
01078                 
01079                 $tabs_gui->addTarget(
01080                         "svy_eval_cumulated", 
01081                         $this->ctrl->getLinkTargetByClass(get_class($this), "evaluation"), 
01082                         array("evaluation", "checkEvaluationAccess"),   
01083                         ""
01084                 );
01085 
01086                 $tabs_gui->addTarget(
01087                         "svy_eval_detail", 
01088                         $this->ctrl->getLinkTargetByClass(get_class($this), "evaluationdetails"), 
01089                         array("evaluationdetails"),     
01090                         ""
01091                 );
01092                 
01093                 $tabs_gui->addTarget(
01094                         "svy_eval_user", 
01095                         $this->ctrl->getLinkTargetByClass(get_class($this), "evaluationuser"), 
01096                         array("evaluationuser"),        
01097                         ""
01098                 );
01099                 $ilTabs = $tabs_gui;
01100                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01101         }
01102         
01103 }
01104 ?>

Generated on Fri Dec 13 2013 11:58:02 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1