ILIAS  release_8 Revision v8.24
class.ilLPStatusContributionToDiscussion.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4
10{
11 public static function _getCompleted(int $a_obj_id): array
12 {
13 $userIds = [];
14
15 $frm_properties = ilForumProperties::getInstance($a_obj_id);
16 $num_required_postings = $frm_properties->getLpReqNumPostings();
17
18 if (null === $num_required_postings) {
19 return $userIds;
20 }
21
22 $frm = new ilForum();
23 $frm->setForumId($frm_properties->getObjId());
24 $statistics = $frm->getUserStatistics(
25 $frm_properties->isPostActivationEnabled()
26 );
27
28 return array_map(
29 static function (array $statisic): int {
30 return (int) $statisic['pos_author_id'];
31 },
32 array_filter(
33 $statistics,
34 static function (array $statistic) use (
35 $num_required_postings
36 ): bool {
37 return (int) $statistic['num_postings'] >= $num_required_postings;
38 }
39 )
40 );
41 }
42
43 public static function _getInProgress(int $a_obj_id): array
44 {
45 $userIds = [];
46
47 $frm_properties = ilForumProperties::getInstance($a_obj_id);
48 $num_required_postings = $frm_properties->getLpReqNumPostings();
49
50 if (null === $num_required_postings) {
51 return $userIds;
52 }
53
54 $frm = new ilForum();
55 $frm->setForumId($frm_properties->getObjId());
56 $statistics = $frm->getUserStatistics(
57 $frm_properties->isPostActivationEnabled()
58 );
59
60 return array_map(
61 static function (array $statisic): int {
62 return (int) $statisic['pos_author_id'];
63 },
64 array_filter(
65 $statistics,
66 static function (array $statistic) use (
67 $num_required_postings
68 ): bool {
69 $num_user_postings = (int) $statistic['num_postings'];
70 return $num_user_postings > 0 && $num_user_postings < $num_required_postings;
71 }
72 )
73 );
74 }
75
76 public function determineStatus(
77 int $a_obj_id,
78 int $a_usr_id,
79 object $a_obj = null
80 ): int {
81 $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
82
83 $frm_properties = ilForumProperties::getInstance($a_obj_id);
84 $num_required_postings = $frm_properties->getLpReqNumPostings();
85
86 if (null === $num_required_postings) {
87 return $status;
88 }
89
90 $frm = new ilForum();
91 $frm->setForumId($frm_properties->getObjId());
92
93 $num_postings = $frm->getNumberOfPublishedUserPostings(
94 $a_usr_id,
95 $frm_properties->isPostActivationEnabled()
96 );
97 if ($num_postings >= $num_required_postings) {
99 } elseif ($num_postings > 0) {
101 }
102
103 return $status;
104 }
105}
static getInstance(int $a_obj_id=0)
Class Forum core functions for forum.
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM