ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilTestExport Class Reference

Export class for tests. More...

+ Collaboration diagram for ilTestExport:

Public Member Functions

 __construct (&$a_test_obj, $a_mode="xml")
 Constructor. More...
 
 isResultExportingEnabledForTestExport ()
 
 setResultExportingEnabledForTestExport ($resultExprtingEnabledForTestExport)
 
 getExtension ()
 
 getInstId ()
 
 buildExportFile ()
 build export file (complete zip file) More...
 
 buildExportResultFile ()
 build xml export file More...
 
 exportToExcel ($deliver=TRUE, $filterby="", $filtertext="", $passedonly=FALSE)
 Exports the evaluation data to the Microsoft Excel file format. More...
 
 exportToCSV ($deliver=TRUE, $filterby="", $filtertext="", $passedonly=FALSE)
 Exports the evaluation data to the CSV file format. More...
 
 buildExportFileXML ()
 build xml export file More...
 
 exportXHTMLMediaObjects ($a_export_dir)
 

Data Fields

 $err
 
 $db
 
 $ilias
 
 $test_obj
 
 $inst_id
 
 $mode
 

Protected Member Functions

 aggregatedResultsToExcel ($deliver=TRUE)
 Exports the aggregated results to the Microsoft Excel file format. More...
 
 aggregatedResultsToCSV ($deliver=TRUE)
 Exports the aggregated results to CSV. More...
 

Protected Attributes

 $resultExportingEnabledForTestExport = false
 

Private Attributes

 $lng
 
 $resultsfile
 

Detailed Description

Export class for tests.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 18 of file class.ilTestExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestExport::__construct ( $a_test_obj,
  $a_mode = "xml" 
)

Constructor.

Definition at line 45 of file class.ilTestExport.php.

46 {
47 global $ilErr, $ilDB, $ilias, $lng;
48
49 $this->test_obj =& $a_test_obj;
50
51 $this->err =& $ilErr;
52 $this->ilias =& $ilias;
53 $this->db =& $ilDB;
54 $this->mode = $a_mode;
55 $this->lng =& $lng;
56
57 $this->inst_id = IL_INST_ID;
58
59 $date = time();
60 $this->export_dir = $this->test_obj->getExportDirectory();
61 switch($this->mode)
62 {
63 case "results":
64 $this->subdir = $date."__".$this->inst_id."__".
65 "tst__results_".$this->test_obj->getId();
66 break;
67 case "aggregated":
68 $this->subdir = $date."__".$this->inst_id."__".
69 "test__aggregated__results_".$this->test_obj->getId();
70 break;
71 default:
72 $this->subdir = $date."__".$this->inst_id."__".
73 "tst"."_".$this->test_obj->getId();
74 $this->filename = $this->subdir.".xml";
75 $this->resultsfile = $date."__".$this->inst_id."__".
76 "results"."_".$this->test_obj->getId().".xml";
77 $this->qti_filename = $date."__".$this->inst_id."__".
78 "qti"."_".$this->test_obj->getId().".xml";
79 break;
80 }
81 $this->filename = $this->subdir.".".$this->getExtension();
82 }
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB

References $ilDB, $ilErr, $ilias, $lng, and getExtension().

+ Here is the call graph for this function:

Member Function Documentation

◆ aggregatedResultsToCSV()

ilTestExport::aggregatedResultsToCSV (   $deliver = TRUE)
protected

Exports the aggregated results to CSV.

Parameters
boolean$deliverTRUE to directly deliver the file, FALSE to return the data

Definition at line 242 of file class.ilTestExport.php.

243 {
244 $data = $this->test_obj->getAggregatedResultsData();
245 $rows = array();
246 array_push($rows, array(
247 $this->lng->txt("result"),
248 $this->lng->txt("value")
249 ));
250 foreach ($data["overview"] as $key => $value)
251 {
252 array_push($rows, array(
253 $key,
254 $value
255 ));
256 }
257 array_push($rows, array(
258 $this->lng->txt("question_title"),
259 $this->lng->txt("average_reached_points"),
260 $this->lng->txt("points"),
261 $this->lng->txt("percentage"),
262 $this->lng->txt("number_of_answers")
263 ));
264 foreach ($data["questions"] as $key => $value)
265 {
266 array_push($rows, array(
267 $value[0],
268 $value[4],
269 $value[5],
270 $value[6],
271 $value[3]
272 ));
273 }
274 $csv = "";
275 $separator = ";";
276 foreach ($rows as $evalrow)
277 {
278 $csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE, $separator);
279 $csv .= join($csvrow, $separator) . "\n";
280 }
281 if ($deliver)
282 {
283 ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "_aggregated.csv"));
284 exit;
285 }
286 else
287 {
288 return $csv;
289 }
290 }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
$separator
exit
Definition: login.php:54

References $data, $separator, ilUtil\deliverData(), exit, and ilUtil\getASCIIFilename().

Referenced by exportToCSV().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aggregatedResultsToExcel()

