ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusContributionToDiscussion.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
26{
27 public static function _getCompleted(int $a_obj_id): array
28 {
29 $userIds = [];
30
31 $frm_properties = ilForumProperties::getInstance($a_obj_id);
32 $num_required_postings = $frm_properties->getLpReqNumPostings();
33
34 if (null === $num_required_postings) {
35 return $userIds;
36 }
37
38 $frm = new ilForum();
39 $frm->setForumId($frm_properties->getObjId());
40 $statistics = $frm->getUserStatistics(
41 $frm_properties->isPostActivationEnabled()
42 );
43
44 return array_map(
45 static function (array $statisic): int {
46 return (int) $statisic['pos_author_id'];
47 },
48 array_filter(
49 $statistics,
50 static function (array $statistic) use (
51 $num_required_postings
52 ): bool {
53 return (int) $statistic['num_postings'] >= $num_required_postings;
54 }
55 )
56 );
57 }
58
59 public static function _getInProgress(int $a_obj_id): array
60 {
61 $userIds = [];
62
63 $frm_properties = ilForumProperties::getInstance($a_obj_id);
64 $num_required_postings = $frm_properties->getLpReqNumPostings();
65
66 if (null === $num_required_postings) {
67 return $userIds;
68 }
69
70 $frm = new ilForum();
71 $frm->setForumId($frm_properties->getObjId());
72 $statistics = $frm->getUserStatistics(
73 $frm_properties->isPostActivationEnabled()
74 );
75
76 return array_map(
77 static function (array $statisic): int {
78 return (int) $statisic['pos_author_id'];
79 },
80 array_filter(
81 $statistics,
82 static function (array $statistic) use (
83 $num_required_postings
84 ): bool {
85 $num_user_postings = (int) $statistic['num_postings'];
86 return $num_user_postings > 0 && $num_user_postings < $num_required_postings;
87 }
88 )
89 );
90 }
91
92 public function determineStatus(
93 int $a_obj_id,
94 int $a_usr_id,
95 ?object $a_obj = null
96 ): int {
97 $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
98
99 $frm_properties = ilForumProperties::getInstance($a_obj_id);
100 $num_required_postings = $frm_properties->getLpReqNumPostings();
101
102 if (null === $num_required_postings) {
103 return $status;
104 }
105
106 $frm = new ilForum();
107 $frm->setForumId($frm_properties->getObjId());
108
109 $num_postings = $frm->getNumberOfPublishedUserPostings(
110 $a_usr_id,
111 $frm_properties->isPostActivationEnabled()
112 );
113 if ($num_postings >= $num_required_postings) {
115 } elseif ($num_postings > 0) {
117 }
118
119 return $status;
120 }
121}
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