Skip to content
Snippets Groups Projects
Commit 42e2f138 authored by Lea's avatar Lea
Browse files

tracker_js_features

parent 072285df
No related branches found
No related tags found
No related merge requests found
/** /**
* Handle add/remove competency links. * Handle add/remove competency links.
* *
* @module block/career * @module block_career/suivi
* @package career * @package block_career
* @copyright 2021 Léa Marais * @copyright 2021 Léa Marais
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
define(['jquery', 'core/ajax', 'core/templates', 'core/str'], define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
function($, ajax, templates, str) { function($, ajax, templates, str) {
var all_selected=false; var all_selected=false;
var data=[]; var data=[];
return{ return{
registerFilters:function(){ registerFilters:function(){
$("#path-select").on('change', function(e){
$("#path-select").on('change', function(e){ changePath();
changePath(); });
});
}, },
}
function getOption(){
return ("#path-select").val();
} }
function getCompleteUrl(){
url=window.location.search;
urlParams = new URLSearchParams(url); function getCompleteUrl(){
courseid=urlParams.get('courseid'); url=window.location.search;
pathid=urlParams.get('courseid'); urlParams = new URLSearchParams(url);
if (!pathid){ courseid=urlParams.get('courseid');
pathid=$("#path-select").val(); completeUrl='career_tracker.php?courseid='+courseid;
} return completeUrl;
completeUrl='career_tracker.php?courseid='+courseid+'&pathid='+pathid; }
return completeUrl;
} function changePath(){
function changeGroup(){ var select = $("#path-select").val();
completeUrl=getCompleteUrl(); var completeUrl=getCompleteUrl();
loadMessage("loading"); $.ajax({
$.ajax({ url: completeUrl, url: completeUrl,
data: {action: 'test'}, data: {pathid : select},
type: 'post', type: 'post',
success: function(request) { success: function(request) {
console.log(JSON.parse(request)); $("#tracker").html(request);
changeCompletion();
//reloadTable(JSON.parse(request));
}
});
} }
function reloadTable(params){ });
console.log(params); }
url=getCompleteUrl(); });
templates.render('block_career/career_table_tracker', params) \ No newline at end of file
.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
...@@ -31,7 +31,7 @@ require_login($course, false, NULL); ...@@ -31,7 +31,7 @@ require_login($course, false, NULL);
$PAGE->set_title(get_string('title_plugin', 'block_career')); $PAGE->set_title(get_string('title_plugin', 'block_career'));
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline')); $PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
echo $OUTPUT->header();
// echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">"; // echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">";
//$content = new view_career_list(); //$content = new view_career_list();
...@@ -40,10 +40,12 @@ if(!empty($id_path)){ ...@@ -40,10 +40,12 @@ if(!empty($id_path)){
$renderer->get_tracker($id_path); $renderer->get_tracker($id_path);
} }
else{ else{
$PAGE->requires->js("/blocks/career/js/suivi_career.js"); //$PAGE->requires->js("/blocks/career/js/suivi_career.js");
//$id_path=getOption(); //$id_path=getOption();
//print_r($_GET['pathfilter']); //print_r($_GET['pathfilter']);
//ici une valeur de parcours en brut pour pas avoir d'erreurs au chargement de la page //ici une valeur de parcours en brut pour pas avoir d'erreurs au chargement de la page
echo $OUTPUT->header();
$renderer->get_tracker(1); $renderer->get_tracker(1);
echo $OUTPUT->footer();
} }
echo $OUTPUT->footer();
console.log('Test');
\ No newline at end of file
<h2>{{track}}</h2> <div id="tracker"><h2>{{track}}</h2>
{{^isset}} {{^isset}}
<form style="clear: right;" class="form-inline" action="" method="GET"> <form style="clear: right;" class="form-inline" action="" method="GET">
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
</form> </form>
{{/isset}} {{/isset}}
<table id="suivi"> <table id="suivi">
<thead style ="height:100%;width:150%;overflow-x: hidden; "> <thead style ="height:100%;width:150%;overflow-x: hidden; ">
<tr id="modules"> <tr id="modules">
...@@ -62,3 +64,12 @@ ...@@ -62,3 +64,12 @@
{{/students}} {{/students}}
</tbody> </tbody>
</table> </table>
</div>
{{#js}}
require(['block_career/suivi'], function(module) {
module.registerFilters();
});
{{/js}}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment