Skip to content

Commit

Permalink
Merge branch 'release_5-1' of https://github.com/ILIAS-eLearning/ILIAS
Browse files Browse the repository at this point in the history
…into release_5-1
  • Loading branch information
smeyer-ilias committed May 19, 2016
2 parents 425ebed + d8d9986 commit 3990002
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 96 deletions.
19 changes: 19 additions & 0 deletions Modules/Glossary/classes/class.ilGlossaryDataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
*/
class ilGlossaryDataSet extends ilDataSet
{
/**
* @var ilLogger
*/
protected $log;

/**
* Constructor
*/
function __construct()
{
$this->log = ilLoggerFactory::getLogger('glo');
parent::__construct();
}

/**
* Get supported versions
*
Expand Down Expand Up @@ -251,8 +265,13 @@ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version
$term->setGlossaryId($glo_id);
$term->setTerm($a_rec["Term"]);
$term->setLanguage($a_rec["Language"]);
if ($this->getCurrentInstallationId() > 0)
{
$term->setImportId("il_".$this->getCurrentInstallationId()."_git_".$a_rec["Id"]);
}
$term->create();
$term_id = $term->getId();
$this->log->debug("glo_term, import id: ".$term->getImportId().", term id: ".$term_id);

$a_mapping->addMapping("Modules/Glossary", "term",
$a_rec["Id"], $term_id);
Expand Down
3 changes: 2 additions & 1 deletion Modules/Glossary/classes/class.ilGlossaryTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ function _getIdForImportId($a_import_id)
{
$glo_id = ilGlossaryTerm::_lookGlossaryID($term_rec["id"]);

if (ilObject::_hasUntrashedReference($glo_id))
$ref_ids = ilObject::_getAllReferences($glo_id); // will be 0 if import of lm is in progress (new import)
if (count($ref_ids) == 0 || ilObject::_hasUntrashedReference($glo_id))
{
return $term_rec["id"];
}
Expand Down
1 change: 1 addition & 0 deletions Modules/Glossary/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
<copage>
<pageobject parent_type="gdf" class_name="ilGlossaryDefPage" directory="classes"/>
</copage>
<logging />
</module>
7 changes: 0 additions & 7 deletions Modules/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11930,13 +11930,6 @@ public function recalculateScores($preserve_manscoring = false)
$scoring = new ilTestScoring($this);
$scoring->setPreserveManualScores($preserve_manscoring);
$scoring->recalculateSolutions();

if ($this->getEnableArchiving())
{
require_once 'Modules/Test/classes/class.ilTestArchiveService.php';
$archiveService = new ilTestArchiveService($this);
$archiveService->archivePassesByActives($scoring->getRecalculatedPassesByActives());
}
}

public static function getPoolQuestionChangeListeners(ilDB $db, $poolObjId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ private function saveResultDetailsSettings(ilPropertyFormGUI $form)

private function addMiscSettingsFormSection(ilPropertyFormGUI $form)
{
$fields = array('anonymity', 'enable_archiving');
$fields = array('anonymity');

if( $this->isSectionHeaderRequired($fields) || $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
{
Expand Down Expand Up @@ -771,13 +771,6 @@ private function addMiscSettingsFormSection(ilPropertyFormGUI $form)
$form->addItem($results_presentation);
}
}

// enable_archiving
$enable_archiving = new ilCheckboxInputGUI($this->lng->txt('test_enable_archiving'), 'enable_archiving');
$enable_archiving->setInfo($this->lng->txt('test_enable_archiving_desc'));
$enable_archiving->setValue(1);
$enable_archiving->setChecked($this->testOBJ->getEnableArchiving());
$form->addItem($enable_archiving);
}

/**
Expand All @@ -802,21 +795,6 @@ private function saveResultMiscOptionsSettings(ilPropertyFormGUI $form)
$this->testOBJ->setResultFilterTaxIds($taxFilters);
}
}

if( $this->formPropertyExists($form, 'enable_archiving') )
{
// Archiving
if($this->testOBJ->getAnonymity() == true &&
$form->getItemByPostVar('enable_archiving')->getChecked() == true)
{
$this->testOBJ->setEnableArchiving(false);
ilUtil::sendInfo($this->lng->txt('no_archive_on_anonymous'), true);
}
else
{
$this->testOBJ->setEnableArchiving($form->getItemByPostVar('enable_archiving')->getChecked());
}
}
}

private function areScoringSettingsWritable()
Expand Down
7 changes: 0 additions & 7 deletions Modules/Test/classes/class.ilScoringAdjustmentGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,6 @@ protected function saveQuestion()
$scoring->setPreserveManualScores($_POST['preserve_manscoring'] == 1 ? true : false);
$scoring->recalculateSolutions();

if ($this->object->getEnableArchiving())
{
require_once 'Modules/Test/classes/class.ilTestArchiveService.php';
$archiveService = new ilTestArchiveService($this->object);
$archiveService->archivePassesByActives($scoring->getRecalculatedPassesByActives());
}

ilUtil::sendSuccess($this->lng->txt('saved_adjustment'));
$this->questionsObject();

Expand Down
32 changes: 32 additions & 0 deletions Modules/Test/classes/class.ilTestArchiveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,54 @@
*/
class ilTestArchiveService
{
/**
* @var ilObjTest
*/
protected $testOBJ;

/**
* @var ilTestParticipantData
*/
protected $participantData;

/**
* @var bool
*/
protected $considerHiddenQuestionsEnabled;

/**
* @var ilTestResultHeaderLabelBuilder
*/
protected $testResultHeaderLabelBuilder;

public function __construct(ilObjTest $testOBJ)
{
global $ilObjDataCache, $lng;

$this->testOBJ = $testOBJ;
$this->participantData = null;

$this->considerHiddenQuestionsEnabled = true;

require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
$this->testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($lng, $ilObjDataCache);
}

/**
* @return ilTestParticipantData
*/
public function getParticipantData()
{
return $this->participantData;
}

/**
* @param ilTestParticipantData $participantData
*/
public function setParticipantData(ilTestParticipantData $participantData)
{
$this->participantData = $participantData;
}

public function isConsiderHiddenQuestionsEnabled()
{
Expand Down Expand Up @@ -60,6 +91,7 @@ public function archiveActivesPass($activeId, $pass)
ilTestPDFGenerator::generatePDF($content, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);

$archiver = new ilTestArchiver($this->testOBJ->getId());
$archiver->setParticipantData($this->getParticipantData());
$archiver->handInTestResult($activeId, $pass, $filename);

unlink($filename);
Expand Down
90 changes: 79 additions & 11 deletions Modules/Test/classes/class.ilTestArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class ilTestArchiver
protected $archive_data_index; /** @var $archive_data_index array[string[]] Archive data index as associative array */

protected $ilDB; /** @var $ilDB ilDB */

/**
* @var ilTestParticipantData
*/
protected $participantData;

#endregion

Expand All @@ -101,6 +106,24 @@ public function __construct($test_obj_id)
$this->ilDB = $ilias->db;

$this->archive_data_index = $this->readArchiveDataIndex();

$this->participantData = null;
}

/**
* @return ilTestParticipantData
*/
public function getParticipantData()
{
return $this->participantData;
}

/**
* @param ilTestParticipantData $participantData
*/
public function setParticipantData($participantData)
{
$this->participantData = $participantData;
}

#region API methods
Expand Down Expand Up @@ -463,6 +486,20 @@ protected function createPassDataDirectory($active_fi, $pass)
mkdir($this->getPassDataDirectory($active_fi, $pass), 0777, true);
return;
}

private function buildPassDataDirectory($active_fi, $pass)
{
foreach ($this->archive_data_index as $data_index_entry)
{
if ( $data_index_entry != null && $data_index_entry['identifier'] == $active_fi.'|'.$pass )
{
array_shift($data_index_entry);
return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
}
}

return null;
}

/**
* Returns the pass data directory.
Expand All @@ -474,19 +511,34 @@ protected function createPassDataDirectory($active_fi, $pass)
*/
protected function getPassDataDirectory($active_fi, $pass)
{
foreach ($this->archive_data_index as $data_index_entry)
$passDataDir = $this->buildPassDataDirectory($active_fi, $pass);

if( !$passDataDir )
{
if ( $data_index_entry != null && $data_index_entry['identifier'] == $active_fi.'|'.$pass )
if( $this->getParticipantData() )
{
array_shift($data_index_entry);
return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
$usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
$user = new ilObjUser();
$user->setFirstname($usrData['firstname']);
$user->setLastname($usrData['lastname']);
$user->setMatriculation($usrData['matriculation']);
$user->setFirstname($usrData['firstname']);
}
else
{
global $ilUser;
$user = $ilUser;
}

$this->appendToArchiveDataIndex(
date(DATE_ISO8601), $active_fi, $pass,
$user->getFirstname(), $user->getLastname(), $user->getMatriculation()
);

$passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
}
global $ilUser;
$this->appendToArchiveDataIndex(date(DATE_ISO8601), $active_fi, $pass, $ilUser->getFirstname(), $ilUser->getLastname(), $ilUser->getMatriculation());
$data_index_entry = $this->getPassDataDirectory($active_fi, $pass);
@array_shift($data_index_entry);
return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);

return $passDataDir;
}

