Prechádzať zdrojové kódy

Improving skill profile see #1791

Julio Montoya 12 rokov pred
rodič
commit
0b94f9bc04

+ 26 - 3
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();

+ 6 - 0
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)
      */

+ 22 - 13
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 = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />';
 

+ 10 - 1
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');
     }
 }

+ 54 - 32
main/template/default/skill/profile.tpl

@@ -1,7 +1,7 @@
-<script type="text/javascript">
+<script>
 $(document).ready( function() {     
     
-    $("#skills").fcbkcomplete({
+    /*$("#skills").fcbkcomplete({
         json_url: "{{url}}?a=find_skills",
         cache: false,
         filter_case: false,
@@ -12,11 +12,11 @@ $(document).ready( function() {
         onselect:"check_skills",
         filter_selected: true,
         newel: true
-    });
+    });*/
     
     
     //Open dialog
-    $("#dialog-form").dialog({
+    /*$("#dialog-form").dialog({
         autoOpen: false,
         modal   : true, 
         width   : 550, 
@@ -48,7 +48,7 @@ $(document).ready( function() {
             $("#name").attr('value', '');
             $("#description").attr('value', '');                
         }
-    });
+    });*/
 
     $("#add_profile").click(function() {
         $("#name").attr('value', '');
@@ -95,7 +95,9 @@ function checkLength( o, n, min, max ) {
     }
 }    
 </script>
-{{form}}
+{{ form }}
+
+
 
 {% if search_skill_list is not null %}    
     <div class="skills-skills">
@@ -127,34 +129,54 @@ function checkLength( o, n, min, max ) {
 {% endif %}
 
 {% if order_user_list is not null %}
-    <div class="skills-users">
     {% for count, user_list in order_user_list %}
-        <h2> {{"Matches"|get_lang}} {{count}}/{{total_search_skills}} </h2>
+        <div class="row-fluid">
+            <div class="span12">  
+            <div class="page-header">
+                <h2>
+                {% if count == total_search_skills %}
+                    {{ "CompleteMatch"|get_lang }}
+                {% else %}
+                    {% if count == 1 %}
+                        {{ "MissingOneStepToMatch"|get_lang }}</h2>
+                    {% else %}
+                        {{ "MissingXStepsToMatch"|get_lang | format(total_search_skills - count)}}                        
+                    {% endif %}        
+                {% endif %}
+                </h2>
+                    
+            </div>
+            </div>
+        </div>
+
+        <div class="row-fluid">
         {% for user in user_list %}
-            <div class="ui-widget" style="width:400px">
-                <div class="ui-widget-header">                    
-                    <h3>
-                        <img src="{{user.user.avatar_small}}" /> {{user['user'].complete_name}} ({{user['user'].username}})
-                    </h3>
-                </div>
-                <div class="ui-widget-content ">
-                    <h4>{{"Skills"|get_lang}} {{user.total_found_skills}} / {{total_search_skills}}</h4>
-                    <ul>                
-                        {% for skill_data in user.skills %}                 
-                            <li>
-                                {% if skill_list[skill_data.skill_id].name is not null %}                                    
-                                    <span class="label_tag skill">{{skill_list[skill_data.skill_id].name}}</span>
-                                {% else %} 
-                                    {{"SkillNotFound"|get_lang}}
-                                {% endif %}
-                                {# if $skill_data.found 
-                                     IHaveThisSkill"|get_lang
-                                #}
-                            </li>
-                        {% endfor %}
-                    </ul>
-                </div>    
-            </div>  
+            <div class="span4">
+                <div class="well">
+                    <div class="ui-widget-header">                    
+                        <h3>
+                            <img src="{{user.user.avatar_small}}" /> {{user['user'].complete_name}} ({{user['user'].username}})
+                        </h3>
+                    </div>
+                    <div class="ui-widget-content ">
+                        <h4>{{ "Skills"|get_lang }} {{ user.total_found_skills }} / {{ total_search_skills }}</h4>
+                        <ul>                
+                            {% for skill_data in user.skills %}                 
+                                <li>
+                                    {% if skill_list[skill_data.skill_id].name is not null %}                                    
+                                        <span class="label_tag skill">{{skill_list[skill_data.skill_id].name}}</span>
+                                    {% else %} 
+                                        {{ "SkillNotFound"|get_lang }}
+                                    {% endif %}
+                                    {# if $skill_data.found 
+                                         IHaveThisSkill"|get_lang
+                                    #}
+                                </li>
+                            {% endfor %}
+                        </ul>
+                    </div>    
+                </div> 
+            </div>
         {% endfor %}
     {% endfor %}
     </div>

+ 62 - 47
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('<li class="bit-box" id="profile_match_item_'+skill_id+'">'+skill_name+'  <a rel="'+skill_id+'" class="closebutton" href="#"></a> </li>');        
-        } 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('<div id="skill_wheel"></div>');
         
         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