ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestExport Class Reference

Export class for tests. More...

+ Collaboration diagram for ilTestExport:

Public Member Functions

 ilTestExport (&$a_test_obj, $a_mode="xml")
 Constructor public.
 getExtension ()
 getInstId ()
 buildExportFile ()
 build export file (complete zip file)
 buildExportResultFile ()
 build CSV/Excel export files
 compareQuestionsByOID ($a, $b)
 Compares two questions by their original ID.
 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.
 exportToImsCSV ($deliver=TRUE, $filterby="", $filtertext="", $passedonly=FALSE)
 Exports the evaluation data to the IMSm CSV file format.
 buildExportFileXML ()
 build xml export file
 exportXHTMLMediaObjects ($a_export_dir)
 singleChoiceExport ($adapter=null, $deliver=true, $filterby="", $filtertext="", $passedonly=FALSE)

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.
 aggregatedResultsToCSV ($deliver=TRUE)
 Exports the aggregated results to CSV.

Private Member Functions

 writeQuestionUsageTimes ($adapter)

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
Version
Id:
class.ilTestExport.php 38086 2012-11-08 10:19:19Z wplank

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

Member Function Documentation

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 221 of file class.ilTestExport.php.

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

Referenced by exportToCSV().

{
$data = $this->test_obj->getAggregatedResultsData();
$rows = array();
array_push($rows, array(
$this->lng->txt("result"),
$this->lng->txt("value")
));
foreach ($data["overview"] as $key => $value)
{
array_push($rows, array(
$key,
$value
));
}
array_push($rows, array(
$this->lng->txt("question_title"),
$this->lng->txt("average_reached_points"),
$this->lng->txt("points"),
$this->lng->txt("percentage"),
$this->lng->txt("number_of_answers")
));
foreach ($data["questions"] as $key => $value)
{
array_push($rows, array(
$value[0],
$value[4],
$value[5],
$value[6],
$value[3]
));
}
$csv = "";
$separator = ";";
foreach ($rows as $evalrow)
{
$csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE, $separator);
$csv .= join($csvrow, $separator) . "\n";
}
if ($deliver)
{
ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "-aggregated.csv"));
}
else
{
return $csv;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 165 of file class.ilTestExport.php.

References $data, $row, CELL_FORMAT_PERCENT, CELL_FORMAT_TITLE, ilExcelUtils\ExcelAdapter(), exit, and ilUtil\getASCIIFilename().

Referenced by exportToExcel().

{
$data = $this->test_obj->getAggregatedResultsData();
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$outputfilename = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->test_obj->getTitle())) . "-aggregated." . $adapter->getFileExtension();
$adapter->setWorksheetTitle($this->lng->txt("tst_results_aggregated"));
$additionalFields = $this->test_obj->getEvaluationAdditionalFields();
$row = 0;
$col = 0;
$adapter->setCellValue($row, $col++, $this->lng->txt("result"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("value"), CELL_FORMAT_TITLE);
$row++;
foreach ($data["overview"] as $key => $value)
{
$col = 0;
$adapter->setCellValue($row, $col++, $key);
$adapter->setCellValue($row, $col++, $value);
$row++;
}
$row++;
$col = 0;
$adapter->setCellValue($row, $col++, $this->lng->txt("question_id"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("question_title"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("average_reached_points"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("points"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("percentage"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("number_of_answers"), CELL_FORMAT_TITLE);
$row++;
foreach ($data["questions"] as $key => $value)
{
$col = 0;
$adapter->setCellValue($row, $col++, $key);
$adapter->setCellValue($row, $col++, $value[0]);
$adapter->setCellValue($row, $col++, $value[4]);
$adapter->setCellValue($row, $col++, $value[5]);
$adapter->setCellValue($row, $col++, $value[6], CELL_FORMAT_PERCENT);
$adapter->setCellValue($row, $col++, $value[3]);
$row++;
}
if ($deliver)
{
$adapter->deliver($outputfilename);
}
else
{
return $adapter->save();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestExport::buildExportFile ( )

build export file (complete zip file)

public

Returns

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

References buildExportFileXML(), and buildExportResultFile().

{
switch ($this->mode)
{
case "results":
return $this->buildExportResultFile();
break;
default:
return $this->buildExportFileXML();
break;
}
}

+ Here is the call graph for this function:

ilTestExport::buildExportFileXML ( )

build xml export file

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

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

Referenced by buildExportFile().

{
global $ilBench;
$ilBench->start("TestExport", "buildExportFile");
include_once("./Services/Xml/classes/class.ilXmlWriter.php");
$this->xml = new ilXmlWriter;
// set dtd definition
$this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
// set generated comment
$this->xml->xmlSetGenCmt("Export of ILIAS Test ".
$this->test_obj->getId()." of installation ".$this->inst.".");
// set xml header
$this->xml->xmlHeader();
// create directories
$this->test_obj->createExportDirectory();
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::makeDir($this->export_dir."/".$this->subdir);
ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
// get Log File
$expDir = $this->test_obj->getExportDirectory();
include_once "./Services/Logging/classes/class.ilLog.php";
$expLog = new ilLog($expDir, "export.log");
$expLog->delete();
$expLog->setLogFormat("");
$expLog->write(date("[y-m-d H:i:s] ")."Start Export");
// write qti file
include_once "./Modules/Test/classes/class.ilTestExportQTI.php";
$exportObject = new ilTestExportQTI($this->test_obj);
$qti_file = fopen($this->export_dir."/".$this->subdir."/".$this->qti_filename, "w");
fwrite($qti_file, $exportObject->toXML());
fclose($qti_file);
// get xml content
$ilBench->start("TestExport", "buildExportFile_getXML");
$this->test_obj->exportPagesXML($this->xml, $this->inst_id,
$this->export_dir."/".$this->subdir, $expLog);
$ilBench->stop("TestExport", "buildExportFile_getXML");
// dump xml document to screen (only for debugging reasons)
/*
echo "<PRE>";
echo htmlentities($this->xml->xmlDumpMem($format));
echo "</PRE>";
*/
// dump xml document to file
$ilBench->start("TestExport", "buildExportFile_dumpToFile");
$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
, false);
$ilBench->stop("TestExport", "buildExportFile_dumpToFile");
// dump results xml document to file
include_once "./Modules/Test/classes/class.ilTestResultsToXML.php";
$resultwriter = new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity());
$ilBench->start("TestExport", "buildExportFile_results");
$resultwriter->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->resultsfile, false);
$ilBench->stop("TestExport", "buildExportFile_results");
// add media objects which were added with tiny mce
$ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
$this->exportXHTMLMediaObjects($this->export_dir."/".$this->subdir);
$ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
// zip the file
$ilBench->start("TestExport", "buildExportFile_zipFile");
ilUtil::zip($this->export_dir."/".$this->subdir,
$this->export_dir."/".$this->subdir.".zip");
$ilBench->stop("TestExport", "buildExportFile_zipFile");
// destroy writer object
$this->xml->_XmlWriter;
$expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
$ilBench->stop("TestExport", "buildExportFile");
return $this->export_dir."/".$this->subdir.".zip";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestExport::buildExportResultFile ( )

build CSV/Excel export files

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

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

Referenced by buildExportFile().

{
global $ilBench;
global $log;
//get Log File
$expDir = $this->test_obj->getExportDirectory();
//$expLog = &$log;
$expLog = new ilLog($expDir, "export.log");
$expLog->delete();
$expLog->setLogFormat("");
$expLog->write(date("[y-m-d H:i:s] ")."Start Export Of Results");
// make_directories
$this->test_obj->createExportDirectory();
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::makeDir($this->export_dir);
$data = $this->exportToCSV($deliver = FALSE);
$file = fopen($this->export_dir."/".$this->filename, "w");
fwrite($file, $data);
fclose($file);
$excelfile = $this->exportToExcel($deliver = FALSE);
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
@copy($excelfile, $this->export_dir . "/" . str_replace($this->getExtension(), $adapter->getFileExtension(), $this->filename));
@unlink($excelfile);
// end
$expLog->write(date("[y-m-d H:i:s] ")."Finished Export of Results");
return $this->export_dir."/".$this->filename;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestExport::compareQuestionsByOID (   $a,
  $b 
)

Compares two questions by their original ID.

Compares two questions by their original ID (to be used by usort())

Parameters
array$aLeft side of comparison
array$bRight side of comparison public

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

{
if ($a["id"] == $b["id"]) {
return 0;
}
return ($a["id"] < $b["id"]) ? -1 : 1;
}
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 public

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

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

Referenced by buildExportResultFile().

{
global $ilLog;
if (strcmp($this->mode, "aggregated") == 0) return $this->aggregatedResultsToCSV($deliver);
$rows = array();
$datarow = array();
$col = 1;
if ($this->test_obj->getAnonymity())
{
array_push($datarow, $this->lng->txt("counter"));
$col++;
}
else
{
array_push($datarow, $this->lng->txt("name"));
$col++;
array_push($datarow, $this->lng->txt("login"));
$col++;
}
$additionalFields = $this->test_obj->getEvaluationAdditionalFields();
if (count($additionalFields))
{
foreach ($additionalFields as $fieldname)
{
array_push($datarow, $this->lng->txt($fieldname));
$col++;
}
}
array_push($datarow, $this->lng->txt("tst_stat_result_resultspoints"));
$col++;
array_push($datarow, $this->lng->txt("maximum_points"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_resultsmarks"));
$col++;
if ($this->test_obj->ects_output)
{
array_push($datarow, $this->lng->txt("ects_grade"));
$col++;
}
array_push($datarow, $this->lng->txt("tst_stat_result_qworkedthrough"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_qmax"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_pworkedthrough"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_timeofwork"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_atimeofwork"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_firstvisit"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_lastvisit"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_mark_median"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_rank_participant"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_rank_median"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_total_participants"));
$col++;
array_push($datarow, $this->lng->txt("tst_stat_result_median"));
$col++;
array_push($datarow, $this->lng->txt("scored_pass"));
$col++;
array_push($datarow, $this->lng->txt("pass"));
$col++;
$data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
$headerrow = $datarow;
$counter = 1;
foreach ($data->getParticipants() as $active_id => $userdata)
{
$datarow = $headerrow;
$remove = FALSE;
if ($passedonly)
{
if ($data->getParticipant($active_id)->getPassed() == FALSE)
{
$remove = TRUE;
}
}
if (!$remove)
{
$datarow2 = array();
if ($this->test_obj->getAnonymity())
{
array_push($datarow2, $counter);
}
else
{
array_push($datarow2, $data->getParticipant($active_id)->getName());
array_push($datarow2, $data->getParticipant($active_id)->getLogin());
}
if (count($additionalFields))
{
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "gender") == 0)
{
array_push($datarow2, $this->lng->txt("gender_" . $userfields[$fieldname]));
}
else
{
array_push($datarow2, $userfields[$fieldname]);
}
}
}
array_push($datarow2, $data->getParticipant($active_id)->getReached());
array_push($datarow2, $data->getParticipant($active_id)->getMaxpoints());
array_push($datarow2, $data->getParticipant($active_id)->getMark());
if ($this->test_obj->ects_output)
{
array_push($datarow2, $data->getParticipant($active_id)->getECTSMark());
}
array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThrough());
array_push($datarow2, $data->getParticipant($active_id)->getNumberOfQuestions());
array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0);
$time = $data->getParticipant($active_id)->getTimeOfWork();
$time_seconds = $time;
$time_hours = floor($time_seconds/3600);
$time_seconds -= $time_hours * 3600;
$time_minutes = floor($time_seconds/60);
$time_seconds -= $time_minutes * 60;
array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
$time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
$time_seconds = $time;
$time_hours = floor($time_seconds/3600);
$time_seconds -= $time_hours * 3600;
$time_minutes = floor($time_seconds/60);
$time_seconds -= $time_minutes * 60;
array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
$fv = getdate($data->getParticipant($active_id)->getFirstVisit());
$firstvisit = ilUtil::excelTime(
$fv["year"],
$fv["mon"],
$fv["mday"],
$fv["hours"],
$fv["minutes"],
$fv["seconds"]
);
array_push($datarow2, $firstvisit);
$lv = getdate($data->getParticipant($active_id)->getLastVisit());
$lastvisit = ilUtil::excelTime(
$lv["year"],
$lv["mon"],
$lv["mday"],
$lv["hours"],
$lv["minutes"],
$lv["seconds"]
);
array_push($datarow2, $lastvisit);
$median = $data->getStatistics()->getStatistics()->median();
$pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
$mark = $this->test_obj->mark_schema->getMatchingMark($pct);
$mark_short_name = "";
if (is_object($mark))
{
$mark_short_name = $mark->getShortName();
}
array_push($datarow2, $mark_short_name);
array_push($datarow2, $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
array_push($datarow2, $data->getStatistics()->getStatistics()->rank_median());
array_push($datarow2, $data->getStatistics()->getStatistics()->count());
array_push($datarow2, $median);
if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS)
{
array_push($datarow2, $data->getParticipant($active_id)->getBestPass() + 1);
}
else
{
array_push($datarow2, $data->getParticipant($active_id)->getLastPass() + 1);
}
for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
{
$finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
if ($finishdate > 0)
{
if ($pass > 0)
{
for ($i = 1; $i < $col-1; $i++)
{
array_push($datarow2, "");
array_push($datarow, "");
}
array_push($datarow, "");
}
array_push($datarow2, $pass+1);
if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass)))
{
$questions = $data->getParticipant($active_id)->getQuestions($pass);
if (!$this->test_obj->getExportSettingsRespectShuffle())
{
usort($questions, array(&$this, "compareQuestionsByOID"));
}
foreach ($questions as $question)
{
$question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
array_push($datarow2, $question_data["reached"]);
array_push($datarow, preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"])));
}
}
if ((($this->test_obj->isRandomTest()
|| $this->test_obj->getShuffleQuestions())
&& $this->test_obj->getExportSettingsRespectShuffle())
|| ($counter == 1 && $pass == 0))
{
array_push($rows, $datarow);
}
$datarow = array();
array_push($rows, $datarow2);
$datarow2 = array();
}
}
$counter++;
}
}
$csv = "";
$separator = ";";
foreach ($rows as $evalrow)
{
$csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE, $separator);
$csv .= join($csvrow, $separator) . "\n";
}
if ($deliver)
{
ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "-detailed.csv"));
}
else
{
return $csv;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Exports the evaluation data to the Microsoft Excel file format.

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

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

References $data, $ilLog, $pass, $pos, $row, $title, ilExcelUtils\_convert_text(), assSingleChoice\_getAnswerTexts(), assQuestion\_getSolutionValues(), ilObjUser\_lookupFields(), aggregatedResultsToExcel(), CELL_FORMAT_BOLD, CELL_FORMAT_DATETIME, CELL_FORMAT_PERCENT, CELL_FORMAT_TITLE, ilExcelUtils\ExcelAdapter(), ilUtil\excelTime(), exit, ilUtil\getASCIIFilename(), SCORE_BEST_PASS, and writeQuestionUsageTimes().

Referenced by buildExportResultFile().

{
global $ilLog;
if (strcmp($this->mode, "aggregated") == 0) return $this->aggregatedResultsToExcel($deliver);
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$outputfilename = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->test_obj->getTitle())) . "-detailed." . $adapter->getFileExtension();
$adapter->setWorksheetTitle($this->lng->txt("tst_results"));
$additionalFields = $this->test_obj->getEvaluationAdditionalFields();
$row = 0;
$col = 0;
if ($this->test_obj->getAnonymity())
{
$adapter->setCellValue($row, $col++, $this->lng->txt("counter"), CELL_FORMAT_TITLE);
}
else
{
$adapter->setCellValue($row, $col++, $this->lng->txt("name"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("login"), CELL_FORMAT_TITLE);
}
if (count($additionalFields))
{
foreach ($additionalFields as $fieldname)
{
$adapter->setCellValue($row, $col++, $this->lng->txt($fieldname), CELL_FORMAT_TITLE);
}
}
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_resultspoints"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("maximum_points"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_resultsmarks"), CELL_FORMAT_TITLE);
if ($this->test_obj->ects_output)
{
$adapter->setCellValue($row, $col++, $this->lng->txt("ects_grade"), CELL_FORMAT_TITLE);
}
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_qworkedthrough"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_qmax"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_pworkedthrough"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_timeofwork"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_atimeofwork"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_firstvisit"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_lastvisit"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_mark_median"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_rank_participant"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_rank_median"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_total_participants"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("tst_stat_result_median"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("scored_pass"), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt("pass"), CELL_FORMAT_TITLE);
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$counter = 1;
include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
include_once "./Modules/Test/classes/class.ilTestEvaluationPassData.php";
include_once "./Modules/Test/classes/class.ilTestEvaluationUserData.php";
unset($this->test_obj->ilias);
unset($this->test_obj->lng);
$data = new ilTestEvaluationData($this->test_obj);
$data->calculateStatistics();
$data->setFilter($filterby, $filtertext);
// $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
$firstrowwritten = false;
$ilLog->write("Export Test Results");
foreach ($data->getParticipants() as $active_id => $userdata)
{
$data->getCompleteDataForParticipant($active_id); // do this by participant, otherwise memory usage is horrible for large tests and participants
$remove = FALSE;
if ($passedonly)
{
if ($data->getParticipant($active_id)->getPassed() == FALSE)
{
$remove = TRUE;
}
}
if (!$remove)
{
$row++;
if (($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) && $this->test_obj->getExportSettingsRespectShuffle())
{
$row++;
}
$col = 0;
if ($this->test_obj->getAnonymity())
{
$adapter->setCellValue($row, $col++, $counter);
}
else
{
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getName());
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getLogin());
}
//$ilLog->write($row . ". " . $data->getParticipant($active_id)->getName());
if (count($additionalFields))
{
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "gender") == 0)
{
$adapter->setCellValue($row, $col++, $this->lng->txt("gender_" . $userfields[$fieldname]));
}
else
{
$adapter->setCellValue($row, $col++, $userfields[$fieldname]);
}
}
}
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getReached());
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getMaxpoints());
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getMark());
if ($this->test_obj->ects_output)
{
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getECTSMark());
}
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getQuestionsWorkedThrough());
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getNumberOfQuestions());
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0, CELL_FORMAT_PERCENT);
$time = $data->getParticipant($active_id)->getTimeOfWork();
$time_seconds = $time;
$time_hours = floor($time_seconds/3600);
$time_seconds -= $time_hours * 3600;
$time_minutes = floor($time_seconds/60);
$time_seconds -= $time_minutes * 60;
$adapter->setCellValue($row, $col++, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
$time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
$time_seconds = $time;
$time_hours = floor($time_seconds/3600);
$time_seconds -= $time_hours * 3600;
$time_minutes = floor($time_seconds/60);
$time_seconds -= $time_minutes * 60;
$adapter->setCellValue($row, $col++, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
$fv = getdate($data->getParticipant($active_id)->getFirstVisit());
$firstvisit = ilUtil::excelTime(
$fv["year"],
$fv["mon"],
$fv["mday"],
$fv["hours"],
$fv["minutes"],
$fv["seconds"]
);
$adapter->setCellValue($row, $col++, $firstvisit, CELL_FORMAT_DATETIME);
$lv = getdate($data->getParticipant($active_id)->getLastVisit());
$lastvisit = ilUtil::excelTime(
$lv["year"],
$lv["mon"],
$lv["mday"],
$lv["hours"],
$lv["minutes"],
$lv["seconds"]
);
$adapter->setCellValue($row, $col++, $lastvisit, CELL_FORMAT_DATETIME);
$median = $data->getStatistics()->getStatistics()->median();
$pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
$mark = $this->test_obj->mark_schema->getMatchingMark($pct);
$mark_short_name = "";
if (is_object($mark))
{
$mark_short_name = $mark->getShortName();
}
$adapter->setCellValue($row, $col++, $mark_short_name);
$adapter->setCellValue($row, $col++, $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
$adapter->setCellValue($row, $col++, $data->getStatistics()->getStatistics()->rank_median());
$adapter->setCellValue($row, $col++, $data->getStatistics()->getStatistics()->count());
$adapter->setCellValue($row, $col++, $median);
if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS)
{
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getBestPass() + 1);
}
else
{
$adapter->setCellValue($row, $col++, $data->getParticipant($active_id)->getLastPass() + 1);
}
$startcol = $col;
$maxcol = $col;
for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
{
$col = $startcol;
$finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
if ($finishdate > 0)
{
if ($pass > 0)
{
$row++;
if (($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) && $this->test_obj->getExportSettingsRespectShuffle())
{
$row++;
}
}
$adapter->setCellValue($row, $col++, $pass+1);
if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass)))
{
$questions = $data->getParticipant($active_id)->getQuestions($pass);
if (!$this->test_obj->getExportSettingsRespectShuffle())
{
usort($questions, array(&$this, "compareQuestionsByOID"));
}
foreach ($questions as $question)
{
$question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
$adapter->setCellValue($row, $col, $question_data["reached"]);
if (($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) && $this->test_obj->getExportSettingsRespectShuffle())
{
$adapter->setCellValue($row-1, $col, preg_replace("/<.*?>/", "", "[" . $question["id"] . "] " . $data->getQuestionTitle($question["id"])), CELL_FORMAT_TITLE);
}
else
{
if ($pass == 0 && !$firstrowwritten)
{
$adapter->setCellValue(0, $col, preg_replace("/<.*?>/", "", "[" . $question["id"] . "] " . $data->getQuestionTitle($question["id"])), CELL_FORMAT_TITLE);
}
}
$col++;
}
$firstrowwritten = true;
}
}
if ($col > $maxcol) $maxcol = $col;
}
$counter++;
}
$data->getParticipant($active_id)->unsetPasses();
$data->getParticipant($active_id)->unsetQuestions();
}
for ($colnr = 0; $colnr <= $maxcol; $colnr++)
{
$adapter->setColumnWidth($colnr, 'auto');
}
if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions())
{
unset($data);
$data = new ilTestEvaluationData($this->test_obj);
$data->calculateStatistics();
$data->setFilter($filterby, $filtertext);
$ilLog->write("Export Single Choice Results");
// special tab for single choice tests
$titles =& $this->test_obj->getQuestionTitlesAndIndexes();
$positions = array();
$pos = 0;
$row = 0;
foreach ($titles as $id => $title)
{
$positions[$id] = $pos;
$pos++;
}
$usernames = array();
$participantcount = count($data->getParticipants());
$allusersheet = false;
$pages = 0;
$adapter->addWorksheet($this->lng->txt("export_result_overview"));
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
$col = 0;
$adapter->setCellValue($row, $col++, $this->lng->txt('name'), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt('login'), CELL_FORMAT_TITLE);
if (count($additionalFields))
{
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
$adapter->setCellValue($row, $col++, $this->lng->txt('matriculation'), CELL_FORMAT_TITLE);
}
}
}
$adapter->setCellValue($row, $col++, $this->lng->txt('test'), CELL_FORMAT_TITLE);
foreach ($titles as $aid => $title)
{
$adapter->setCellValue($row, $col+$positions[$aid], "[". $aid . "] " . $title, CELL_FORMAT_TITLE);
}
$row++;
$maxcol = $col;
foreach ($data->getParticipants() as $active_id => $userdata)
{
$data->getCompleteDataForParticipant($active_id); // do this by participant, otherwise memory usage is horrible for large tests and participants
$username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
if (array_key_exists($username, $usernames))
{
$usernames[$username]++;
$username .= " ($i)";
}
else
{
$usernames[$username] = 1;
}
$col = 0;
//$ilLog->write($row . ". " . $data->getParticipant($active_id)->getName());
$adapter->setCellValue($row, $col++, $username);
$adapter->setCellValue($row, $col++, $userdata->getLogin());
if (count($additionalFields))
{
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
if (strlen($userfields[$fieldname]))
{
$adapter->setCellValue($row, $col++, $userfields[$fieldname]);
}
else
{
$col++;
}
}
}
}
$adapter->setCellValue($row, $col++, $this->test_obj->getTitle());
$pass = $userdata->getScoredPass();
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
include_once "./Modules/TestQuestionPool/classes/class.assSingleChoice.php";
if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
{
foreach ($userdata->getQuestions($pass) as $question)
{
$solution = assQuestion::_getSolutionValues($active_id, $question["id"], $pass);
$answers = assSingleChoice::_getAnswerTexts($question["id"]);
$pos = $positions[$question["id"]];
$selectedanswer = "x";
foreach ($answers as $id => $answer)
{
if (strlen($solution[0]["value1"]) && $id == $solution[0]["value1"])
{
$selectedanswer = $answer;
break;
}
}
$adapter->setCellValue($row, $col+$pos, $selectedanswer);
if ($col+$pos > $maxcol) $maxcol = $col+$pos;
}
}
$row++;
$data->getParticipant($active_id)->unsetPasses();
$data->getParticipant($active_id)->unsetQuestions();
}
for ($colnr = 0; $colnr <= $maxcol; $colnr++)
{
$adapter->setColumnWidth($colnr, 'auto');
}
if ($this->test_obj->isSingleChoiceTestWithoutShuffle())
{
unset($data);
$ilLog->write("Export Compact Single Choice Results");
$data = new ilTestEvaluationData($this->test_obj);
$data->calculateStatistics();
$data->setFilter($filterby, $filtertext);
// special tab for single choice tests without shuffle option
$pos = 0;
$row = 0;
$usernames = array();
$allusersheet = false;
$pages = 0;
$adapter->addWorksheet($this->lng->txt("export_result_overview") . " (2)");
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
$col = 0;
$adapter->setCellValue($row, $col++, $this->lng->txt('name'), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt('login'), CELL_FORMAT_TITLE);
if (count($additionalFields))
{
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
$adapter->setCellValue($row, $col++, $this->lng->txt('matriculation'), CELL_FORMAT_TITLE);
}
}
}
$adapter->setCellValue($row, $col++, $this->lng->txt('test'), CELL_FORMAT_TITLE);
foreach ($titles as $aid => $title)
{ // M.W.
$adapter->setCellValue($row, $col+$positions[$aid], "[". $aid . "] " . $title, CELL_FORMAT_TITLE);
}
$row++;
$maxcol = $col;
foreach ($data->getParticipants() as $active_id => $userdata)
{
$data->getCompleteDataForParticipant($active_id); // do this by participant, otherwise memory usage is horrible for large tests and participants
$username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
if (array_key_exists($username, $usernames))
{
$usernames[$username]++;
$username .= " ($i)";
}
else
{
$usernames[$username] = 1;
}
$col = 0;
//$ilLog->write($row . ". " . $data->getParticipant($active_id)->getName());
$adapter->setCellValue($row, $col++, $username);
$adapter->setCellValue($row, $col++, $userdata->getLogin());
if (count($additionalFields))
{
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
if (strlen($userfields[$fieldname]))
{
$adapter->setCellValue($row, $col++, $userfields[$fieldname]);
}
else
{
$col++;
}
}
}
}
$adapter->setCellValue($row, $col++, $this->test_obj->getTitle());
$pass = $userdata->getScoredPass();
if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
{
foreach ($userdata->getQuestions($pass) as $question)
{
$solution = assQuestion::_getSolutionValues($active_id, $question["id"], $pass);
$pos = $positions[$question["id"]];
if (strlen($solution[0]["value1"]))
{
$selectedanswer = chr(65+$solution[0]["value1"]);
}
else
{
$selectedanswer = 'x';
}
$adapter->setCellValue($row, $col+$pos, $selectedanswer);
if ($col+$pos > $maxcol) $maxcol = $col+$pos;
}
}
$row++;
$data->getParticipant($active_id)->unsetPasses();
$data->getParticipant($active_id)->unsetQuestions();
}
for ($colnr = 0; $colnr <= $maxcol; $colnr++)
{
$adapter->setColumnWidth($colnr, 'auto');
}
}
}
$ilLog->write("Test participant result export");
unset($data);
$data = new ilTestEvaluationData($this->test_obj);
$data->calculateStatistics();
$data->setFilter($filterby, $filtertext);
$row = 0;
// test participant result export
$usernames = array();
$participantcount = count($data->getParticipants());
$allusersheet = false;
$pages = 0;
$pcounter = 1;
foreach ($data->getParticipants() as $active_id => $userdata)
{
$data->getCompleteDataForParticipant($active_id); // do this by participant, otherwise memory usage is horrible for large tests and participants
$username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
if (array_key_exists($username, $usernames))
{
$i=$usernames[$username]++;
$username .= " ($i)";
}
else
{
$usernames[$username] = 1;
}
//$ilLog->write($pcounter++ . ". " . $data->getParticipant($active_id)->getName());
if (strcmp($adapter->getFileExtension(), 'xls') == 0)
{
if ($participantcount > 250)
{
if (!$allusersheet || ($pages-1) < floor($row / 64000))
{
$adapter->addWorksheet($this->lng->txt("export_result_overview") . (($pages > 0) ? " (".($pages+1).")" : ""));
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
$allusersheet = true;
$row = 0;
$pages++;
}
}
else
{
$adapter->addWorksheet($username);
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
}
}
else
{
$adapter->addWorksheet($username);
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
}
$pass = $userdata->getScoredPass();
$row = ($allusersheet) ? $row : 0;
$adapter->setCellValue($row, 0, sprintf($this->lng->txt("tst_result_user_name_pass"), $pass+1, $userdata->getName()), CELL_FORMAT_BOLD);
$row += 2;
if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
{
foreach ($userdata->getQuestions($pass) as $question)
{
$question =& $this->test_obj->_instanciateQuestion($question["id"]);
if (is_object($question))
{
$row = $question->setExportDetailsXLS($adapter, $row, $active_id, $pass);
}
}
}
$data->getParticipant($active_id)->unsetPasses();
$data->getParticipant($active_id)->unsetQuestions();
}
unset($data);
$this->writeQuestionUsageTimes($adapter);
if ($deliver)
{
$adapter->deliver($outputfilename);
}
else
{
return $adapter->save($outputfilename);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Exports the evaluation data to the IMSm CSV file format.

This format considers the original IMSm (Heidelberg) Question ID's

IMSm specific export - http://www.ims-m.org, http://www.medizinische-fakultaet-hd.uni-heidelberg.de/Computergestuetzte-Pruefungen.100385.0.html To be used with IMS-m/Examinator - File Format v1

TODO: Prevent export if shuffled answers mode in SC, MC is activated (this is not the case in the normal IMS-m scenario)

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

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

References $data, $ilLog, $pass, $pos, $row, $separator, $title, ilExcelUtils\_convert_text(), ilUtil\deliverData(), exit, and ilUtil\getASCIIFilename().

{
global $ilLog;
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
$titles =& $this->test_obj->getQuestionTitlesAndIndexes();
$oids =& $this->test_obj->getQuestions();//$this->test_obj->getQuestionOIDsByAID();
asort($oids);
$positions = array();
$pos = 0;
$row = 0;
foreach ($oids as $aid => $oid)
{
$positions[$oid] = $pos;
$pos++;
}
$usernames = array();
$participantcount = count($data->getParticipants());
// fill csv header
$a_csv_header_row=array();
$col = 0;
$a_csv_header_row[$col++]=ilExcelUtils::_convert_text('last_name');
$a_csv_header_row[$col++]=ilExcelUtils::_convert_text('first_name');
$a_csv_header_row[$col++]=ilExcelUtils::_convert_text('Matrikel');
$a_csv_header_row[$col++]=ilExcelUtils::_convert_text('user');
//$a_csv_header_row[$col++]=ilExcelUtils::_convert_text($this->lng->txt('test'));
foreach ($titles as $aid => $title)
{
$question=$this->test_obj->_instanciateQuestion($aid);
$imsm_id=$question->getExternalID();
$a_csv_header_row[$col+$positions[$aid]]=ilExcelUtils::_convert_text($imsm_id);
}
$a_csv_header_row[count($a_csv_header_row)]=ilExcelUtils::_convert_text('time');
// fill csv body
$a_csv_data_rows=array();
$a_csv_data_rows[$row++]=$a_csv_header_row;
foreach ($data->getParticipants() as $active_id => $userdata)
{
$a_csv_row=array();
$col = 0;
/*$tmp_obj = ilObjectFactory::getInstanceByObjId($userdata->user_id);
$a_csv_row[$col++]=$tmp_obj->getLastName();
$a_csv_row[$col++]=$tmp_obj->getFirstName();
$a_csv_row[$col++]=$tmp_obj->getMatriculation();
$a_csv_row[$col++]=$userdata->getLogin();
*/
$anon_id=$row;
$a_csv_row[$col++]="lastname_".$anon_id;
$a_csv_row[$col++]="firstname_".$anon_id;
$a_csv_row[$col++]="1111".$anon_id;
$a_csv_row[$col++]="id_".$anon_id;
//$a_csv_row[$col++]=ilExcelUtils::_convert_text($this->test_obj->getTitle());
$pass = $userdata->getScoredPass();
if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
{
foreach ($userdata->getQuestions($pass) as $question)
{
$objQuestion =& $this->test_obj->_instanciateQuestion($question["id"]);
$is_sc=strcmp($objQuestion->getQuestionType(), 'assSingleChoice')==0;
$is_mc=strcmp($objQuestion->getQuestionType(), 'assMultipleChoice')==0;
if (is_object($objQuestion) && ($is_sc || $is_mc))
{
$solutions = $objQuestion->getSolutionValues($active_id, $pass);
$answers=array();
for ($i=0;$i<count($solutions);$i++){
$selectedanswer = chr(65+$solutions[$i]["value1"]);
array_push($answers,$selectedanswer);
}
sort($answers);
$pos = $positions[$question["id"]];
$a_csv_row[$col+$pos]=implode($answers,",");
}
}
}
$lv = getdate($data->getParticipant($active_id)->getLastVisit());
$tstamp=mktime($lv['hours'],$lv['minutes'],$lv['seconds'],$lv['mon'],$lv['mday'],$lv['year']);
$lastvisit = date("d.m.Y G:i:s",$tstamp);
$a_csv_row[count($a_csv_row)]=$lastvisit;
ksort($a_csv_row);
$a_csv_data_rows[$row]=$a_csv_row;
$row++;
}
// write to file
$csv = "";
$separator = ";";
foreach ($a_csv_data_rows as $evalrow)
{
$csvrow =& $this->test_obj->processCSVRow($evalrow, FALSE, $separator);
$csv .= join($csvrow, $separator) . "\n";
}
if ($deliver)
{
ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "-detailed.csv"));
}
else
{
return $csv;
}
}

+ Here is the call graph for this function:

ilTestExport::exportXHTMLMediaObjects (   $a_export_dir)

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

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

Referenced by buildExportFileXML().

{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->test_obj->getId());
foreach ($mobs as $mob)
{
{
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->exportFiles($a_export_dir);
unset($mob_obj);
}
}
foreach ($this->test_obj->questions as $question_id)
{
$mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
foreach ($mobs as $mob)
{
{
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->exportFiles($a_export_dir);
unset($mob_obj);
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestExport::getExtension ( )

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

Referenced by buildExportResultFile(), and ilTestExport().

{
switch ($this->mode) {
case "results":
return "csv"; break;
default:
return "xml"; break;
}
}

+ Here is the caller graph for this function:

ilTestExport::getInstId ( )

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

References $inst_id.

{
}
ilTestExport::ilTestExport ( $a_test_obj,
  $a_mode = "xml" 
)

Constructor public.

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

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

{
global $ilErr, $ilDB, $ilias, $lng;
$this->test_obj =& $a_test_obj;
$this->err =& $ilErr;
$this->ilias =& $ilias;
$this->db =& $ilDB;
$this->mode = $a_mode;
$this->lng =& $lng;
$settings = $this->ilias->getAllSettings();
$this->inst_id = IL_INST_ID;
$date = time();
$this->export_dir = $this->test_obj->getExportDirectory();
switch($this->mode)
{
case "results":
$this->subdir = $date."__".$this->inst_id."__".
"test__results__".$this->test_obj->getId();
break;
case "aggregated":
$this->subdir = $date."__".$this->inst_id."__".
"test__aggregated__results__".$this->test_obj->getId();
break;
default:
$this->subdir = $date."__".$this->inst_id."__".
"test"."__".$this->test_obj->getId();
$this->filename = $this->subdir.".xml";
$this->resultsfile = $date."__".$this->inst_id."__".
"results"."__".$this->test_obj->getId().".xml";
$this->qti_filename = $date."__".$this->inst_id."__".
"qti"."__".$this->test_obj->getId().".xml";
break;
}
$this->filename = $this->subdir.".".$this->getExtension();
}

+ Here is the call graph for this function:

ilTestExport::singleChoiceExport (   $adapter = null,
  $deliver = true,
  $filterby = "",
  $filtertext = "",
  $passedonly = FALSE 
)

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

References $data, $ilLog, $pass, $pos, $row, $title, ilExcelUtils\_convert_text(), assSingleChoice\_getAnswerTexts(), assQuestion\_getSolutionValues(), ilObjUser\_lookupFields(), CELL_FORMAT_TITLE, ilExcelUtils\ExcelAdapter(), exit, and ilUtil\getASCIIFilename().

{
global $ilLog;
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
if ($adapter == null)
{
$adapter->setWorksheetTitle($this->lng->txt("export_result_overview"));
}
else
{
$adapter->addWorksheet($this->lng->txt("export_result_overview"));
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
}
include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
$data = new ilTestEvaluationData($this->test_obj);
$data->calculateStatistics();
$data->setFilter($filterby, $filtertext);
$ilLog->write("Export Single Choice Results");
// special tab for single choice tests
$titles =& $this->test_obj->getQuestionTitlesAndIndexes();
$positions = array();
$pos = 0;
$row = 0;
foreach ($titles as $id => $title)
{
$positions[$id] = $pos;
$pos++;
}
$usernames = array();
$participantcount = count($data->getParticipants());
$allusersheet = false;
$pages = 0;
$col = 0;
$adapter->setCellValue($row, $col++, $this->lng->txt('name'), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt('login'), CELL_FORMAT_TITLE);
if (count($additionalFields))
{
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
$adapter->setCellValue($row, $col++, $this->lng->txt('matriculation'), CELL_FORMAT_TITLE);
}
}
}
$adapter->setCellValue($row, $col++, $this->lng->txt('test'), CELL_FORMAT_TITLE);
foreach ($titles as $aid => $title)
{
$adapter->setCellValue($row, $col+$positions[$aid], "[". $aid . "] " . $title, CELL_FORMAT_TITLE);
}
$row++;
$maxcol = $col;
$rangefrom = 1;
$rangeto = $participantcount;
$rangecounter = 1;
foreach ($data->getParticipants() as $active_id => $userdata)
{
if ($rangecounter >= $rangefrom && $rangecounter <= $rangeto)
{
$data->getCompleteDataForParticipant($active_id); // do this by participant, otherwise memory usage is horrible for large tests and participants
$username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
if (array_key_exists($username, $usernames))
{
$usernames[$username]++;
$username .= " ($i)";
}
else
{
$usernames[$username] = 1;
}
$col = 0;
//$ilLog->write($row . ". " . $data->getParticipant($active_id)->getName());
$adapter->setCellValue($row, $col++, $username);
$adapter->setCellValue($row, $col++, $userdata->getLogin());
if (count($additionalFields))
{
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
if (strlen($userfields[$fieldname]))
{
$adapter->setCellValue($row, $col++, $userfields[$fieldname]);
}
else
{
$col++;
}
}
}
}
$adapter->setCellValue($row, $col++, $this->test_obj->getTitle());
$pass = $userdata->getScoredPass();
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
include_once "./Modules/TestQuestionPool/classes/class.assSingleChoice.php";
if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
{
foreach ($userdata->getQuestions($pass) as $question)
{
$solution = assQuestion::_getSolutionValues($active_id, $question["id"], $pass);
$answers = assSingleChoice::_getAnswerTexts($question["id"]);
$pos = $positions[$question["id"]];
$selectedanswer = "x";
foreach ($answers as $id => $answer)
{
if (strlen($solution[0]["value1"]) && $id == $solution[0]["value1"])
{
$selectedanswer = $answer;
break;
}
}
$adapter->setCellValue($row, $col+$pos, $selectedanswer);
if ($col+$pos > $maxcol) $maxcol = $col+$pos;
}
}
$row++;
$data->getParticipant($active_id)->unsetPasses();
$data->getParticipant($active_id)->unsetQuestions();
}
$rangecounter++;
}
for ($colnr = 0; $colnr <= $maxcol; $colnr++)
{
$adapter->setColumnWidth($colnr, 'auto');
}
if ($this->test_obj->isSingleChoiceTestWithoutShuffle())
{
$ilLog->write("Export Compact Single Choice Results");
$data = new ilTestEvaluationData($this->test_obj);
// special tab for single choice tests without shuffle option
$pos = 0;
$row = 0;
$usernames = array();
$allusersheet = false;
$pages = 0;
$adapter->addWorksheet($this->lng->txt("export_result_overview") . " (2)");
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
$col = 0;
$adapter->setCellValue($row, $col++, $this->lng->txt('name'), CELL_FORMAT_TITLE);
$adapter->setCellValue($row, $col++, $this->lng->txt('login'), CELL_FORMAT_TITLE);
if (count($additionalFields))
{
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
$adapter->setCellValue($row, $col++, $this->lng->txt('matriculation'), CELL_FORMAT_TITLE);
}
}
}
$adapter->setCellValue($row, $col++, $this->lng->txt('test'), CELL_FORMAT_TITLE);
foreach ($titles as $aid => $title)
{ // M.W.
$adapter->setCellValue($row, $col+$positions[$aid], "[". $aid . "] " . $title, CELL_FORMAT_TITLE);
}
$row++;
$maxcol = $col;
$rangecounter = 1;
foreach ($data->getParticipants() as $active_id => $userdata)
{
if ($rangecounter >= $rangefrom && $rangecounter <= $rangeto)
{
$data->getCompleteDataForParticipant($active_id); // do this by participant, otherwise memory usage is horrible for large tests and participants
$username = (!is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName())) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID $active_id";
if (array_key_exists($username, $usernames))
{
$usernames[$username]++;
$username .= " ($i)";
}
else
{
$usernames[$username] = 1;
}
$col = 0;
//$ilLog->write($row . ". " . $data->getParticipant($active_id)->getName());
$adapter->setCellValue($row, $col++, $username);
$adapter->setCellValue($row, $col++, $userdata->getLogin());
if (count($additionalFields))
{
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname)
{
if (strcmp($fieldname, "matriculation") == 0)
{
if (strlen($userfields[$fieldname]))
{
$adapter->setCellValue($row, $col++, $userfields[$fieldname]);
}
else
{
$col++;
}
}
}
}
$adapter->setCellValue($row, $col++, $this->test_obj->getTitle());
$pass = $userdata->getScoredPass();
if (is_object($userdata) && is_array($userdata->getQuestions($pass)))
{
foreach ($userdata->getQuestions($pass) as $question)
{
$solution = assQuestion::_getSolutionValues($active_id, $question["id"], $pass);
$pos = $positions[$question["id"]];
if (strlen($solution[0]["value1"]))
{
$selectedanswer = chr(65+$solution[0]["value1"]);
}
else
{
$selectedanswer = 'x';
}
$adapter->setCellValue($row, $col+$pos, $selectedanswer);
if ($col+$pos > $maxcol) $maxcol = $col+$pos;
}
}
$row++;
$data->getParticipant($active_id)->unsetPasses();
$data->getParticipant($active_id)->unsetQuestions();
}
$rangecounter++;
}
for ($colnr = 0; $colnr <= $maxcol; $colnr++)
{
$adapter->setColumnWidth($colnr, 'auto');
}
}
if ($deliver)
{
$outputfilename = ilUtil::getASCIIFilename(preg_replace("/\s/", "_", $this->test_obj->getTitle())) . "-singlechoice." . $adapter->getFileExtension();
$adapter->deliver($outputfilename);
}
}

+ Here is the call graph for this function:

ilTestExport::writeQuestionUsageTimes (   $adapter)
private

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

References $ilLog, $pass, $row, ilExcelUtils\_convert_text(), ilTestEvaluationData\_getTimeStatsForTest(), CELL_FORMAT_BOLD, and CELL_FORMAT_TITLE.

Referenced by exportToExcel().

{
global $ilLog;
$ilLog->write("Export Question Time Usage");
$adapter->addWorksheet($this->lng->txt('tst_question_time_usage'));
$adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
$times = ilTestEvaluationData::_getTimeStatsForTest($this->test_obj->getTestId());
$titles =& $this->test_obj->getQuestionTitlesAndIndexes();
$adapter->setCellValue(0, 0, $this->lng->txt('question_title'), CELL_FORMAT_TITLE);
$adapter->setCellValue(0, 1, $this->lng->txt('total_time'), CELL_FORMAT_TITLE);
$row = 1;
foreach ($times as $question_id => $passes)
{
if ($question_id > 0)
{
$totaltime = 0;
$adapter->setCellValue($row, 0, "[" . $question_id . "] " . ilExcelUtils::_convert_text($titles[$question_id]), CELL_FORMAT_BOLD);
$col = 2;
foreach ($passes as $pass => $participants)
{
foreach ($participants as $active_id => $questiontimes)
{
foreach ($questiontimes as $timeInSeconds)
{
$totaltime += $timeInSeconds;
$adapter->setCellValue($row, $col, $timeInSeconds);
$col++;
}
}
}
$adapter->setCellValue($row, 1, $totaltime);
$row++;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilTestExport::$db

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

ilTestExport::$err

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

ilTestExport::$ilias

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

Referenced by ilTestExport().

ilTestExport::$inst_id

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

Referenced by getInstId().

ilTestExport::$lng
private

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

Referenced by ilTestExport().

ilTestExport::$mode

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

ilTestExport::$resultsfile
private

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

ilTestExport::$test_obj

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


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