Skip to content
Snippets Groups Projects
Commit fc949d25 authored by Ron Lucke's avatar Ron Lucke Committed by Elmar Ludwig
Browse files

fix #2048

Closes #2048

Merge request studip/studip!1416
parent 4f98178a
No related branches found
No related tags found
1 merge request!4Draft: Icon creation
......@@ -65,32 +65,26 @@ class CoursewareModule extends CorePlugin implements SystemPlugin, StudipModule,
*/
public function getIconNavigation($courseId, $last_visit, $user_id)
{
$new = 0;
$course_elements = Courseware\StructuralElement::findBySQL(
'range_type = ? AND range_id = ?',
['course', $courseId]
);
foreach($course_elements as $element) {
$has_new_blocks = false;
$containers = $element->containers->getArrayCopy();
foreach($containers as $container) {
$blocks = $container->blocks->getArrayCopy();
foreach($blocks as $block) {
if (
$block->editor_id !== $user_id
&&
$block->chdate >= $last_visit
&&
$block->payload !== ''
) {
$has_new_blocks = true;
}
}
}
if($has_new_blocks) {
$new++;
}
}
$statement = DBManager::get()->prepare("
SELECT COUNT(DISTINCT elem.id)
FROM `cw_structural_elements` AS elem
INNER JOIN `cw_containers` as container ON (elem.id = container.structural_element_id)
INNER JOIN `cw_blocks` as blocks ON (container.id = blocks.container_id)
WHERE elem.range_type = 'course'
AND elem.range_id = :range_id
AND blocks.payload != ''
AND blocks.chdate > :last_visit
AND blocks.editor_id != :user_id
");
$statement->execute([
'range_id' => $courseId,
'last_visit' => $last_visit,
'user_id' => $user_id
]);
$new = $statement->fetchColumn();
$nav = new Navigation(_('Courseware'), 'dispatch.php/course/courseware');
$nav->setImage(Icon::create('courseware', Icon::ROLE_CLICKABLE), [
'title' => _('Courseware'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment