skill_wheel_student.tpl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. {% include app.template_style ~ '/skill/skill_wheel.js.tpl' %}
  2. <script>
  3. /* Skill search input in the left menu */
  4. function check_skills_sidebar() {
  5. //Selecting only selected skills
  6. $("#skill_id option:selected").each(function() {
  7. var skill_id = $(this).val();
  8. if (skill_id != "" ) {
  9. $.ajax({
  10. url: "{{ url }}&a=skill_exists",
  11. data: "skill_id="+skill_id,
  12. // async: false,
  13. success: function(return_value) {
  14. if (return_value == 0 ) {
  15. alert("{{ 'SkillDoesNotExist'|get_lang }}");
  16. //Deleting select option tag
  17. //$("#skill_id option[value="+skill_id+"]").remove();
  18. $("#skill_id").empty();
  19. //Deleting holder
  20. $("#skill_search .holder li").each(function () {
  21. if ($(this).attr("rel") == skill_id) {
  22. $(this).remove();
  23. }
  24. });
  25. } else {
  26. $("#skill_id option[value="+skill_id+"]").remove();
  27. //Deleting holder
  28. $("#skill_search .holder li").each(function () {
  29. if ($(this).attr("rel") == skill_id) {
  30. $(this).remove();
  31. }
  32. });
  33. if ($('#skill_to_select_id_'+skill_id).length == 0) {
  34. skill_info = get_skill_info(skill_id);
  35. li = fill_skill_search_li(skill_id, skill_info.name);
  36. $("#skill_holder").append(li);
  37. }
  38. }
  39. },
  40. });
  41. }
  42. });
  43. }
  44. function fill_skill_search_li(skill_id, skill_name, checked) {
  45. checked_condition = '';
  46. if (checked == 1) {
  47. checked_condition = 'checked=checked';
  48. }
  49. return '<li><a id="skill_to_select_id_'+skill_id+'" href="#" class="load_wheel" rel="'+skill_id+'">'+skill_name+'</a></li>';
  50. }
  51. function load_skill_info(skill_id) {
  52. $.ajax({
  53. url: url+'&a=get_skill_course_info&id='+skill_id,
  54. async: false,
  55. success: function(data) {
  56. $('#skill_info').html(data);
  57. return data;
  58. }
  59. });
  60. }
  61. function load_my_skills() {
  62. $.ajax({
  63. url: url+'&a=get_user_skills&user_id='+{{ _u.user_id}},
  64. //async: false,
  65. success: function(data) {
  66. $('#my_skills').html(data);
  67. }
  68. });
  69. }
  70. $(document).ready(function() {
  71. /* Skill search */
  72. /* Skill item list onclick */
  73. $("#skill_holder").on("click", "input.skill_to_select", function() {
  74. skill_id = $(this).attr('rel');
  75. skill_name = $(this).attr('name');
  76. add_skill_in_profile_list(skill_id, skill_name);
  77. });
  78. /* URL link when searching skills */
  79. $("#skill_holder").on("click", "a.load_wheel", function() {
  80. skill_id = $(this).attr('rel');
  81. skill_to_load_from_get = 0;
  82. load_nodes(skill_id, main_depth);
  83. load_skill_info(skill_id);
  84. });
  85. /* URL link when searching skills */
  86. $("#skill_search").on("click", "a.load_root", function() {
  87. skill_id = $(this).attr('rel');
  88. skill_to_load_from_get = 0;
  89. load_nodes(skill_id, main_depth);
  90. });
  91. /* When clicking in a course title */
  92. $("#skill_info").on("click", "a.course_description_popup", function() {
  93. course_code = $(this).attr('rel');
  94. $.ajax({
  95. url: url+'&a=get_course_info_popup&code='+course_code,
  96. async: false,
  97. success: function(data) {
  98. $('#course_info').html(data);
  99. $("#dialog-course-info").dialog({
  100. close: function() {
  101. $('#course_info').html('');
  102. }
  103. });
  104. $("#dialog-course-info").dialog("open");
  105. }
  106. });
  107. });
  108. /* Wheel skill popup form */
  109. /* Close button in gradebook select */
  110. $("#gradebook_holder").on("click", "a.closebutton", function() {
  111. gradebook_id = $(this).attr('rel');
  112. skill_id = $('#id').attr('value');
  113. delete_gradebook_from_skill(skill_id, gradebook_id);
  114. });
  115. $("#skill_id").fcbkcomplete({
  116. json_url: "{{ url }}&a=find_skills",
  117. cache: false,
  118. filter_case: false,
  119. filter_hide: true,
  120. complete_text:"{{ 'StartToType' | get_lang }}",
  121. firstselected: true,
  122. //onremove: "testme",
  123. onselect:"check_skills_sidebar",
  124. filter_selected: true,
  125. newel: true
  126. });
  127. $("#parent_id").fcbkcomplete({
  128. json_url: "{{ url }}&a=find_skills",
  129. cache: false,
  130. filter_case: false,
  131. filter_hide: true,
  132. complete_text:"{{ 'StartToType' | get_lang }}",
  133. firstselected: true,
  134. //onremove: "testme",
  135. onselect:"check_skills_edit_form",
  136. filter_selected: true,
  137. newel: true
  138. });
  139. $("#gradebook_id").fcbkcomplete({
  140. json_url: "{{ url }}&a=find_gradebooks",
  141. cache: false,
  142. filter_case: false,
  143. filter_hide: true,
  144. complete_text:"{{ 'StartToType' | get_lang }}",
  145. firstselected: true,
  146. //onremove: "testme",
  147. onselect:"check_gradebook",
  148. filter_selected: true,
  149. newel: true
  150. });
  151. //Open dialog
  152. $("#dialog-form").dialog({
  153. autoOpen: false,
  154. modal : true,
  155. width : 600,
  156. height : 550
  157. });
  158. //Open dialog
  159. $("#dialog-course-info").dialog({
  160. autoOpen: false,
  161. modal : true,
  162. width : 550,
  163. height : 250
  164. });
  165. load_nodes(0, main_depth);
  166. load_my_skills();
  167. function open_popup(skill_id, parent_id) {
  168. //Cleaning selected
  169. $("#gradebook_id").find('option').remove();
  170. $("#parent_id").find('option').remove();
  171. $("#gradebook_holder").find('li').remove();
  172. $("#skill_edit_holder").find('li').remove();
  173. var skill = false;
  174. if (skill_id) {
  175. skill = get_skill_info(skill_id);
  176. }
  177. var parent = false;
  178. if (parent_id) {
  179. parent = get_skill_info(parent_id);
  180. }
  181. if (skill) {
  182. var parent_info = get_skill_info(skill.extra.parent_id);
  183. $("#id").attr('value', skill.id);
  184. $("#name").attr('value', skill.name);
  185. $("#short_code").attr('value', skill.short_code);
  186. $("#description").attr('value', skill.description);
  187. //Filling parent_id
  188. $("#parent_id").append('<option class="selected" value="'+skill.extra.parent_id+'" selected="selected" >');
  189. $("#skill_edit_holder").append('<li class="bit-box">'+parent_info.name+'</li>');
  190. //Filling the gradebook_id
  191. jQuery.each(skill.gradebooks, function(index, data) {
  192. $("#gradebook_id").append('<option class="selected" value="'+data.id+'" selected="selected" >');
  193. $("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
  194. });
  195. $("#dialog-form").dialog({
  196. buttons: {
  197. "{{ "Edit"|get_lang }}" : function() {
  198. var params = $("#add_item").find(':input').serialize();
  199. add_skill(params);
  200. },
  201. /*"{{ "Delete"|get_lang }}" : function() {
  202. },*/
  203. "{{ "CreateChildSkill"|get_lang }}" : function() {
  204. open_popup(0, skill.id);
  205. },
  206. "{{ "AddSkillToProfileSearch"|get_lang }}" : function() {
  207. add_skill_in_profile_list(skill.id, skill.name);
  208. }
  209. },
  210. close: function() {
  211. $("#name").attr('value','');
  212. $("#description").attr('value', '');
  213. //Redirect to the main root
  214. load_nodes(0, main_depth);
  215. }
  216. });
  217. $("#dialog-form").dialog("open");
  218. }
  219. }
  220. });
  221. </script>
  222. <div class="container-fluid">
  223. <div class="row-fluid">
  224. <div class="span3">
  225. <div class="well sidebar-nav-skill-wheel ">
  226. <div class="page-header">
  227. <h3>{{ 'MySkills'|get_lang }}</h3>
  228. </div>
  229. <div id="my_skills">
  230. </div>
  231. <div class="page-header">
  232. <h3>{{ 'GetNewSkills'|get_lang }}</h3>
  233. </div>
  234. <form id="skill_search" class="form-search">
  235. <select id="skill_id" name="skill_id" />
  236. </select>
  237. <br /><br />
  238. <div class="btn-group">
  239. <a class="btn load_root" rel="0" href="#">{{ "SkillRoot"|get_lang }}</a>
  240. </div>
  241. <ul id="skill_holder" class="holder holder_simple">
  242. </ul>
  243. </form>
  244. <div class="page-header">
  245. <h3>{{ 'SkillInfo'|get_lang }}</h3>
  246. </div>
  247. <div id="skill_info">
  248. </div>
  249. <div class="page-header">
  250. <h3>{{ "Legend"|get_lang }}</h3>
  251. </div>
  252. <span class="label label-info">{{ "SkillsYouAcquired"|get_lang }}</span><br />
  253. <span class="label label-warning">{{ "SkillsYouCanLearn"|get_lang }}</span><br />
  254. <span class="label label-important">{{ "SkillsSearchedFor"|get_lang }}</span><br /><br />
  255. <div><a class="btn btn-small" href="{{ _p.web }}user_portal.php">{{ "ReturnToCourseList"|get_lang }}</a></div>
  256. </div>
  257. </div>
  258. <div id="wheel_container" class="span9">
  259. <div id="skill_wheel">
  260. <img src="">
  261. </div>
  262. </div>
  263. </div>
  264. <div id="dialog-course-info" style="display:none;">
  265. <div id="course_info">
  266. </div>
  267. </div>