Adding hot courses block (partial) see #4200

skala
Julio Montoya 13 years ago
parent b20c8f927a
commit dd485c16d4
  1. 3
      index.php
  2. 11
      main/css/base.css
  3. 10
      main/inc/ajax/course_home.ajax.php
  4. 35
      main/inc/lib/course.lib.php
  5. 2
      main/inc/lib/database.lib.php
  6. 4
      main/inc/local.inc.php
  7. 22
      main/template/default/auth/courses_categories.php
  8. 22
      main/template/default/layout/head.tpl
  9. 18
      main/template/default/layout/layout_2_col.tpl
  10. 4
      user_portal.php

@ -26,6 +26,7 @@ if (!api_is_anonymous()) {
$header_title = " "; $header_title = " ";
} }
$htmlHeadXtra[] = api_get_jquery_ui_js();
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider')); $htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider'));
$htmlHeadXtra[] =' $htmlHeadXtra[] ='
<script type="text/javascript"> <script type="text/javascript">
@ -181,6 +182,8 @@ if (!api_is_anonymous()) {
} }
} }
$controller->tpl->assign('hot_courses', $controller->return_hot_courses());
$controller->tpl->assign('announcements_block', $controller->return_announcements()); $controller->tpl->assign('announcements_block', $controller->return_announcements());
$controller->tpl->assign('home_page_block', $controller->return_home_page()); $controller->tpl->assign('home_page_block', $controller->return_home_page());
$controller->tpl->assign('notice_block', $controller->return_notice()); $controller->tpl->assign('notice_block', $controller->return_notice());

@ -1810,8 +1810,8 @@ button:hover {
float:left; float:left;
margin:10px; margin:10px;
padding:12px; padding:12px;
width:250px; width:95%;
min-height:294px; /* min-height:294px; */
color: #BBBBBB; color: #BBBBBB;
} }
@ -1843,10 +1843,15 @@ button:hover {
} }
.categories-course-description { .categories-course-description {
margin-left:10px; margin-left:18px;
font-family:arial; font-family:arial;
font-size:11px; font-size:11px;
margin-bottom: 10px; margin-bottom: 10px;
float:left;
}
.categories-course-links div {
padding-left:10px;
} }
.categories-course-description .course-block-title { .categories-course-description .course-block-title {

@ -72,15 +72,19 @@ switch ($action) {
$language_file = array('course_description'); $language_file = array('course_description');
require_once '../global.inc.php'; require_once '../global.inc.php';
if (api_is_anonymous()) {
exit;
}
// Get the name of the database course. // Get the name of the database course.
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_info = api_get_course_info($_GET['code']); $course_info = api_get_course_info($_GET['code']);
if ($course_info['visibility'] != COURSE_VISIBILITY_OPEN_WORLD) {
if (api_is_anonymous()) {
exit;
}
}
echo Display::tag('h2', $course_info['name']); echo Display::tag('h2', $course_info['name']);
echo '<br />'; echo '<br />';

@ -3592,14 +3592,39 @@ class CourseManager {
} }
} }
function return_hot_courses($limit = 5) { //Stats functions
function return_hot_courses($days = 30, $limit = 5) {
$limit = intval($limit);
$table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$today = api_get_utc_datetime();
$today_diff = time() -intval($days)*24*60*60;
$today_diff = api_get_utc_datetime($today_diff);
//WHERE login_course_date <= '$today' AND login_course_date >= '$today_diff'
//$table_course_access table uses the now() and interval ...
$sql = "SELECT COUNT(course_access_id) course_count, course_code FROM $table_course_access
WHERE login_course_date <= now() AND login_course_date > DATE_SUB(now(), INTERVAL $days DAY)
GROUP BY course_code
ORDER BY course_count DESC
LIMIT $limit";
$result = Database::query($sql);
$courses = array();
if (Database::num_rows($result)) {
$courses = Database::store_result($result, 'ASSOC');
foreach ($courses as &$my_course) {
$my_course['extra_info'] = api_get_course_info($my_course['course_code']);
}
}
return $courses;
}
function return_most_accessed_courses($limit = 5) {
$table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING); $table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
$params['url_id'] = api_get_current_access_url_id(); $params['url_id'] = api_get_current_access_url_id();
$result = Database::select('c_id, accesses, points, users', $table_course_ranking, array('where' => array('url_id = ?' => $params), 'order' => array('accesses DESC, users DESC, points DESC'), 'limit' => $limit), 'all', true); $result = Database::select('c_id, accesses, points, users', $table_course_ranking, array('where' => array('url_id = ?' => $params), 'order' => array('accesses DESC'), 'limit' => $limit), 'all', true);
return $result; return $result;
} }
} //end class CourseManager } //end class CourseManager

@ -1154,7 +1154,7 @@ class Database {
* @todo known issues, it doesn't work when using LIKE conditions example: array('where'=>array('course_code LIKE "?%"')) * @todo known issues, it doesn't work when using LIKE conditions example: array('where'=>array('course_code LIKE "?%"'))
*/ */
public static function select($columns = '*' , $table_name, $conditions = array(), $type_result = 'all', $option = 'ASSOC') { public static function select($columns, $table_name, $conditions = array(), $type_result = 'all', $option = 'ASSOC') {
$conditions = self::parse_conditions($conditions); $conditions = self::parse_conditions($conditions);
//@todo we could do a describe here to check the columns ... //@todo we could do a describe here to check the columns ...

@ -928,7 +928,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // ses
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::store_result($result); $row = Database::store_result($result);
if (isset($row) && $row[0]['id_coach'] == $_user['user_id']) { if (isset($row) && isset($row[0]) && $row[0]['id_coach'] == $_user['user_id']) {
$_courseUser['role'] = 'Professor'; $_courseUser['role'] = 'Professor';
$is_courseMember = true; $is_courseMember = true;
$is_courseTutor = true; $is_courseTutor = true;
@ -941,7 +941,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // ses
$is_courseAdmin = false; $is_courseAdmin = false;
} }
api_session_register('_courseUser'); api_session_register('_courseUser');
} elseif(isset($row) && $row[0]['session_admin_id']==$_user['user_id']) { } elseif( isset($row) && isset($row[0]) && $row[0]['session_admin_id']==$_user['user_id']) {
$_courseUser['role'] = 'Professor'; $_courseUser['role'] = 'Professor';
$is_courseMember = false; $is_courseMember = false;
$is_courseTutor = false; $is_courseTutor = false;

@ -163,13 +163,7 @@ $stok = Security::get_token();
//<div class="course-block-main-item"><div class="left">'.get_lang('Teacher').'</div><div class="course-block-teacher right">'.$tutor_name.'</div></div> //<div class="course-block-main-item"><div class="left">'.get_lang('Teacher').'</div><div class="course-block-teacher right">'.$tutor_name.'</div></div>
//<div class="course-block-main-item"><div class="left">'.get_lang('CreationDate').'</div><div class="course-block-date">'.api_format_date($creation_date,DATE_FORMAT_SHORT).'</div></div> //<div class="course-block-main-item"><div class="left">'.get_lang('CreationDate').'</div><div class="course-block-date">'.api_format_date($creation_date,DATE_FORMAT_SHORT).'</div></div>
echo '<div class="categories-block-course"> echo '<div class="categories-block-course">
<div class="categories-content-course"> <div class="categories-content-course">';
<div class="categories-course-description">
<div class="course-block-title">'.cut($title, 60).'</div>
'.$rating.'
</div>';
echo '<div class="categories-course-picture"><center>'; echo '<div class="categories-course-picture"><center>';
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
@ -179,17 +173,23 @@ $stok = Security::get_token();
} else { } else {
echo '<img src="'.$course_medium_image.'" />'; echo '<img src="'.$course_medium_image.'" />';
} }
echo '</center></div>';
echo '</center>
</div> echo '<div class="categories-course-description">
<div class="course-block-popularity"><span>'.get_lang('ConnectionsLastMonth').'</span><div class="course-block-popularity-score">'.$count_connections.'</div></div>'; <div class="course-block-title">'.cut($title, 60).'</div>
'.$rating.'
</div>';
echo '<div class="course-block-popularity"><span>'.get_lang('ConnectionsLastMonth').'</span><div class="course-block-popularity-score">'.$count_connections.'</div></div>';
echo '</div>'; echo '</div>';
echo '<div class="categories-course-links">'; echo '<div class="categories-course-links">';
// we display the icon to subscribe or the text already subscribed // we display the icon to subscribe or the text already subscribed
if (!in_array($course['code'], $user_coursecodes)) { if (!in_array($course['code'], $user_coursecodes)) {
if ($course['subscribe'] == SUBSCRIBE_ALLOWED) { if ($course['subscribe'] == SUBSCRIBE_ALLOWED) {
echo '<div class="course-link-desc left"><a class="a_button orange medium" href="'. api_get_self().'?action=subscribe_course&amp;sec_token='.$stok.'&amp;subscribe_course='.$course['code'].'&amp;search_term='.$search_term.'&amp;category_code='.$code.'">'.get_lang('Subscribe').'</a></div>'; echo '<div class="course-link-desc right">
<a class="a_button gray small" href="'. api_get_self().'?action=subscribe_course&amp;sec_token='.$stok.'&amp;subscribe_course='.$course['code'].'&amp;search_term='.$search_term.'&amp;category_code='.$code.'">'.get_lang('Subscribe').'</a></div>';
} }
} }
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {

@ -48,6 +48,28 @@ if ( ( navigator.userAgent.toLowerCase().indexOf('msie') != -1 ) && ( navigator.
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
$('.topbar').dropdown(); $('.topbar').dropdown();
$('.ajax').live('click', function() {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:hidden"></div>').appendTo('body');
}
// load remote content
dialog.load(
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
modal : true,
width : 540,
height : 400,
});
});
//prevent the browser to follow the link
return false;
});
}); });
</script> </script>

@ -18,11 +18,25 @@
{$announcements_block} {$announcements_block}
{if !(empty($hot_courses)) } {if !(empty($hot_courses)) }
<h3>Hottest courses</h3> <h3>{"HottestCourses"|get_lang}</h3>
{foreach $hot_courses as $hot_course} {foreach $hot_courses as $hot_course}
<div class="categories-block-course"> <div class="categories-block-course">
<div class="categories-content-course"> <div class="categories-content-course">
Course id: {$hot_course.c_id} <h4>{$hot_course.extra_info.name}</h4>
{"Visits"|get_lang} : {$hot_course.course_count}
{if ($hot_course.extra_info.visibility == 3)}
<a class="ajax a_button white small" title="" href="{'WEB_AJAX_PATH'|get_path}course_home.ajax.php?a=show_course_information&code={$hot_course.course_code}">
{"Description"|get_lang}
</a>
{/if}
{* World *}
{if ($hot_course.extra_info.visibility == 3)}
<a class="a_button gray small" title="" href="{'WEB_COURSE_PATH'|get_path}{$hot_course.extra_info.path}/index.php">
{"GoToCourse"|get_lang}
</a>
{/if}
</div> </div>
</div> </div>
{/foreach} {/foreach}

@ -35,6 +35,8 @@ if (isset($_SESSION['this_section']))
require_once './main/inc/global.inc.php'; require_once './main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'userportal.lib.php'; require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';
$htmlHeadXtra[] = api_get_jquery_ui_js();
api_block_anonymous_users(); // Only users who are logged in can proceed. api_block_anonymous_users(); // Only users who are logged in can proceed.
/* Constants and CONFIGURATION parameters */ /* Constants and CONFIGURATION parameters */
@ -226,7 +228,7 @@ if (stripos("flash_yes", $_SESSION['sniff_check_some_activex'])===0 || stripos("
//$controller->tpl->assign('sniff_notification', $sniff_notification); //$controller->tpl->assign('sniff_notification', $sniff_notification);
} }
$controller->tpl->assign('hot_courses', $controller->return_hot_courses()); //$controller->tpl->assign('hot_courses', $controller->return_hot_courses());
$controller->tpl->assign('plugin_courses_block', $controller->return_courses_main_plugin()); $controller->tpl->assign('plugin_courses_block', $controller->return_courses_main_plugin());
$controller->tpl->assign('profile_block', $controller->return_profile_block()); $controller->tpl->assign('profile_block', $controller->return_profile_block());

Loading…
Cancel
Save