diff --git a/main/inc/ajax/skill.ajax.php b/main/inc/ajax/skill.ajax.php index 96870fd071..d3fb3f7a98 100644 --- a/main/inc/ajax/skill.ajax.php +++ b/main/inc/ajax/skill.ajax.php @@ -36,10 +36,15 @@ switch ($action) { break; case 'profile_matches': $skill_rel_user = new SkillRelUser(); - $skills = $_REQUEST['skills']; + $skills = $_REQUEST['skill_id']; + + $total_skills_to_search = $skills; + $users = $skill_rel_user->get_user_by_skills($skills); - $total_skills_to_search = array(); + $user_list = array(); + + $count_skills = count($skills); if (!empty($users)) { foreach ($users as $user) { @@ -62,7 +67,7 @@ switch ($action) { $user_list[$user['user_id']]['total_found_skills'] = $found_counts; } $ordered_user_list = array(); - foreach($user_list as $user_id => $user_data) { + foreach ($user_list as $user_id => $user_data) { $ordered_user_list[$user_data['total_found_skills']][] = $user_data; } if (!empty($ordered_user_list)) { @@ -70,6 +75,24 @@ switch ($action) { } } + + Display::display_no_header(); + + Display::$global_template->assign('order_user_list', $ordered_user_list); + Display::$global_template->assign('total_search_skills', $count_skills); + + $skill_list = array(); + + if (!empty($total_skills_to_search)) { + $total_skills_to_search = $skill->get_skills_info($total_skills_to_search); + + foreach ($total_skills_to_search as $skill_info) { + $skill_list[$skill_info['id']] = $skill_info; + } + } + + Display::$global_template->assign('skill_list', $skill_list); + echo Display::$global_template->fetch('default/skill/profile.tpl'); break; case 'get_gradebooks': $gradebooks = $gradebook_list = $gradebook->get_all(); diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 0cc79b1431..63252efaee 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -72,6 +72,12 @@ class Display { echo self::$global_template ->show_header_template(); } + public static function display_no_header() { + $disable_js_and_css_files = true; + self::$global_template = new Template($tool_name, false, false, $show_learnpath); + //echo self::$global_template->show_header_template(); + } + /** * Displays the reduced page header (without banner) */ diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index e005b01ea7..e111b1b984 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -477,10 +477,13 @@ class Template { } $js_file_to_string = ''; - + + + foreach ($js_files as $js_file) { $js_file_to_string .= api_get_js($js_file); } + //Extra CSS files @@ -498,10 +501,12 @@ class Template { $css_files[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css'; } + $css_file_to_string = ''; foreach ($css_files as $css_file) { $css_file_to_string .= api_get_css($css_file); } + // @todo move this somewhere else. Special fix when using tablets in order to see the text near icons if (SHOW_TEXT_NEAR_ICONS == true) { @@ -532,22 +537,26 @@ class Template { //@todo minify CSS and JS $this->assign('prefetch', $prefetch); - $this->assign('css_file_to_string', $css_file_to_string); - $this->assign('js_file_to_string', $js_file_to_string); - $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-' . $this_section); - - //Adding jquery ui by default - $extra_headers = api_get_jquery_ui_js(); - - //$extra_headers = ''; - if (isset($htmlHeadXtra) && $htmlHeadXtra) { - foreach ($htmlHeadXtra as & $this_html_head) { - $extra_headers .= $this_html_head . "\n"; + + global $disable_js_and_css_files; + + if (!$disable_js_and_css_files) { + $this->assign('css_file_to_string', $css_file_to_string); + $this->assign('js_file_to_string', $js_file_to_string); + + //Adding jquery ui by default + $extra_headers = api_get_jquery_ui_js(); + + //$extra_headers = ''; + if (isset($htmlHeadXtra) && $htmlHeadXtra) { + foreach ($htmlHeadXtra as & $this_html_head) { + $extra_headers .= $this_html_head . "\n"; + } } + $this->assign('extra_headers', $extra_headers); } - $this->assign('extra_headers', $extra_headers); $favico = ''; diff --git a/main/newscorm/lp_upload.php b/main/newscorm/lp_upload.php index 0ac0efc998..0e03e13edd 100644 --- a/main/newscorm/lp_upload.php +++ b/main/newscorm/lp_upload.php @@ -133,12 +133,17 @@ if( Request::is_post() && $is_error){ require_once 'learnpath.class.php'; $type = learnpath::get_package_type($s, basename($s)); + $post_max = ini_get('post_max_size'); + $upl_max = ini_get('upload_max_filesize'); + if (filesize($s)>$post_max || filesize($s)>$upl_max ){ + return api_failure::set_failure('upload_file_too_big'); + } switch ($type) { case 'scorm': require_once 'scorm.class.php'; $oScorm = new scorm(); $manifest = $oScorm->import_local_package($s, $current_dir); - if ($manifest === false ) { //if api_set_failure + if ($manifest === false ) { //if ap i_set_failure return api_failure::set_failure(api_failure::get_last_failure()); } if (!empty($manifest)) { @@ -172,6 +177,10 @@ if( Request::is_post() && $is_error){ break; case '': default: + + if (filesize($s)>$post_max || filesize($s)>$upl_max ){ + return api_failure::set_failure('upload_file_too_big'); + } return api_failure::set_failure('not_a_learning_path'); } } \ No newline at end of file diff --git a/main/template/default/skill/profile.tpl b/main/template/default/skill/profile.tpl index 989817cff0..91693788d6 100644 --- a/main/template/default/skill/profile.tpl +++ b/main/template/default/skill/profile.tpl @@ -1,7 +1,7 @@ - -{{form}} +{{ form }} + + {% if search_skill_list is not null %}
@@ -127,34 +129,54 @@ function checkLength( o, n, min, max ) { {% endif %} {% if order_user_list is not null %} -
{% for count, user_list in order_user_list %} -

{{"Matches"|get_lang}} {{count}}/{{total_search_skills}}

+
+
+ +
+
+ +
{% for user in user_list %} -
-
-

- {{user['user'].complete_name}} ({{user['user'].username}}) -

-
-
-

{{"Skills"|get_lang}} {{user.total_found_skills}} / {{total_search_skills}}

-
    - {% for skill_data in user.skills %} -
  • - {% if skill_list[skill_data.skill_id].name is not null %} - {{skill_list[skill_data.skill_id].name}} - {% else %} - {{"SkillNotFound"|get_lang}} - {% endif %} - {# if $skill_data.found - IHaveThisSkill"|get_lang - #} -
  • - {% endfor %} -
-
-
+
+
+
+

+ {{user['user'].complete_name}} ({{user['user'].username}}) +

+
+
+

{{ "Skills"|get_lang }} {{ user.total_found_skills }} / {{ total_search_skills }}

+
    + {% for skill_data in user.skills %} +
  • + {% if skill_list[skill_data.skill_id].name is not null %} + {{skill_list[skill_data.skill_id].name}} + {% else %} + {{ "SkillNotFound"|get_lang }} + {% endif %} + {# if $skill_data.found + IHaveThisSkill"|get_lang + #} +
  • + {% endfor %} +
+
+
+
{% endfor %} {% endfor %}
diff --git a/main/template/default/skill/skill_wheel.tpl b/main/template/default/skill/skill_wheel.tpl index e333f4ca8b..bcca9cd2c6 100644 --- a/main/template/default/skill/skill_wheel.tpl +++ b/main/template/default/skill/skill_wheel.tpl @@ -192,70 +192,85 @@ function delete_gradebook_from_skill(skill_id, gradebook_id) { }); } - -$(document).ready(function() { - - $("#search_profile_form").submit(function() { - $("#skill_wheel").remove(); - var skill_list=[]; - $("#profile_search li").each(function() { - id = $(this).attr("id"); - if (id) { - console.log(id); - skill_list.push(id); +function submit_profile_search_form() { + $("#skill_wheel").remove(); + var skill_list = {}; + + if ($("#profile_search li").length != 0) { + $("#profile_search li").each(function(index) { + id = $(this).attr("id").split('_')[3]; + if (id) { + skill_list[index] = id; } }); - - skill_list = { 'skill_id': skill_list}; - - skill_params = $.param(skill_list); - console.log(skill_params); - + } + + if (skill_list.length != 0) { + skill_list = { 'skill_id' : skill_list }; + skill_params = $.param(skill_list); + $.ajax({ - url: url+'&a=profile_matches&skills='+skill_params, + url: url+'&a=profile_matches&'+skill_params, async: false, - success: function(json) { - skill = jQuery.parseJSON(json); - return skill; + success: function (html) { + //users = jQuery.parseJSON(users); + $('#wheel_container').html(html); + } - }); - return skill; - - }); + }); + } + //return skill; +} + - $("#skill_holder").on("click", "input.skill_to_select", function() { +$(document).ready(function() { + /* Skill search */ + + /* Skill item list onclick */ + $("#skill_holder").on("click", "input.skill_to_select", function() { skill_id = $(this).attr('rel'); skill_name = $(this).attr('name'); if ($('#profile_match_item_'+skill_id).length == 0 ) { $('#profile_search').append('
  • '+skill_name+'
  • '); - } else { - + } else { $('#profile_match_item_'+skill_id).remove(); } - }); + }); + + /* URL link when searching skills */ + $("#skill_holder").on("click", "a.load_wheel", function() { + skill_id = $(this).attr('rel'); + skill_to_load_from_get = 0; + load_nodes(skill_id, main_depth); + }); - /* Close button in gradebook select */ - $("#gradebook_holder").on("click", "a.closebutton", function() { - gradebook_id = $(this).attr('rel'); - skill_id = $('#id').attr('value'); - delete_gradebook_from_skill(skill_id, gradebook_id); - }); + /* Profile matcher */ - /* Close button in profile matcher */ + + /* Submit button */ + $("#search_profile_form").submit(function() { + submit_profile_search_form(); + }); + + /* Close button in profile matcher items */ $("#profile_search").on("click", "a.closebutton", function() { skill_id = $(this).attr('rel'); $('input[id=skill_to_select_id_'+skill_id+']').attr('checked', false); $('#profile_match_item_'+skill_id).remove(); - }); + submit_profile_search_form(); + }); + - /* URL link when searching skills in the sidebar*/ - $("#skill_holder").on("click", "a.load_wheel", function() { - skill_id = $(this).attr('rel'); - skill_to_load_from_get = 0; - load_nodes(skill_id, main_depth); - }); + /* Wheel skill popup form */ + /* Close button in gradebook select */ + $("#gradebook_holder").on("click", "a.closebutton", function() { + gradebook_id = $(this).attr('rel'); + skill_id = $('#id').attr('value'); + delete_gradebook_from_skill(skill_id, gradebook_id); + }); + $("#skill_id").fcbkcomplete({ json_url: "{{ url }}&a=find_skills", cache: false, @@ -360,7 +375,8 @@ $(document).ready(function() { reduce_top = 1; /* Locate the #div id element */ - $("#skill_wheel").remove(); + $("#skill_wheel").remove(); + $("#wheel_container").html(''); $("#wheel_container").append('
    '); var div = d3.select("#skill_wheel"); @@ -568,8 +584,6 @@ $(document).ready(function() { } function open_popup(d) { - $( "#name" ).attr('value', d.name); - //Cleaning selected $("#gradebook_id").find('option').remove(); $("#parent_id").find('option').remove(); @@ -582,8 +596,9 @@ $(document).ready(function() { if (skill) { var parent_info = get_skill_info(skill.extra.parent_id); + $("#id").attr('value', skill.id); $("#name").attr('value', skill.name); - $("#id").attr('value', skill.id); + $("#short_code").attr('value', skill.short_code); $("#description").attr('value', skill.description); //Filling parent_id