ilTestExport::aggregatedResultsToExcel (   $deliver = TRUE)
protected

Exports the aggregated results to the Microsoft Excel file format.

Parameters
boolean$deliverTRUE to directly deliver the file, FALSE to return the binary data

Definition at line 174 of file class.ilTestExport.php.

175 {
176 $data = $this->test_obj->getAggregatedResultsData();
177 include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
178 $excelfile = ilUtil::ilTempnam();
179 $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
180 $testname = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->test_obj->getTitle() . '_aggregated')) . ".xls";
181 $workbook = $adapter->getWorkbook();
182 $workbook->setVersion(8); // Use Excel97/2000 Format
183 // Creating a worksheet
184 $format_percent =& $workbook->addFormat();
185 $format_percent->setNumFormat("0.00%");
186 $format_title =& $workbook->addFormat();
187 $format_title->setBold();
188 $format_title->setColor('black');
189 $format_title->setPattern(1);
190 $format_title->setFgColor('silver');
191 include_once "./Services/Excel/classes/class.ilExcelUtils.php";
192 $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt("tst_results_aggregated")));
193 $row = 0;
194 $col = 0;
195 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("result")), $format_title);
196 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
197 $row++;
198 foreach ($data["overview"] as $key => $value)
199 {
200 $col = 0;
201 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($key));
202 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($value));
203 $row++;
204 }
205 $row++;
206 $col = 0;
207 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("question_id")), $format_title);
208 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("question_title")), $format_title);
209 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("average_reached_points")), $format_title);
210 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("points")), $format_title);
211 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("percentage")), $format_title);
212 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("number_of_answers")), $format_title);
213 $row++;
214 foreach ($data["questions"] as $key => $value)
215 {
216 $col = 0;
217 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($key));
218 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($value[0]));
219 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($value[4]));
220 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($value[5]));
221 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($value[6]), $format_percent);
222 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($value[3]));
223 $row++;
224 }
225 $workbook->close();
226 if ($deliver)
227 {
228 ilUtil::deliverFile($excelfile, $testname, "application/vnd.ms-excel", false, true);
229 exit;
230 }
231 else
232 {
233 return $excelfile;
234 }
235 }
_convert_text($a_text, $a_target="has been removed")
Class ilExcelWriterAdapter.
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

References $data, $row, ilExcelUtils\_convert_text(), ilUtil\deliverFile(), exit, ilUtil\getASCIIFilename(), and ilUtil\ilTempnam().

Referenced by exportToExcel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFile()

ilTestExport::buildExportFile ( )

build export file (complete zip file)

@access public

Returns

Definition at line 121 of file class.ilTestExport.php.

122 {
123 switch ($this->mode)
124 {
125 case "results":
126 return $this->buildExportResultFile();
127 break;
128 default:
129 return $this->buildExportFileXML();
130 break;
131 }
132 }
buildExportResultFile()
build xml export file
buildExportFileXML()
build xml export file

References buildExportFileXML(), and buildExportResultFile().

+ Here is the call graph for this function:

◆ buildExportFileXML()

ilTestExport::buildExportFileXML ( )

build xml export file

Definition at line 1014 of file class.ilTestExport.php.

1015 {
1016 global $ilBench;
1017
1018 $ilBench->start("TestExport", "buildExportFile");
1019
1020 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
1021 $this->xml = new ilXmlWriter;
1022
1023 // set dtd definition
1024 $this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
1025
1026 // set generated comment
1027 $this->xml->xmlSetGenCmt("Export of ILIAS Test ".
1028 $this->test_obj->getId()." of installation ".$this->inst.".");
1029
1030 // set xml header
1031 $this->xml->xmlHeader();
1032
1033 // create directories
1034 $this->test_obj->createExportDirectory();
1035 include_once "./Services/Utilities/classes/class.ilUtil.php";
1036 ilUtil::makeDir($this->export_dir."/".$this->subdir);
1037 ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
1038
1039 // get Log File
1040 $expDir = $this->test_obj->getExportDirectory();
1041 include_once "./Services/Logging/classes/class.ilLog.php";
1042 $expLog = new ilLog($expDir, "export.log");
1043 $expLog->delete();
1044 $expLog->setLogFormat("");
1045 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
1046
1047 // write qti file
1048 $qti_file = fopen($this->export_dir."/".$this->subdir."/".$this->qti_filename, "w");
1049 fwrite($qti_file, $this->test_obj->toXML());
1050 fclose($qti_file);
1051
1052 // get xml content
1053 $ilBench->start("TestExport", "buildExportFile_getXML");
1054 $this->test_obj->exportPagesXML($this->xml, $this->inst_id,
1055 $this->export_dir."/".$this->subdir, $expLog);
1056 $ilBench->stop("TestExport", "buildExportFile_getXML");
1057
1058 // dump xml document to screen (only for debugging reasons)
1059 /*
1060 echo "<PRE>";
1061 echo htmlentities($this->xml->xmlDumpMem($format));
1062 echo "</PRE>";
1063 */
1064
1065 // dump xml document to file
1066 $ilBench->start("TestExport", "buildExportFile_dumpToFile");
1067 $this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
1068 , false);
1069 $ilBench->stop("TestExport", "buildExportFile_dumpToFile");
1070
1071 if ($this->isResultExportingEnabledForTestExport() && @file_exists("./Modules/Test/classes/class.ilTestResultsToXML.php"))
1072 {
1073 // dump results xml document to file
1074 include_once "./Modules/Test/classes/class.ilTestResultsToXML.php";
1075 $resultwriter = new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity());
1076 $ilBench->start("TestExport", "buildExportFile_results");
1077 $resultwriter->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->resultsfile, false);
1078 $ilBench->stop("TestExport", "buildExportFile_results");
1079 }
1080
1081 // add media objects which were added with tiny mce
1082 $ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
1083 $this->exportXHTMLMediaObjects($this->export_dir."/".$this->subdir);
1084 $ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
1085
1086 // zip the file
1087 $ilBench->start("TestExport", "buildExportFile_zipFile");
1088 ilUtil::zip($this->export_dir."/".$this->subdir,
1089 $this->export_dir."/".$this->subdir.".zip");
1090 $ilBench->stop("TestExport", "buildExportFile_zipFile");
1091
1092 // destroy writer object
1093 $this->xml->_XmlWriter;
1094
1095 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
1096 $ilBench->stop("TestExport", "buildExportFile");
1097
1098 return $this->export_dir."/".$this->subdir.".zip";
1099 }
logging
Definition: class.ilLog.php:19
exportXHTMLMediaObjects($a_export_dir)
isResultExportingEnabledForTestExport()
Test results to XML class.
static zip($a_dir, $a_file, $compress_content=false)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
XML writer class.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $ilBench
Definition: ilias.php:18

References $ilBench, exportXHTMLMediaObjects(), isResultExportingEnabledForTestExport(), ilUtil\makeDir(), ilXmlWriter\xmlSetDtdDef(), and ilUtil\zip().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportResultFile()

ilTestExport::buildExportResultFile ( )

build xml export file

Definition at line 137 of file class.ilTestExport.php.

138 {
139 global $ilBench;
140 global $log;
141
142 //get Log File
143 $expDir = $this->test_obj->getExportDirectory();
144
145 // make_directories
146 $this->test_obj->createExportDirectory();
147 include_once "./Services/Utilities/classes/class.ilUtil.php";
148 ilUtil::makeDir($this->export_dir);
149
150 $expLog = new ilLog($expDir, "export.log");
151 $expLog->delete();
152 $expLog->setLogFormat("");
153 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Of Results");
154
155 $data = $this->exportToCSV($deliver = FALSE);
156 $file = fopen($this->export_dir."/".$this->filename, "w");
157 fwrite($file, $data);
158 fclose($file);
159
160 $excelfile = $this->exportToExcel($deliver = FALSE);
161 @copy($excelfile, $this->export_dir . "/" . str_replace($this->getExtension(), "xls", $this->filename));
162 @unlink($excelfile);
163 // end
164 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export of Results");
165
166 return $this->export_dir."/".$this->filename;
167 }
print $file
$filename
Definition: buildRTE.php:89
exportToExcel($deliver=TRUE, $filterby="", $filtertext="", $passedonly=FALSE)
Exports the evaluation data to the Microsoft Excel file format.
exportToCSV($deliver=TRUE, $filterby="", $filtertext="", $passedonly=FALSE)
Exports the evaluation data to the CSV file format.

References $data, $file, $filename, $ilBench, $log, exportToCSV(), exportToExcel(), getExtension(), and ilUtil\makeDir().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportToCSV()

ilTestExport::exportToCSV (   $deliver = TRUE,
  $filterby = "",
  $filtertext = "",
  $passedonly = FALSE 
)

Exports the evaluation data to the CSV file format.

Exports the evaluation data to the CSV file format

Parameters
string$filtertextFilter text for the user data
boolean$passedonlyTRUE if only passed user datasets should be exported, FALSE otherwise @access public

Definition at line 783 of file class.ilTestExport.php.

