Skip to content

Commit

Permalink
Merge pull request #2 from ILIAS-eLearning/release_5-0
Browse files Browse the repository at this point in the history
Merged from ILIAS
  • Loading branch information
smeyer-ilias committed Mar 20, 2015
2 parents 2a9278e + 03853f2 commit f8ed9c3
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 22 deletions.
134 changes: 134 additions & 0 deletions Modules/Test/classes/class.ilObjTestAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,136 @@ public static function _isPassed($user_id, $a_obj_id)
}
}

/**
* Returns TRUE if the user with the user id $user_id failed the test with the object id $a_obj_id
*
* @param int $user_id The user id
* @param int $a_obj_id The object id
* @return boolean TRUE if the user failed the test, FALSE otherwise
*/
public static function isFailed($user_id, $a_obj_id)
{
global $ilDB;

$ret = self::updateTestResultCache($user_id, $a_obj_id);

if(!$ret)
{
return false;
}

$result = $ilDB->queryF("SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
array('integer','integer'),
array($user_id, $a_obj_id)
);

if (!$result->numRows())
{
$result = $ilDB->queryF("SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
array('integer','integer'),
array($user_id, $a_obj_id)
);

while ($row = $ilDB->fetchAssoc($result))
{
array_push($points, $row);
}
$reached = 0;
$max = 0;
if ($points[0]["pass_scoring"] == 0)
{
$reached = $points[count($points)-1]["points"];
$max = $points[count($points)-1]["maxpoints"];
if (!$max)
{
$active_id = $points[count($points)-1]["active_fi"];
$pass = $points[count($points)-1]["pass"];
if (strlen($active_id) && strlen($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
$max = $res['maxpoints'];
$reached = $res['points'];
}
}
}
else
{
foreach ($points as $row)
{
if ($row["points"] > $reached)
{
$reached = $row["points"];
$max = $row["maxpoints"];
if (!$max)
{
$active_id = $row["active_fi"];
$pass = $row["pass"];
if (strlen($active_id) && strlen($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
$max = $res['maxpoints'];
$reached = $res['points'];
}
}
}
}
}
include_once "./Modules/Test/classes/class.assMarkSchema.php";
$percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
$mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
return ($mark["failed"]) ? TRUE : FALSE;
}
else
{
$row = $ilDB->fetchAssoc($result);
return ($row['failed']) ? TRUE : FALSE;
}
}

/**
* Update test result cache
* @param type $a_user_id
* @param type $a_obj_id
*/
protected function updateTestResultCache($a_user_id, $a_obj_id)
{
global $ilDB;

$result = $ilDB->queryF(
"SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests ".
"WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s ".
"AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
array('integer','integer'),
array($a_user_id, $a_obj_id)
);
if (!$result->numRows())
{
$result = $ilDB->queryF("SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
array('integer','integer'),
array($a_user_id, $a_obj_id)
);
$row = $ilDB->fetchAssoc($result);
if ($row['active_id'] > 0)
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
assQuestion::_updateTestResultCache($row['active_id']);
return true;
}
else
{
return false;
}

}
else
{
return true;
}
}


/**
* Get possible conditions operators
*/
Expand All @@ -228,6 +358,7 @@ public static function getConditionOperators()
include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
return array(
ilConditionHandler::OPERATOR_PASSED,
ilConditionHandler::OPERATOR_FAILED,
ilConditionHandler::OPERATOR_FINISHED,
ilConditionHandler::OPERATOR_NOT_FINISHED
);
Expand All @@ -248,6 +379,9 @@ public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_i
case ilConditionHandler::OPERATOR_PASSED:
return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
break;

case ilConditionHandler::OPERATOR_FAILED:
return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);

case ilConditionHandler::OPERATOR_FINISHED:
return ilObjTestAccess::_hasFinished($a_usr_id,$a_obj_id);
Expand Down
11 changes: 11 additions & 0 deletions Services/ActiveRecord/Cache/class.arObjectCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ public static function get($class, $id) {
public static function purge(ActiveRecord $object) {
unset(self::$cache[get_class($object)][$object->getPrimaryFieldValue()]);
}


/**
* @param $class_name
*/
public static function flush($class_name) {
if ($class_name instanceof ActiveRecord) {
$class_name = get_class($class_name);
}
unset(self::$cache[$class_name]);
}
}

?>
6 changes: 6 additions & 0 deletions Services/ActiveRecord/Fields/class.arFieldList.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,14 @@ protected function initFields() {
*/
public function getFieldByName($field_name) {
$field = NULL;
static $field_map;
if ($field_map[$field_name]) {
return $field_map[$field_name];
}
foreach ($this->getFields() as $field) {
if ($field->getName() == $field_name) {
$field_map[$field_name] = $field;

return $field;
}
}
Expand Down
33 changes: 21 additions & 12 deletions Services/ActiveRecord/class.ActiveRecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,19 @@ public function __construct(ActiveRecord $ar) {
$arSelect->setTableName($ar->getConnectorContainerName());
$arSelect->setFieldName('*');
$this->getArSelectCollection()->add($arSelect);
// if ($ar->getArConnector() == NULL) {
// $this->connector = new arConnectorDB($this);
// } else {
// $this->connector = $ar->getArConnector();
// }
}

if ($ar->getArConnector() == NULL) {
$this->connector = new arConnectorDB($this);
} else {
$this->connector = $ar->getArConnector();
}

/**
* @return arConnector
*/
protected function getArConnector() {
return arConnectorMap::get($this->getAR());
}

//
Expand Down Expand Up @@ -435,7 +442,7 @@ public function hasSets() {
* @return int
*/
public function affectedRows() {
return $this->connector->affectedRows($this);
return $this->getArConnector()->affectedRows($this);
}


Expand Down Expand Up @@ -581,18 +588,20 @@ protected function load() {
if ($this->loaded) {
return;
} else {
$records = $this->connector->readSet($this);
$records = $this->getArConnector()->readSet($this);
/**
* @var $obj ActiveRecord
*/
$class = get_class($this->getAR());
$obj = arFactory::getInstance($class, NULL, $this->getAddidtionalParameters());
$primaryFieldName = $obj->getArFieldList()->getPrimaryFieldName();

// $class = get_class($this->getAR());
// $obj = arFactory::getInstance($class, NULL, $this->getAddidtionalParameters());
$primaryFieldName = $this->getAR()->getArFieldList()->getPrimaryFieldName();
$class_name = get_class($this->getAR());
foreach ($records as $res) {
$primary_field_value = $res[$primaryFieldName];
if (!$this->getRaw()) {
$obj = arFactory::getInstance($class, NULL, $this->getAddidtionalParameters());

// $obj = arFactory::getInstance($class_name, NULL, $this->getAddidtionalParameters());
$obj = new $class_name(0, $this->getArConnector(), $this->getAddidtionalParameters());
$this->result[$primary_field_value] = $obj->buildFromArray($res);
}
$res_awake = array();
Expand Down
8 changes: 7 additions & 1 deletion Services/InfoScreen/classes/class.ilInfoScreenGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@ function addObjectSections()
if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner())
{
include_once './Services/Object/classes/class.ilObjectFactory.php';
if(!$ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(),false))
include_once './Services/User/classes/class.ilObjUser.php';

if(ilObjUser::userExists(array($a_obj->getOwner())))
{
$ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(),false);
}
else
{
$ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
}
Expand Down
6 changes: 6 additions & 0 deletions Services/Init/classes/class.ilErrorHandling.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ public function handleUncaughtException(Exception $e)
*/
public function handleRuntimeErrors($a_error_code, $a_error_message, $a_error_file, $a_error_line)
{
// #15641 - the silence operator should suppress the error completely
if(error_reporting() === 0)
{
return;
}

$backtrace_array = $this->formatBacktraceArray(debug_backtrace());
$error_code = $this->translateErrorCode($a_error_code);

Expand Down
4 changes: 3 additions & 1 deletion Services/Mail/classes/class.ilMailUserCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public static function preloadUserObjects(array $usr_ids)
{
$in = $ilDB->in('ud.usr_id', $usr_ids_to_request, false, 'integer');
$query = "
SELECT ud.usr_id, login, firstname, lastname, title, gender, pprof.value public_profile,pup.value public_upload
SELECT ud.usr_id, login, firstname, lastname, title, gender, pprof.value public_profile,pup.value public_upload, pupgen.value public_gender
FROM usr_data ud
LEFT JOIN usr_pref pprof ON pprof.usr_id = ud.usr_id AND pprof.keyword = %s
LEFT JOIN usr_pref pupgen ON pupgen.usr_id = ud.usr_id AND pupgen.keyword = %s
LEFT JOIN usr_pref pup ON pup.usr_id = ud.usr_id AND pup.keyword = %s
WHERE $in
";
Expand All @@ -69,6 +70,7 @@ public static function preloadUserObjects(array $usr_ids)
$user->setLastname($row['lastname']);
$user->setPref('public_profile', $row['public_profile']);
$user->setPref('public_upload', $row['public_upload']);
$user->setPref('public_gender', $row['public_gender']);

self::$user_instances[$row['usr_id']] = $user;
}
Expand Down
28 changes: 23 additions & 5 deletions Services/MediaObjects/classes/class.ilMediaPlayerGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function getMp3PlayerHtml($a_preview = false)

$tpl->addJavascript("./Services/MediaObjects/js/MediaObjects.js");

if (!self::$lightbox_initialized)
if (!self::$lightbox_initialized && $a_preview)
{
include_once("./Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php");
$lb = new ilLightboxGUI("media_lightbox");
Expand Down Expand Up @@ -363,9 +363,18 @@ function getMp3PlayerHtml($a_preview = false)
$mp_tpl->setVariable("TITLE", $this->getTitle());
$mp_tpl->setVariable("DESCRIPTION", $this->getDescription());
include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
$mp_tpl->setVariable("CLOSE", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
if ($a_preview)
{
$mp_tpl->setVariable("CLOSE", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
}
$mp_tpl->parseCurrentBlock();
$r = $mp_tpl->get();

if (!$a_preview)
{
$tpl->addOnLoadCode("new MediaElementPlayer('#player_".$this->id."_".$this->current_nr."');");
}

//echo htmlentities($r);
return $r;
}
Expand Down Expand Up @@ -488,13 +497,22 @@ function getMp3PlayerHtml($a_preview = false)
/**
* Get preview html
*
* @param
* @return
* @return string html
*/
function getPreviewHtml()
{
return $this->getMp3PlayerHtml(true);
}


/**
* Get HTML (no preview) for media player integration
*
* @return string html
*/
function getMediaPlayerHtml()
{
return $this->getMp3PlayerHtml(false);
}

}
?>
2 changes: 1 addition & 1 deletion Services/News/classes/class.ilNewsForContextBlockGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ function showNews()
include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
$mob = new ilObjMediaObject($item["mob_id"]);
$med = $mob->getMediaItem("Standard");
$mpl = new ilMediaPlayerGUI();
$mpl = new ilMediaPlayerGUI("news_pl_".$item["mob_id"]);
if (strcasecmp("Reference", $med->getLocationType()) == 0)
$mpl->setFile($med->getLocation());
else
Expand Down
2 changes: 2 additions & 0 deletions lang/setup_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,5 @@ ps_auto_https_header_name#:#Headername
ps_auto_https_header_value#:#Headerwert
https_settings#:#HTTPS-Einstellungen
alert#:#Warnung
pre_opcache_comments#:#opcache.load_comments muss eingeschaltet sein
pre_load_comments#:#PHP-OPCache load_comments
4 changes: 3 additions & 1 deletion lang/setup_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,6 @@ ps_auto_https_header_name#:#Header Name
ps_auto_https_header_value#:#Header Value
ps_auto_https#:#Autodetect HTTPS
https_settings#:#HTTPS Settings
alert#:#Warning
alert#:#Warning
pre_opcache_comments#:#Set opcache.load_comments to 1
pre_load_comments#:#PHP-OPCache load_comments
Loading

0 comments on commit f8ed9c3

Please sign in to comment.