diff --git a/amd/build/suivi.js b/amd/build/suivi.js index f03a00ed7d2859d2c681ae748cd0e2f4e71e0d2d..51bbf349acdf854e90c5a2bc9aa9f40186b4840c 100644 --- a/amd/build/suivi.js +++ b/amd/build/suivi.js @@ -1,67 +1,44 @@ /** * Handle add/remove competency links. * - * @module block/career - * @package career + * @module block_career/suivi + * @package block_career * @copyright 2021 Léa Marais * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], - function($, ajax, templates, str) { - var all_selected=false; - var data=[]; - return{ - registerFilters:function(){ - - $("#path-select").on('change', function(e){ - changePath(); - }); - + function($, ajax, templates, str) { + var all_selected=false; + var data=[]; + return{ + registerFilters:function(){ + $("#path-select").on('change', function(e){ + changePath(); + }); + }, - - - - - } - function getOption(){ - return ("#path-select").val(); } - function getCompleteUrl(){ - url=window.location.search; - urlParams = new URLSearchParams(url); - courseid=urlParams.get('courseid'); - pathid=urlParams.get('courseid'); - if (!pathid){ - pathid=$("#path-select").val(); - } - completeUrl='career_tracker.php?courseid='+courseid+'&pathid='+pathid; - return completeUrl; - } - function changeGroup(){ - completeUrl=getCompleteUrl(); - loadMessage("loading"); - $.ajax({ url: completeUrl, - data: {action: 'test'}, - type: 'post', - success: function(request) { - console.log(JSON.parse(request)); - changeCompletion(); - //reloadTable(JSON.parse(request)); - } - }); + + +function getCompleteUrl(){ + url=window.location.search; + urlParams = new URLSearchParams(url); + courseid=urlParams.get('courseid'); + completeUrl='career_tracker.php?courseid='+courseid; + return completeUrl; +} + +function changePath(){ + var select = $("#path-select").val(); + var completeUrl=getCompleteUrl(); + $.ajax({ + url: completeUrl, + data: {pathid : select}, + type: 'post', + success: function(request) { + $("#tracker").html(request); } - function reloadTable(params){ - console.log(params); - url=getCompleteUrl(); - templates.render('block_career/career_table_tracker', params) - .done(function(html, js){ - console.log("done done"); - $("#partial-table").html(html); - templates.runTemplateJS(js); - window.history.pushState('suivi',"", url); - }) - .fail(function(){ - loadMessage("error"); - }); - } \ No newline at end of file + }); +} +}); \ No newline at end of file diff --git a/career_tracker.php b/career_tracker.php index 4dc8433ade6ec942de70b2a90c74349b76f06368..64b440ca89e6b8f0ac7d6c97d2fceccb9e55396d 100644 --- a/career_tracker.php +++ b/career_tracker.php @@ -31,7 +31,7 @@ require_login($course, false, NULL); $PAGE->set_title(get_string('title_plugin', 'block_career')); $PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); -echo $OUTPUT->header(); + // echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">"; //$content = new view_career_list(); @@ -40,10 +40,12 @@ if(!empty($id_path)){ $renderer->get_tracker($id_path); } else{ - $PAGE->requires->js("/blocks/career/js/suivi_career.js"); + //$PAGE->requires->js("/blocks/career/js/suivi_career.js"); //$id_path=getOption(); //print_r($_GET['pathfilter']); //ici une valeur de parcours en brut pour pas avoir d'erreurs au chargement de la page + echo $OUTPUT->header(); $renderer->get_tracker(1); + echo $OUTPUT->footer(); } -echo $OUTPUT->footer(); + diff --git a/js/suivi_career.js b/js/suivi_career.js deleted file mode 100644 index a767aed6690c5dbc601201436d87d0f33734c4fa..0000000000000000000000000000000000000000 --- a/js/suivi_career.js +++ /dev/null @@ -1 +0,0 @@ -console.log('Test'); \ No newline at end of file diff --git a/templates/career_table_tracker.mustache b/templates/career_table_tracker.mustache index 886ebe443aa6826112f3d8aad43d240ee40c28ea..0a51d862b6b1263b2b5747b29780ecd4bcdc8ec7 100644 --- a/templates/career_table_tracker.mustache +++ b/templates/career_table_tracker.mustache @@ -1,4 +1,5 @@ -<h2>{{track}}</h2> +<div id="tracker"><h2>{{track}}</h2> + {{^isset}} <form style="clear: right;" class="form-inline" action="" method="GET"> @@ -18,6 +19,7 @@ </form> {{/isset}} + <table id="suivi"> <thead style ="height:100%;width:150%;overflow-x: hidden; "> <tr id="modules"> @@ -62,3 +64,12 @@ {{/students}} </tbody> </table> +</div> +{{#js}} +require(['block_career/suivi'], function(module) { + module.registerFilters(); + + + +}); +{{/js}} \ No newline at end of file