784 {
785 global $ilLog;
786
787 if (strcmp($this->mode, "aggregated") == 0) return $this->aggregatedResultsToCSV($deliver);
788
789 $rows = array();
790 $datarow = array();
791 $col = 1;
792 if ($this->test_obj->getAnonymity())
793 {
794 array_push($datarow, $this->lng->txt("counter"));
795 $col++;
796 }
797 else
798 {
799 array_push($datarow, $this->lng->txt("name"));
800 $col++;
801 array_push($datarow, $this->lng->txt("login"));
802 $col++;
803 }
804 $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
805 if (count($additionalFields))
806 {
807 foreach ($additionalFields as $fieldname)
808 {
809 array_push($datarow, $this->lng->txt($fieldname));
810 $col++;
811 }
812 }
813 array_push($datarow, $this->lng->txt("tst_stat_result_resultspoints"));
814 $col++;
815 array_push($datarow, $this->lng->txt("maximum_points"));
816 $col++;
817 array_push($datarow, $this->lng->txt("tst_stat_result_resultsmarks"));
818 $col++;
819 if ($this->test_obj->getECTSOutput())
820 {
821 array_push($datarow, $this->lng->txt("ects_grade"));
822 $col++;
823 }
824 array_push($datarow, $this->lng->txt("tst_stat_result_qworkedthrough"));
825 $col++;
826 array_push($datarow, $this->lng->txt("tst_stat_result_qmax"));
827 $col++;
828 array_push($datarow, $this->lng->txt("tst_stat_result_pworkedthrough"));
829 $col++;
830 array_push($datarow, $this->lng->txt("tst_stat_result_timeofwork"));
831 $col++;
832 array_push($datarow, $this->lng->txt("tst_stat_result_atimeofwork"));
833 $col++;
834 array_push($datarow, $this->lng->txt("tst_stat_result_firstvisit"));
835 $col++;
836 array_push($datarow, $this->lng->txt("tst_stat_result_lastvisit"));
837 $col++;
838
839 array_push($datarow, $this->lng->txt("tst_stat_result_mark_median"));
840 $col++;
841 array_push($datarow, $this->lng->txt("tst_stat_result_rank_participant"));
842 $col++;
843 array_push($datarow, $this->lng->txt("tst_stat_result_rank_median"));
844 $col++;
845 array_push($datarow, $this->lng->txt("tst_stat_result_total_participants"));
846 $col++;
847 array_push($datarow, $this->lng->txt("tst_stat_result_median"));
848 $col++;
849 array_push($datarow, $this->lng->txt("scored_pass"));
850 $col++;
851
852 array_push($datarow, $this->lng->txt("pass"));
853 $col++;
854
855 $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
856 $headerrow = $datarow;
857 $counter = 1;
858 foreach ($data->getParticipants() as $active_id => $userdata)
859 {
860 $datarow = $headerrow;
861 $remove = FALSE;
862 if ($passedonly)
863 {
864 if ($data->getParticipant($active_id)->getPassed() == FALSE)
865 {
866 $remove = TRUE;
867 }
868 }
869 if (!$remove)
870 {
871 $datarow2 = array();
872 if ($this->test_obj->getAnonymity())
873 {
874 array_push($datarow2, $counter);
875 }
876 else
877 {
878 array_push($datarow2, $data->getParticipant($active_id)->getName());
879 array_push($datarow2, $data->getParticipant($active_id)->getLogin());
880 }
881 if (count($additionalFields))
882 {
883 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
884 foreach ($additionalFields as $fieldname)
885 {
886 if (strcmp($fieldname, "gender") == 0)
887 {
888 array_push($datarow2, $this->lng->txt("gender_" . $userfields[$fieldname]));
889 }
890 else
891 {
892 array_push($datarow2, $userfields[$fieldname]);
893 }
894 }
895 }
896 array_push($datarow2, $data->getParticipant($active_id)->getReached());
897 array_push($datarow2, $data->getParticipant($active_id)->getMaxpoints());
898 array_push($datarow2, $data->getParticipant($active_id)->getMark());
899 if ($this->test_obj->getECTSOutput())
900 {
901 array_push($datarow2, $data->getParticipant($active_id)->getECTSMark());
902 }
903 array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThrough());
904 array_push($datarow2, $data->getParticipant($active_id)->getNumberOfQuestions());
905 array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0);
906 $time = $data->getParticipant($active_id)->getTimeOfWork();
907 $time_seconds = $time;
908 $time_hours = floor($time_seconds/3600);
909 $time_seconds -= $time_hours * 3600;
910 $time_minutes = floor($time_seconds/60);
911 $time_seconds -= $time_minutes * 60;
912 array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
913 $time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
914 $time_seconds = $time;
915 $time_hours = floor($time_seconds/3600);
916 $time_seconds -= $time_hours * 3600;
917 $time_minutes = floor($time_seconds/60);
918 $time_seconds -= $time_minutes * 60;
919 array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
920
921 $fv = $data->getParticipant($active_id)->getFirstVisit();
922 $lv = $data->getParticipant($active_id)->getLastVisit();
923 foreach(array($fv, $lv) as $ts)
924 {
925 if($ts)
926 {
927 $visit = ilFormat::formatDate(date('Y-m-d H:i:s', $ts), "datetime", false, false);
928 array_push($datarow2, $visit);
929 }
930 else
931 {
932 array_push($datarow2, "");
933 }
934 }
935
936 $median = $data->getStatistics()->getStatistics()->median();
937 $pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
938 $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
939 $mark_short_name = "";
940 if (is_object($mark))
941 {
942 $mark_short_name = $mark->getShortName();
943 }
944 array_push($datarow2, $mark_short_name);
945 array_push($datarow2, $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
946 array_push($datarow2, $data->getStatistics()->getStatistics()->rank_median());
947 array_push($datarow2, $data->getStatistics()->getStatistics()->count());
948 array_push($datarow2, $median);
949 if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS)
950 {
951 array_push($datarow2, $data->getParticipant($active_id)->getBestPass() + 1);
952 }
953 else
954 {
955 array_push($datarow2, $data->getParticipant($active_id)->getLastPass() + 1);
956 }
957 for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
958 {
959 $finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
960 if ($finishdate > 0)
961 {
962 if ($pass > 0)
963 {
964 for ($i = 1; $i < $col-1; $i++)
965 {
966 array_push($datarow2, "");
967 array_push($datarow, "");
968 }
969 array_push($datarow, "");
970 }
971 array_push($datarow2, $pass+1);
972 if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass)))
973 {
974 foreach ($data->getParticipant($active_id)->getQuestions($pass) as $question)
975 {
976 $question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
977 array_push($datarow2, $question_data["reached"]);
978 array_push($datarow, preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"])));
979 }
980 }
981 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions() || ($counter == 1 && $pass == 0))
982 {
983 array_push($rows, $datarow);
984 }
985 $datarow = array();
986 array_push($rows, $datarow2);
987 $datarow2 = array();
988 }
989 }
990 $counter++;
991 }
992 }
993 $csv = "";
994 $separator = ";";
995 foreach ($rows as $evalrow)
996 {
997 $csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE, $separator);
998 $csv .= join($csvrow, $separator) . "\n";
999 }
1000 if ($deliver)
1001 {
1002 ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "_results.csv"));
1003 exit;
1004 }
1005 else
1006 {
1007 return $csv;
1008 }
1009 }
formatDate($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
format a date according to the user language shortcut for Format::fmtDateTime @access public
_lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
aggregatedResultsToCSV($deliver=TRUE)
Exports the aggregated results to CSV.
const SCORE_BEST_PASS

References $data, $ilLog, $pass, $separator, ilObjUser\_lookupFields(), aggregatedResultsToCSV(), ilUtil\deliverData(), exit, ilFormat\formatDate(), ilUtil\getASCIIFilename(), and SCORE_BEST_PASS.

Referenced by buildExportResultFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportToExcel()

ilTestExport::exportToExcel (   $deliver = TRUE,
  $filterby = "",
  $filtertext = "",
  $passedonly = FALSE 
)

Exports the evaluation data to the Microsoft Excel file format.

Parameters
bool$deliver
string$filterby
string$filtertextFilter text for the user data
boolean$passedonlyTRUE if only passed user datasets should be exported, FALSE otherwise
Returns
string

Definition at line 302 of file class.ilTestExport.php.

303 {
304 if (strcmp($this->mode, "aggregated") == 0) return $this->aggregatedResultsToExcel($deliver);
305
306 require_once './Services/Excel/classes/class.ilExcelWriterAdapter.php';
307 $excelfile = ilUtil::ilTempnam();
308 $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
309 $testname = $this->test_obj->getTitle();
310 switch($this->mode)
311 {
312 case 'results':
313 $testname .= '_results';
314 break;
315 }
316 $testname = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $testname)) . ".xls";
317 $workbook = $adapter->getWorkbook();
318 $workbook->setVersion(8); // Use Excel97/2000 Format
319 // Creating a worksheet
320 $format_bold =& $workbook->addFormat();
321 $format_bold->setBold();
322 $format_percent =& $workbook->addFormat();
323 $format_percent->setNumFormat("0.00%");
324 $format_datetime =& $workbook->addFormat();
325 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
326 $format_title =& $workbook->addFormat();
327 $format_title->setBold();
328 $format_title->setColor('black');
329 $format_title->setPattern(1);
330 $format_title->setFgColor('silver');
331 require_once './Services/Excel/classes/class.ilExcelUtils.php';
332 $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt("tst_results")));
333 $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
334 $row = 0;
335 $col = 0;
336
337 if ($this->test_obj->getAnonymity())
338 {
339 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("counter")), $format_title);
340 }
341 else
342 {
343 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("name")), $format_title);
344 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("login")), $format_title);
345 }
346 if (count($additionalFields))
347 {
348 foreach ($additionalFields as $fieldname)
349 {
350 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt($fieldname)), $format_title);
351 }
352 }
353 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_resultspoints")), $format_title);
354 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("maximum_points")), $format_title);
355 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_resultsmarks")), $format_title);
356 if ($this->test_obj->getECTSOutput())
357 {
358 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("ects_grade")), $format_title);
359 }
360 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_qworkedthrough")), $format_title);
361 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_qmax")), $format_title);
362 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_pworkedthrough")), $format_title);
363 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_timeofwork")), $format_title);
364 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_atimeofwork")), $format_title);
365 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_firstvisit")), $format_title);
366 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_lastvisit")), $format_title);
367
368 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_mark_median")), $format_title);
369 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_rank_participant")), $format_title);
370 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_rank_median")), $format_title);
371 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_total_participants")), $format_title);
372 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_median")), $format_title);
373 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("scored_pass")), $format_title);
374
375 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("pass")), $format_title);
376
377 $counter = 1;
378 $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
379 $firstrowwritten = false;
380 foreach ($data->getParticipants() as $active_id => $userdata)
381 {
382 $remove = FALSE;
383 if ($passedonly)
384 {
385 if ($data->getParticipant($active_id)->getPassed() == FALSE)
386 {
387 $remove = TRUE;
388 }
389 }
390 if (!$remove)
391 {
392 $row++;
393 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions())
394 {
395 $row++;
396 }
397 $col = 0;
398 if ($this->test_obj->getAnonymity())
399 {
400 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($counter));
401 }
402 else
403 {
404 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getName()));
405 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getLogin()));
406 }
407 if (count($additionalFields))
408 {
409 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
410 foreach ($additionalFields as $fieldname)
411 {
412 if (strcmp($fieldname, "gender") == 0)
413 {
414 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("gender_" . $userfields[$fieldname])));
415 }
416 else
417 {
418 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
419 }
420 }
421 }
422 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getReached()));
423 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getMaxpoints()));
424 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getMark()));
425 if ($this->test_obj->getECTSOutput())
426 {
427 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getECTSMark()));
428 }
429 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getQuestionsWorkedThrough()));
430 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getNumberOfQuestions()));
431 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0, $format_percent);
432 $time = $data->getParticipant($active_id)->getTimeOfWork();
433 $time_seconds = $time;
434 $time_hours = floor($time_seconds/3600);
435 $time_seconds -= $time_hours * 3600;
436 $time_minutes = floor($time_seconds/60);
437 $time_seconds -= $time_minutes * 60;
438 $worksheet->write($row, $col++, ilExcelUtils::_convert_text(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)));
439 $time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
440 $time_seconds = $time;
441 $time_hours = floor($time_seconds/3600);
442 $time_seconds -= $time_hours * 3600;
443 $time_minutes = floor($time_seconds/60);
444 $time_seconds -= $time_minutes * 60;
445 $worksheet->write($row, $col++, ilExcelUtils::_convert_text(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)));
446 $fv = getdate($data->getParticipant($active_id)->getFirstVisit());
447 $firstvisit = ilUtil::excelTime(
448 $fv["year"],
449 $fv["mon"],
450 $fv["mday"],
451 $fv["hours"],
452 $fv["minutes"],
453 $fv["seconds"]
454 );
455 $worksheet->write($row, $col++, $firstvisit, $format_datetime);
456 $lv = getdate($data->getParticipant($active_id)->getLastVisit());
457 $lastvisit = ilUtil::excelTime(
458 $lv["year"],
459 $lv["mon"],
460 $lv["mday"],
461 $lv["hours"],
462 $lv["minutes"],
463 $lv["seconds"]
464 );
465 $worksheet->write($row, $col++, $lastvisit, $format_datetime);
466
467 $median = $data->getStatistics()->getStatistics()->median();
468 $pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
469 $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
470 $mark_short_name = "";
471 if (is_object($mark))
472 {
473 $mark_short_name = $mark->getShortName();
474 }
475 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($mark_short_name));
476 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached())));
477 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->rank_median()));
478 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->count()));
479 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($median));
480 if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS)
481 {
482 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getBestPass() + 1);
483 }
484 else
485 {
486 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getLastPass() + 1);
487 }
488 $startcol = $col;
489 for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
490 {
491 $col = $startcol;
492 $finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
493 if ($finishdate > 0)
494 {
495 if ($pass > 0)
496 {
497 $row++;
498 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions())
499 {
500 $row++;
501 }
502 }
503 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($pass+1));
504 if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass)))
505 {
506 foreach ($data->getParticipant($active_id)->getQuestions($pass) as $question)
507 {
508 $question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
509 $worksheet->write($row, $col, ilExcelUtils::_convert_text($question_data["reached"]));
510 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions())
511 {
512 $worksheet->write($row-1, $col, ilExcelUtils::_convert_text(preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))), $format_title);
513 }
514 else
515 {
516 if ($pass == 0 && !$firstrowwritten)
517 {
518 $worksheet->write(0, $col, ilExcelUtils::_convert_text(preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))), $format_title);
519 }
520 }
521 $col++;
522 }
523 $firstrowwritten = true;
524 }
525 }
526 }
527 $counter++;
528 }
529 }
530 if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions())
531 {
532 // special tab for single choice tests
533 $titles =& $this->test_obj->getQuestionTitlesAndIndexes();
534 $positions = array();
535 $pos = 0;
536 $row = 0;
537 foreach ($titles as $id => $title)
538 {
539 $positions[$id] = $pos;
540 $pos++;
541 }
542 $usernames = array();
543 $participantcount = count($data->getParticipants());
544 $allusersheet = false;
545 $pages = 0;
546 $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users"));
547
548 $col = 0;
549 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
550 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
551 if (count($additionalFields))
552 {
553 foreach ($additionalFields as $fieldname)
554 {
555 if (strcmp($fieldname, "matriculation") == 0)
556 {
557 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
558 }
559 }
560 }
561 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
562 foreach ($titles as $title)
563 {
564 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
565 }
566 $row++;
567
568 foreach ($data->getParticipants() as $active_id => $userdata)
569 {
570 $username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
571 if (array_key_exists($username, $usernames))
572 {
573 $usernames[$username]++;
574 $username .= " ($i)";
575 }
576 else
577 {
578 $usernames[$username] = 1;
579 }
580 $col = 0;
581 $resultsheet->write($row, $col++, $username);
582 $resultsheet->write($row, $col++, $userdata->getLogin());
583 if (count($additionalFields))
584 {
585 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
586 foreach ($additionalFields as $fieldname)
587 {
588 if (strcmp($fieldname, "matriculation") == 0)
589 {
590 if (strlen($userfields[$fieldname]))
591 {
592 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
593 }
594 else
595 {
596 $col++;
597 }
598 }
599 }
600 }
601 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
602 $pass = $userdata->getScoredPass();
603 if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
604 {
605 foreach ($userdata->getQuestions($pass) as $question)
606 {
607 $objQuestion = assQuestion::_instantiateQuestion($question["id"]);
608 if(is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0)
609 {
610 $solution = $objQuestion->getSolutionValues($active_id, $pass);
611 $pos = $positions[$question["id"]];
612 $selectedanswer = "x";
613 foreach ($objQuestion->getAnswers() as $id => $answer)
614 {
615 if (strlen($solution[0]["value1"]) && $id == $solution[0]["value1"])
616 {
617 $selectedanswer = $answer->getAnswertext();
618 }
619 }
620 $resultsheet->write($row, $col+$pos, ilExcelUtils::_convert_text($selectedanswer));
621 }
622 }
623 }
624 $row++;
625 }
626 if ($this->test_obj->isSingleChoiceTestWithoutShuffle())
627 {
628 // special tab for single choice tests without shuffle option
629 $pos = 0;
630 $row = 0;
631 $usernames = array();
632 $allusersheet = false;
633 $pages = 0;
634 $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . " (2)");
635
636 $col = 0;
637 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
638 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
639 if (count($additionalFields))
640 {
641 foreach ($additionalFields as $fieldname)
642 {
643 if (strcmp($fieldname, "matriculation") == 0)
644 {
645 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
646 }
647 }
648 }
649 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
650 foreach ($titles as $title)
651 {
652 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
653 }
654 $row++;
655
656 foreach ($data->getParticipants() as $active_id => $userdata)
657 {
658 $username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
659 if (array_key_exists($username, $usernames))
660 {
661 $usernames[$username]++;
662 $username .= " ($i)";
663 }
664 else
665 {
666 $usernames[$username] = 1;
667 }
668 $col = 0;
669 $resultsheet->write($row, $col++, $username);
670 $resultsheet->write($row, $col++, $userdata->getLogin());
671 if (count($additionalFields))
672 {
673 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
674 foreach ($additionalFields as $fieldname)
675 {
676 if (strcmp($fieldname, "matriculation") == 0)
677 {
678 if (strlen($userfields[$fieldname]))
679 {
680 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
681 }
682 else
683 {
684 $col++;
685 }
686 }
687 }
688 }
689 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
690 $pass = $userdata->getScoredPass();
691 if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
692 {
693 foreach ($userdata->getQuestions($pass) as $question)
694 {
695 $objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
696 if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0)
697 {
698 $solution = $objQuestion->getSolutionValues($active_id, $pass);
699 $pos = $positions[$question["aid"]];
700 $selectedanswer = chr(65+$solution[0]["value1"]);
701 $resultsheet->write($row, $col+$pos, ilExcelUtils::_convert_text($selectedanswer));
702 }
703 }
704 }
705 $row++;
706 }
707 }
708 }
709 else
710 {
711 // test participant result export
712 $usernames = array();
713 $participantcount = count($data->getParticipants());
714 $allusersheet = false;
715 $pages = 0;
716 $i = 0;
717 foreach ($data->getParticipants() as $active_id => $userdata)
718 {
719 $i++;
720
721 $username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
722 if (array_key_exists($username, $usernames))
723 {
724 $usernames[$username]++;
725 $username .= " ($i)";
726 }
727 else
728 {
729 $usernames[$username] = 1;
730 }
731 if ($participantcount > 250) {
732 if (!$allusersheet || ($pages-1) < floor($row / 64000)) {
733 $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . (($pages > 0) ? " (".($pages+1).")" : ""));
734 $allusersheet = true;
735 $row = 0;
736 $pages++;
737 }
738 } else {
739 $resultsheet =& $workbook->addWorksheet(utf8_decode($username));
740 }
741 if (method_exists($resultsheet, "writeString"))
742 {
743 $pass = $userdata->getScoredPass();
744 $row = ($allusersheet) ? $row : 0;
745 $resultsheet->writeString($row, 0, ilExcelUtils::_convert_text(sprintf($this->lng->txt("tst_result_user_name_pass"), $pass+1, $userdata->getName())), $format_bold);
746 $row += 2;
747 if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
748 {
749 foreach ($userdata->getQuestions($pass) as $question)
750 {
751 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
752 $question = assQuestion::_instanciateQuestion($question["id"]);
753 if (is_object($question))
754 {
755 $row = $question->setExportDetailsXLS($resultsheet, $row, $active_id, $pass, $format_title, $format_bold);
756 }
757 }
758 }
759 }
760 }
761 }
762 $workbook->close();
763 if ($deliver)
764 {
765 ilUtil::deliverFile($excelfile, $testname, "application/vnd.ms-excel", false, true);
766 exit;
767 }
768 else
769 {
770 return $excelfile;
771 }
772 }
static _instantiateQuestion($question_id)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
aggregatedResultsToExcel($deliver=TRUE)
Exports the aggregated results to the Microsoft Excel file format.
static excelTime($year="", $month="", $day="", $hour="", $minute="", $second="")
Calculates a Microsoft Excel date/time value.