/**
Expand Down Expand Up @@ -542,9 +594,25 @@ protected function createPassMaterialsDirectory($active_fi, $pass)
{
// Data are taken from the current user as the implementation expects the first interaction of the pass
// takes place from the usage/behaviour of the current user.
global $ilUser;

if( $this->getParticipantData() )
{
$usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
$user = new ilObjUser();
$user->setFirstname($usrData['firstname']);
$user->setLastname($usrData['lastname']);
$user->setMatriculation($usrData['matriculation']);
$user->setFirstname($usrData['firstname']);
}
else
{
global $ilUser;
$user = $ilUser;
}

$this->appendToArchiveDataIndex(date('Y'), $active_fi, $pass, $ilUser->getFirstname(), $ilUser->getLastname(), $ilUser->getMatriculation());
$this->appendToArchiveDataIndex(
date('Y'), $active_fi, $pass, $user->getFirstname(), $user->getLastname(), $user->getMatriculation()
);
mkdir($this->getPassMaterialsDirectory($active_fi, $pass) , 0777, true );
}

Expand Down
62 changes: 62 additions & 0 deletions Modules/Test/classes/class.ilTestEvaluation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */


/**
* @author Björn Heyser <[email protected]>
* @version $Id$
*
* @package Modules/Test
*/
class ilTestEvaluation
{
/**
* @var ilDBInterface
*/
protected $db;

/**
* @var integer
*/
protected $testId;

/**
* @param ilDBInterface $db
*/
public function __construct(ilDBInterface $db, $testId)
{
$this->db = $db;
$this->testId = $testId;
}

/**
* @param $testId
* @return array
*/
public function getAllActivesPasses()
{
$query = "
SELECT active_fi, pass
FROM tst_active actives
INNER JOIN tst_pass_result passes
ON active_fi = active_id
WHERE test_fi = %s
";

$res = $this->db->queryF($query, array('integer'), array($this->testId));

$passes = array();

while($row = $this->db->fetchAssoc($res))
{
if( !isset($passes[$row['active_fi']]) )
{
$passes[$row['active_fi']] = array();
}

$passes[$row['active_fi']][] = $row['pass'];
}

return $passes;
}
}
Loading

0 comments on commit 3990002

Please sign in to comment.