Skip to content

Commit

Permalink
Ticket #4817 - Courses improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Nov 13, 2024
1 parent 0f4b7d1 commit 890d579
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
13 changes: 13 additions & 0 deletions modules/boonex/courses/classes/BxCoursesModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,19 @@ public function serviceOnContentDeleted($sContentType, $iContentId, $iContextId)
}
}

public function serviceJoinedEntriesSummary ($iProfileId = 0)
{
if (!$iProfileId)
$iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
if (!$iProfileId || !($oProfile = BxDolProfile::getInstance($iProfileId)))
return false;

if ($iProfileId != $this->_iProfileId)
return false;

return $this->_oTemplate->getJoinedEntriesSummary($iProfileId);
}

public function serviceEntityContentStructureBlock($iProfileId = 0)
{
$CNF = &$this->_oConfig->CNF;
Expand Down
36 changes: 35 additions & 1 deletion modules/boonex/courses/classes/BxCoursesTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,41 @@ public function getCounters($aCounters)

return $this->_bIsApi ? $aTmplVars : $this->parseHtmlByName('counters.html', $aTmplVars);
}


public function getJoinedEntriesSummary($iProfileId)
{
$CNF = &$this->_oConfig->CNF;

$oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
if(!$oConnection)
return false;

$aEntries = $oConnection->getConnectedContent($iProfileId);

$iJoined = count($aEntries);
$iStarted = 0;
$iPassed = 0;

foreach($aEntries as $iEntryId) {
$aEntryInfo = $this->_oDb->getContentInfoByProfileId($iEntryId);

list($iPassPercent) = $this->_oModule->getEntryPass($iProfileId, $aEntryInfo[$CNF['FIELD_ID']]);
if($iPassPercent > 0 && $iPassPercent < 100)
$iStarted += 1;
else if($iPassPercent == 100)
$iPassed +=1;
}

$aTmplVars = [
'joined' => $iJoined,
'passed' => $iPassed,
'not_passed' => $iJoined - $iPassed,
'passed_percent' => $iJoined != 0 ? (int)round(100 * $iPassed/$iJoined) : 0
];

return $this->_bIsApi ? $aTmplVars : $this->parseHtmlByName('entries_summary.html', $aTmplVars);
}

public function entryStructureByLevel($aContentInfo, $aParams = [])
{
$CNF = &$this->_oConfig->CNF;
Expand Down
8 changes: 6 additions & 2 deletions modules/boonex/courses/install/langs/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
<string name="_bx_courses_page_title_entries_search"><![CDATA[Search]]></string>
<string name="_bx_courses_page_title_sys_entries_favorites"><![CDATA[Favorites Courses]]></string>
<string name="_bx_courses_page_title_entries_favorites"><![CDATA[Favorites Courses]]></string>

<string name="_bx_courses_page_block_title_sys_entries_actions"><![CDATA[Courses actions]]></string>
<string name="_bx_courses_page_block_title_entries_actions"><![CDATA[Courses actions]]></string>
<string name="_bx_courses_page_block_title_sys_favorites_entries"><![CDATA[Favorite List]]></string>
Expand All @@ -167,6 +166,8 @@
<string name="_bx_courses_page_block_title_entries_of_author"><![CDATA[Courses by {display_name}]]></string>
<string name="_bx_courses_page_block_title_favorites_of_author"><![CDATA[Favorite Courses]]></string>
<string name="_bx_courses_page_block_title_sys_favorites_of_author"><![CDATA[Favorite Courses]]></string>
<string name="_bx_courses_page_block_title_sys_joined_entries_summary"><![CDATA[Attended Courses Summary]]></string>
<string name="_bx_courses_page_block_title_joined_entries_summary"><![CDATA[Attended Courses Summary]]></string>
<string name="_bx_courses_page_block_title_sys_joined_entries"><![CDATA[Attended Courses]]></string>
<string name="_bx_courses_page_block_title_joined_entries"><![CDATA[Attended Courses]]></string>
<string name="_bx_courses_page_block_title_create_profile"><![CDATA[Create Course]]></string>
Expand Down Expand Up @@ -467,7 +468,10 @@
<string name="_bx_courses_txt_back_step"><![CDATA[Back]]></string>
<string name="_bx_courses_txt_next_step"><![CDATA[Next]]></string>
<string name="_bx_courses_txt_download"><![CDATA[Download]]></string>

<string name="_bx_courses_txt_summary_title"><![CDATA[Study progress]]></string>
<string name="_bx_courses_txt_summary_joined"><![CDATA[Attended]]></string>
<string name="_bx_courses_txt_summary_passed"><![CDATA[Passed]]></string>
<string name="_bx_courses_txt_summary_not_started"><![CDATA[Not started]]></string>

<string name="_bx_courses_msg_performed"><![CDATA[The action was successfully performed.]]></string>
<string name="_bx_courses_err_price_duplicate"><![CDATA[Similar pricing plan is already exists.]]></string>
Expand Down
3 changes: 2 additions & 1 deletion modules/boonex/courses/install/sql/enable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
('bx_courses_joined', 1, 'bx_courses', '_bx_courses_page_block_title_sys_entries_actions', '_bx_courses_page_block_title_entries_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:10:"bx_courses";s:6:"method";s:18:"my_entries_actions";}', 0, 0, 1, 1),
('bx_courses_joined', 1, 'bx_courses', '_bx_courses_page_block_title_sys_entries_of_author', '_bx_courses_page_block_title_entries_of_author', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:10:"bx_courses";s:6:"method";s:22:"browse_created_entries";}', 0, 0, 0, 2),
('bx_courses_joined', 1, 'bx_courses', '_bx_courses_page_block_title_sys_favorites_of_author', '_bx_courses_page_block_title_favorites_of_author', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:10:"bx_courses";s:6:"method";s:15:"browse_favorite";s:6:"params";a:1:{i:0;s:12:"{profile_id}";}}', 0, 1, 1, 3),
('bx_courses_joined', 1, 'bx_courses', '_bx_courses_page_block_title_sys_joined_entries', '_bx_courses_page_block_title_joined_entries', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:10:"bx_courses";s:6:"method";s:21:"browse_joined_entries";s:6:"params";a:2:{i:0;i:0;i:1;b:1;}}', 0, 0, 1, 4);
('bx_courses_joined', 1, 'bx_courses', '_bx_courses_page_block_title_sys_joined_entries_summary', '_bx_courses_page_block_title_joined_entries_summary', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:10:"bx_courses";s:6:"method";s:22:"joined_entries_summary";}', 0, 0, 1, 4),
('bx_courses_joined', 1, 'bx_courses', '_bx_courses_page_block_title_sys_joined_entries', '_bx_courses_page_block_title_joined_entries', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:10:"bx_courses";s:6:"method";s:21:"browse_joined_entries";s:6:"params";a:2:{i:0;i:0;i:1;b:1;}}', 0, 0, 1, 5);

-- PAGE: favorites by list
INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES
Expand Down
6 changes: 6 additions & 0 deletions modules/boonex/russian/data/langs/bx_courses/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
<string name="_bx_courses_page_block_title_entries_of_author"><![CDATA[{display_name} - Курсы]]></string>
<string name="_bx_courses_page_block_title_favorites_of_author"><![CDATA[Избранные курсы]]></string>
<string name="_bx_courses_page_block_title_sys_favorites_of_author"><![CDATA[Избранные курсы]]></string>
<string name="_bx_courses_page_block_title_sys_joined_entries_summary"><![CDATA[Сводка посещаемых курсов]]></string>
<string name="_bx_courses_page_block_title_joined_entries_summary"><![CDATA[Сводка посещаемых курсов]]></string>
<string name="_bx_courses_page_block_title_sys_joined_entries"><![CDATA[Посещаемые курсы]]></string>
<string name="_bx_courses_page_block_title_joined_entries"><![CDATA[Посещаемые курсы]]></string>
<string name="_bx_courses_page_block_title_create_profile"><![CDATA[Создать курс]]></string>
Expand Down Expand Up @@ -465,6 +467,10 @@
<string name="_bx_courses_txt_back_step"><![CDATA[Назад]]></string>
<string name="_bx_courses_txt_next_step"><![CDATA[Вперед]]></string>
<string name="_bx_courses_txt_download"><![CDATA[Скачать]]></string>
<string name="_bx_courses_txt_summary_title"><![CDATA[Прогресс обучения]]></string>
<string name="_bx_courses_txt_summary_joined"><![CDATA[Записан на]]></string>
<string name="_bx_courses_txt_summary_passed"><![CDATA[Закончено]]></string>
<string name="_bx_courses_txt_summary_not_started"><![CDATA[Не начато]]></string>

<string name="_bx_courses_msg_performed"><![CDATA[Действие было успешно выполнено.]]></string>
<string name="_bx_courses_err_price_duplicate"><![CDATA[Аналогичный ценовой план уже существует.]]></string>
Expand Down

0 comments on commit 890d579

Please sign in to comment.