References $data, $pass, $row, ilExcelUtils\_convert_text(), assQuestion\_instanciateQuestion(), assQuestion\_instantiateQuestion(), ilObjUser\_lookupFields(), aggregatedResultsToExcel(), ilUtil\deliverFile(), ilUtil\excelTime(), exit, ilUtil\getASCIIFilename(), ilUtil\ilTempnam(), and SCORE_BEST_PASS.

Referenced by buildExportResultFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXHTMLMediaObjects()

ilTestExport::exportXHTMLMediaObjects (   $a_export_dir)

Definition at line 1101 of file class.ilTestExport.php.

1102 {
1103 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1104
1105 $mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->test_obj->getId());
1106 foreach ($mobs as $mob)
1107 {
1108 if (ilObjMediaObject::_exists($mob))
1109 {
1110 $mob_obj =& new ilObjMediaObject($mob);
1111 $mob_obj->exportFiles($a_export_dir);
1112 unset($mob_obj);
1113 }
1114 }
1115 foreach ($this->test_obj->questions as $question_id)
1116 {
1117 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
1118 foreach ($mobs as $mob)
1119 {
1120 if (ilObjMediaObject::_exists($mob))
1121 {
1122 $mob_obj =& new ilObjMediaObject($mob);
1123 $mob_obj->exportFiles($a_export_dir);
1124 unset($mob_obj);
1125 }
1126 }
1127 }
1128 }
Class ilObjMediaObject.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id)
checks wether a lm content object with specified id exists or not
$mobs

