Adding course link when searching skills (student view) see #1791

skala
Julio Montoya 14 years ago
parent 7d177b8d89
commit 8484f974c6
  1. 2
      main/admin/skills_wheel.php
  2. 1
      main/auth/courses.php
  3. 34
      main/inc/ajax/skill.ajax.php
  4. 2
      main/inc/lib/auth.lib.php
  5. 63
      main/inc/lib/course.lib.php
  6. 4
      main/inc/lib/javascript/jquery-ui/default.css
  7. 13
      main/lang/english/trad4all.inc.php
  8. 5
      main/social/home.php
  9. 26
      main/template/default/layout/hot_course_item.tpl
  10. 26
      main/template/default/layout/hot_course_item_popup.tpl
  11. 36
      main/template/default/layout/hot_courses.tpl
  12. 1
      main/template/default/skill/profile.tpl
  13. 8
      main/template/default/skill/skill_wheel.js.tpl
  14. 24
      main/template/default/skill/skill_wheel.tpl
  15. 56
      main/template/default/skill/skill_wheel_student.tpl

@ -49,4 +49,4 @@ $tpl->assign('url', $url);
$content = $tpl->fetch('default/skill/skill_wheel.tpl');
$tpl->assign('content', $content);
$tpl->display_no_layout_template();
$tpl->display_no_layout_template();

@ -184,7 +184,6 @@ if (isset($_POST['unsubscribe'])) {
//$message = remove_user_from_course($_user['user_id'], $_POST['unsubscribe']);
}
}
switch ($action) {
case 'createcoursecategory':
$courses_controller->categories_list($action);

@ -35,11 +35,9 @@ switch ($action) {
$return_skills[] = $skill;
}
echo json_encode($return_skills);
break;
break;
case 'get_gradebooks':
$gradebooks = $gradebook_list = $gradebook->get_all();
$gradebooks = $gradebook_list = $gradebook->get_all();
$gradebook_list = array();
//Only course gradebook with certificate
if (!empty($gradebooks)) {
@ -51,8 +49,7 @@ switch ($action) {
} else {
// $gradebook['name'] = $gradebook_list[$gradebook['parent_id']]['name'].' > '.$gradebook['name'];
//$gradebook_list[] = $gradebook;
}
}
}
}
echo json_encode($gradebook_list);
@ -67,7 +64,16 @@ switch ($action) {
$return[] = $item;
}
echo json_encode($return);
break;
break;
case 'get_course_info_popup':
$course_info = api_get_course_info($_REQUEST['code']);
$courses = CourseManager::process_hot_course_item(array($course_info));
Display::display_no_header();
Display::$global_template->assign('span_size', 9);
Display::$global_template->assign('show_ranking', false);
Display::$global_template->assign('hot_courses', $courses);
echo Display::$global_template->fetch('default/layout/hot_course_item_popup.tpl');
break;
case 'gradebook_exists':
$data = $gradebook->get($_REQUEST['gradebook_id']);
if (!empty($data)) {
@ -88,8 +94,7 @@ switch ($action) {
Display::display_no_header();
Display::$global_template->assign('profiles', $profiles);
echo Display::$global_template->fetch('default/skill/profile_item.tpl');
echo Display::$global_template->fetch('default/skill/profile_item.tpl');
break;
case 'get_skills':
$load_user_data = isset($_REQUEST['load_user_data']) ? $_REQUEST['load_user_data'] : null;
@ -105,12 +110,15 @@ switch ($action) {
break;
case 'get_skill_course_info':
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$courses = $skill->get_courses_by_skill($id);
$html = null;
$skill_info = $skill->get_skill_info($id);
$courses = $skill->get_courses_by_skill($id);
$html = '';
if (!empty($courses)) {
$html = sprintf(get_lang('ToGetToLearnXYouWillNeedToTakeOneOfTheFollowingCourses'), '<i>'.$skill_info['name'].'</i>').'<br />';
foreach ($courses as $course) {
$html .= $course['title'].'<br />';
$url = '#';
$attributes = array('class' => 'course_description_popup', 'rel' => $course['code']);
$html .= Display::url(sprintf(get_lang('SkillXWithCourseX'), $skill_info['name'], $course['title']), $url, $attributes).'<br />';
}
}
echo $html;

@ -432,7 +432,7 @@ class Auth
$TABLE_COURSE_FIELD_VALUE = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
// get course list auto-register
// Get course list auto-register
$sql = "SELECT course_code FROM $TABLE_COURSE_FIELD_VALUE tcfv INNER JOIN $TABLE_COURSE_FIELD tcf ON tcfv.field_id = tcf.id
WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";

@ -3579,7 +3579,7 @@ class CourseManager {
*
*/
public function add_course_vote($user_id, $vote, $course_id, $session_id = null, $url_id = null) {
public static function add_course_vote($user_id, $vote, $course_id, $session_id = null, $url_id = null) {
$table_user_course_vote = Database::get_main_table(TABLE_MAIN_USER_REL_COURSE_VOTE);
$course_id = empty($course_id) ? api_get_course_int_id() : intval($course_id);
@ -3691,7 +3691,7 @@ class CourseManager {
//$table_course_access table uses the now() and interval ...
$sql = "SELECT COUNT(course_access_id) course_count, a.course_code, visibility ".
$sql = "SELECT COUNT(course_access_id) course_count, a.code, visibility ".
"FROM $table_course c INNER JOIN $table_course_access a ".
" ON (c.code = a.course_code) INNER JOIN $table_course_url u ON u.course_code = a.course_code ".
" WHERE u.access_url_id = ".$_configuration['access_url']." AND".
@ -3705,38 +3705,43 @@ class CourseManager {
$result = Database::query($sql);
$courses = array();
if (Database::num_rows($result)) {
$courses = Database::store_result($result, 'ASSOC');
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
foreach ($courses as &$my_course) {
$course_info = api_get_course_info($my_course['course_code']);
$my_course['extra_info'] = $course_info;
$my_course['extra_info']['go_to_course_button'] = '';
$access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list);
//Course visibility
if (0 === strcmp($access_link,'register')) {
$stok = Security::get_token();
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('Subscribe'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?action=subscribe&amp;sec_token='.$stok, array('class' => 'btn btn-primary'));
} elseif (0 === strcmp($access_link,'enter')) {
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
}
//Description
$my_course['extra_info']['description_button'] = '';
if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list) ) {
$my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn'));
}
$my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
$point_info = self::get_course_ranking($course_info['real_id'], 0);
$my_course['extra_info']['rating_html'] = Display::return_rating_system('star_'.$course_info['real_id'], $ajax_url.'&amp;course_id='.$course_info['real_id'], $point_info);
$courses = Database::store_result($result, 'ASSOC');
$courses = self::process_hot_course_item($courses, $my_course_code_list);
}
return $courses;
}
public static function process_hot_course_item($courses, $my_course_code_list = array()) {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
foreach ($courses as &$my_course) {
$course_info = api_get_course_info($my_course['code']);
$my_course['extra_info'] = $course_info;
$my_course['extra_info']['go_to_course_button'] = '';
$access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list);
//Course visibility
if (0 === strcmp($access_link,'register')) {
$stok = Security::get_token();
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('Subscribe'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?action=subscribe&amp;sec_token='.$stok, array('class' => 'btn btn-primary'));
} elseif (0 === strcmp($access_link,'enter')) {
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
}
//Description
$my_course['extra_info']['description_button'] = '';
if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list) ) {
$my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn'));
}
$my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
$point_info = self::get_course_ranking($course_info['real_id'], 0);
$my_course['extra_info']['rating_html'] = Display::return_rating_system('star_'.$course_info['real_id'], $ajax_url.'&amp;course_id='.$course_info['real_id'], $point_info);
}
return $courses;
}
public function return_most_accessed_courses($limit = 5) {
public static function return_most_accessed_courses($limit = 5) {
$table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
$params['url_id'] = api_get_current_access_url_id();

@ -48,6 +48,10 @@
color: #3757F7;
cursor: pointer;
}
.ui-widget-content .btn, .ui-widget-content .btn:hover {
color: white;
}
.ui-widget-content a:hover{
color: #3757F7;
cursor: pointer;

@ -935,6 +935,19 @@ $Literal20 = "twenty";
$DateTime = "Date & time";
$Item = "Item";
$Never = "Never";
$SkillsYouAcquired = "Skills you acquired";
$SkillsSearchedFor = "Skills searched for";
$SkillsYouCanLearn = "Skills you can learn";
$Legend = "Legend";
$ClickToZoom = "Click to zoom";
$SkillXWithCourseX = "%s with %s";
$ToGetToLearnXYouWillNeedToTakeOneOfTheFollowingCourses = "To get to learn %s you will need to take one of the following courses:";
$YourSkillRankingX = "Your skill ranking: %s";
$ManageSkills = "Manage skills";
$SkillRoot = "Root";
$SkillInfo = "Skill info";
$GetNewSkills = "Get new skills";
$ViewSkillsWheel = "View skills wheel";
$MissingOneStepToMatch = "Missing <b>one</b> step to match";
$CompleteMatch = "Complete match";
$MissingXStepsToMatch = "Missing <b>%s</b> steps";

@ -82,11 +82,10 @@ $social_right_content .= '
if (api_get_setting('allow_skills_tool') == 'true') {
$social_right_content .= '<div class="well_border">';
$skill = new Skill();
$skill_ranking = $skill->get_user_skill_ranking(api_get_user_id());
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH).'social/skills_ranking.php';
$social_right_content .= Display::url(sprintf(get_lang('YourSkillRanking'), $ranking), $url);
$social_right_content .= Display::url(sprintf(get_lang('YourSkillRankingX'), $ranking), $url);
$skill = new Skill();
$skills = $skill->get_user_skills(api_get_user_id(), true);
$social_right_content .= '<h3>'.get_lang('Skills').'</h3>';

@ -0,0 +1,26 @@
{% for hot_course in hot_courses %}
{% if hot_course.extra_info.title %}
<div class="span9">
<div class="well_border">
<div class="row">
<div class="span2">
<div class="thumbnail">
<img src="{{ hot_course.extra_info.course_image }}" />
</div>
</div>
<div class="span6">
<div class="categories-course-description">
<h3>{{ hot_course.extra_info.title}}</h3>
<h5>{{ hot_course.extra_info.teachers }}</h5>
{{ hot_course.extra_info.rating_html }}
</div>
<p>
{{ hot_course.extra_info.go_to_course_button }}
{{ hot_course.extra_info.description_button }}
</p>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}

@ -0,0 +1,26 @@
{% for hot_course in hot_courses %}
{% if hot_course.extra_info.title %}
<div class="span5">
<div class="well_border">
<div class="row">
<div class="span2">
<div class="thumbnail">
<img src="{{ hot_course.extra_info.course_image }}" />
</div>
</div>
<div class="span2">
<div class="categories-course-description">
<h3>{{ hot_course.extra_info.title}}</h3>
<h5>{{ hot_course.extra_info.teachers }}</h5>
{# hot_course.extra_info.rating_html #}
</div>
<p>
{{ hot_course.extra_info.go_to_course_button }}
{{ hot_course.extra_info.description_button }}
</p>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}

@ -1,6 +1,6 @@
{% if hot_courses is not null and hot_courses is not empty %}
<script type="text/javascript">
<script>
$(document).ready( function() {
$('.star-rating li a').live('click', function(event) {
var id = $(this).parents('ul').attr('id');
@ -9,10 +9,10 @@ $(document).ready( function() {
url: $(this).attr('data-link'),
success: function(data) {
$("#rating_wrapper_"+id).html(data);
if(data == 'added') {
if (data == 'added') {
//$('#vote_label2_' + id).html("{{'Saved'|get_lang}}");
}
if(data == 'updated') {
if (data == 'updated') {
//$('#vote_label2_' + id).html("{{'Saved'|get_lang}}");
}
}
@ -33,35 +33,9 @@ $(document).ready( function() {
</span>
{% endif %}
{{ "HottestCourses"|display_page_header }}
</div>
{% for hot_course in hot_courses %}
</div>
{% if hot_course.extra_info.title %}
<div class="span9">
<div class="well_border">
<div class="row">
<div class="span2">
<div class="thumbnail">
<img src="{{ hot_course.extra_info.course_image }}" />
</div>
</div>
<div class="span6">
<div class="categories-course-description">
<h3>{{ hot_course.extra_info.title}}</h3>
<h5>{{ hot_course.extra_info.teachers }}</h5>
{{ hot_course.extra_info.rating_html }}
</div>
<p>
{{ hot_course.extra_info.go_to_course_button }}
{{ hot_course.extra_info.description_button }}
</p>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% include 'default/layout/hot_course_item.tpl' %}
</div>
</section>
{% endif %}

@ -13,7 +13,6 @@
</div>
{% endif %}
{% if profiles is not null %}
<div class="skills-profiles">
<h3>{{"SkillProfiles"|get_lang}}</h3>

@ -140,14 +140,14 @@ bright red for missing skills, in the "Required skills" view for a student when
//If user achieved that skill
if (d.achieved) {
return_fill = 'cornflowerblue';
//return_stroke = '#FCD23A';
return_fill = '#3A87AD';
//return_stroke = '#FCD23A';
}
//darkblue
//If the skill has a gradebook attached
if (d.skill_has_gradebook) {
return_fill = '#FEF664';
if (d.skill_has_gradebook) {
return_fill = '#F89406';
//return_stroke = 'grey';
}

@ -215,8 +215,7 @@ function add_skill_in_profile_list(skill_id, skill_name) {
}
function toogle_save_profile_form() {
//Hiding showing the save this search
//Hiding showing the save this search
if ($('#profile_search li').length == 0) {
$('#profile-options-container').hide();
} else {
@ -380,15 +379,14 @@ $(document).ready(function() {
success:function(data) {
if (data == 1 ) {
update_my_saved_profiles();
alert("{{"Saved"|get_lang}}");
alert("{{ "Saved"|get_lang }}");
} else {
alert("{{ "Error"|get_lang }}");
}
$("#dialog-form-profile").dialog("close");
$("#name").attr('value', '');
$("#description").attr('value', '');
$("#description").attr('value', '');
}
});
}
@ -443,7 +441,7 @@ $(document).ready(function() {
</select>
<br /><br />
<div class="btn-group">
<a class="btn load_root" rel="1" href="#">{{ "Root"|get_lang }}</a>
<a class="btn load_root" rel="1" href="#">{{ "SkillRoot"|get_lang }}</a>
<!-- <a id="clear_selection" class="btn">{{ "Clear"|get_lang }}</a> -->
</div>
<ul id="skill_holder" class="holder holder_simple">
@ -461,17 +459,20 @@ $(document).ready(function() {
<input class="btn" type="submit" value="{{ "SearchProfileMatches"|get_lang }}">
</form>
<div id="profile-options-container" style="display:none">
<div id="profile-options-container" style="display:none">
{{ 'IsThisWhatYouWereLookingFor'|get_lang }}
<form id="save_profile_form_button" class="form-search">
<input class="btn" type="submit" value="{{ "SaveThisSearch"|get_lang }}">
</form>
</div>
</div>
<div id="saved_profiles">
</div>
<br />
<h3>{{ "Legend"|get_lang }}</h3>
<span class="label label-warning">{{ "SkillsYouCanLearn"|get_lang }}</span><br />
<span class="label label-important">{{ "SkillsSearchedFor"|get_lang }}</span><br />
</div>
</div>
@ -554,5 +555,4 @@ $(document).ready(function() {
</div>
</fieldset>
</form>
</div>
</div>

@ -51,8 +51,7 @@ function fill_skill_search_li(skill_id, skill_name, checked) {
checked_condition = '';
if (checked == 1) {
checked_condition = 'checked=checked';
}
}
return '<li><a href="#" class="load_wheel" rel="'+skill_id+'">'+skill_name+'</a></li>';
}
@ -61,7 +60,7 @@ function load_skill_info(skill_id) {
$.ajax({
url: url+'&a=get_skill_course_info&id='+skill_id,
async: false,
success: function(data) {
success: function(data) {
$('#skill_info').html(data);
return data;
}
@ -77,6 +76,7 @@ $(document).ready(function() {
skill_name = $(this).attr('name');
add_skill_in_profile_list(skill_id, skill_name);
});
/* URL link when searching skills */
$("#skill_holder").on("click", "a.load_wheel", function() {
@ -93,10 +93,23 @@ $(document).ready(function() {
load_nodes(skill_id, main_depth);
});
/*$("#skill_search").on("click", "a#clear_selection", function() {
});*/
$("#skill_info").on("click", "a.course_description_popup", function() {
course_code = $(this).attr('rel');
$.ajax({
url: url+'&a=get_course_info_popup&code='+course_code,
async: false,
success: function(data) {
$('#course_info').html(data);
$("#dialog-course-info").dialog({
close: function() {
$('#course_info').html('');
}
});
$("#dialog-course-info").dialog("open");
}
});
});
/* Wheel skill popup form */
@ -155,17 +168,15 @@ $(document).ready(function() {
height : 550
});
//Save search profile dialog
$("#dialog-form-profile").dialog({
//Open dialog
$("#dialog-course-info").dialog({
autoOpen: false,
modal : true,
width : 500,
height : 400
});
width : 550,
height : 250
});
load_nodes(0, main_depth);
load_nodes(0, main_depth);
function open_popup(skill_id, parent_id) {
//Cleaning selected
@ -289,7 +300,7 @@ $(document).ready(function() {
</select>
<br /><br />
<div class="btn-group">
<a class="btn load_root" rel="1" href="#">{{ "Root"|get_lang }}</a>
<a class="btn load_root" rel="1" href="#">{{ "SkillRoot"|get_lang }}</a>
<!-- <a id="clear_selection" class="btn">{{ "Clear"|get_lang }}</a> -->
</div>
<ul id="skill_holder" class="holder holder_simple">
@ -298,11 +309,16 @@ $(document).ready(function() {
<h3>{{ 'SkillInfo'|get_lang }}</h3>
<hr>
<hr>
<div id="skill_info">
</div>
<br />
<h3>{{ "Legend"|get_lang }}</h3>
<span class="label label-warning">{{ "SkillsYouCanLearn"|get_lang }}</span><br />
<span class="label label-important">{{ "SkillsSearchedFor"|get_lang }}</span><br />
<span class="label label-info">{{ "SkillsYouAcquired"|get_lang }}</span><br />
</div>
</div>
@ -313,3 +329,9 @@ $(document).ready(function() {
</div>
</div>
</div>
<div id="dialog-course-info" style="display:none;">
<div id="course_info">
</div>
</div>
Loading…
Cancel
Save