References $mobs, ilObjMediaObject\_exists(), and ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExtension()

ilTestExport::getExtension ( )

Definition at line 100 of file class.ilTestExport.php.

100 {
101 switch ($this->mode) {
102 case "results":
103 return "csv"; break;
104 default:
105 return "xml"; break;
106 }
107 }

Referenced by __construct(), and buildExportResultFile().

+ Here is the caller graph for this function:

◆ getInstId()

ilTestExport::getInstId ( )

Definition at line 109 of file class.ilTestExport.php.

110 {
111 return $this->inst_id;
112 }

References $inst_id.

◆ isResultExportingEnabledForTestExport()

ilTestExport::isResultExportingEnabledForTestExport ( )
Returns
boolean

Definition at line 87 of file class.ilTestExport.php.

References $resultExportingEnabledForTestExport.

Referenced by buildExportFileXML().

+ Here is the caller graph for this function:

◆ setResultExportingEnabledForTestExport()

ilTestExport::setResultExportingEnabledForTestExport (   $resultExprtingEnabledForTestExport)
Parameters
boolean$resultExprtingEnabledForTestExport

Definition at line 95 of file class.ilTestExport.php.

96 {
97 $this->resultExportingEnabledForTestExport = $resultExprtingEnabledForTestExport;
98 }

Field Documentation

◆ $db

ilDB ilTestExport::$db

Definition at line 24 of file class.ilTestExport.php.

◆ $err

ilErrorHandling ilTestExport::$err

Definition at line 21 of file class.ilTestExport.php.

◆ $ilias

ILIAS ilTestExport::$ilias

Definition at line 27 of file class.ilTestExport.php.

Referenced by __construct().

◆ $inst_id

ilTestExport::$inst_id

Definition at line 32 of file class.ilTestExport.php.

Referenced by getInstId().

◆ $lng

ilLanguage ilTestExport::$lng
private

Definition at line 36 of file class.ilTestExport.php.

Referenced by __construct().

◆ $mode

ilTestExport::$mode

Definition at line 33 of file class.ilTestExport.php.

◆ $resultExportingEnabledForTestExport

ilTestExport::$resultExportingEnabledForTestExport = false
protected

Definition at line 40 of file class.ilTestExport.php.

Referenced by isResultExportingEnabledForTestExport().

◆ $resultsfile

ilTestExport::$resultsfile
private

Definition at line 38 of file class.ilTestExport.php.

◆ $test_obj

ilObjTest ilTestExport::$test_obj

Definition at line 30 of file class.ilTestExport.php.


The documentation for this class was generated from the following file: