Adding links, fixing widths adding documentation see BT#1631

skala
Julio Montoya 14 years ago
parent 0ab621c58d
commit a1aa4228d2
  1. 48
      main/exercice/exercise.lib.php
  2. 16
      main/inc/ajax/course_home.ajax.php
  3. 27
      main/inc/lib/display.lib.php
  4. 2
      main/inc/lib/events.lib.inc.php
  5. 37
      main/session/index.php

@ -1136,7 +1136,12 @@ function convert_score($score, $weight) {
return $score_rounded;
}
/**
* Getting all exercises from a course
* @param array course data
* @param int session id
* @return array exercise data
*/
function get_all_exercises($course_info = null, $session_id = 0) {
if(!empty($course_info)) {
$TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST,$course_info['db_name']);
@ -1157,15 +1162,24 @@ function get_all_exercises($course_info = null, $session_id = 0) {
}
/**
* Gets the position of the score based in my score (result/weight) and the exe_id
* Gets the position of the score based in a given score (result/weight) and the exe_id
* @param float user score to be compared
* @param int exe id of the exercise (this is necesary becase if 2 students have the same score the one with the minor exe_id will have a best position)
* @param int exercise id
* @param string course code
* @param int session id
* @return int the position of the user between his friends in a course (or course within a session)
*/
function get_exercise_result_ranking($my_score, $my_exe_id, $exercise_id, $course_code, $session_id = 0) {
//Getting all exercise results
if (empty($session_id)) {
$session_id = 0;
}
$user_results = get_all_exercise_results($exercise_id, $course_code, $session_id);
if (empty($user_results)) {
return 1;
} else {
$ranking = 1;
$position = 1;
$my_ranking = array();
foreach($user_results as $result) {
//print_r($result);
@ -1177,22 +1191,18 @@ function get_exercise_result_ranking($my_score, $my_exe_id, $exercise_id, $cours
}
asort($my_ranking);
$position = count($my_ranking);
foreach($my_ranking as $exe_id=>$ranking) {
if ($my_score >= $ranking) {
if ($my_score == $ranking) {
if ($my_exe_id < $exe_id) {
$position--;
if (!empty($my_ranking))
foreach($my_ranking as $exe_id=>$ranking) {
if ($my_score >= $ranking) {
if ($my_score == $ranking) {
if ($my_exe_id < $exe_id) {
$position--;
}
} else {
$position--;
}
} else {
$position--;
}
}
}
//echo $position;
}
}
return $position;
}
}
}

@ -105,14 +105,14 @@ switch ($action) {
$count = 0;
foreach ($course_list as $item) {
foreach ($course_list as $item) {
$list = new LearnpathList(api_get_user_id(),$item['code']);
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>'_blank'));
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$temp[$count]['cell']=array($lp_item['publicated_on'], $item['code'], $lp_item['lp_name']);
$temp[$count]['id']= $lp_id;
$temp[$count]['cell']=array(substr($lp_item['publicated_on'], 0,10), $item['title'], $lp_item['lp_name']);
$count++;
}
}
@ -175,10 +175,12 @@ switch ($action) {
$list = new LearnpathList(api_get_user_id(),$item['code']);
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>'_blank'));
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$temp[$count]['cell']=array(get_week_from_day($lp_item['publicated_on']), $lp_item['publicated_on'], $item['code'], $lp_item['lp_name']);
$temp[$count]['cell']=array(get_week_from_day($lp_item['publicated_on']), substr($lp_item['publicated_on'], 0,10), $item['title'], $lp_item['lp_name']);
$count++;
}
}
@ -240,10 +242,10 @@ switch ($action) {
$list = new LearnpathList(api_get_user_id(),$item['code']);
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>'_blank'));
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$temp[$count]['cell']=array($lp_item['publicated_on'], $item['code'], $lp_item['lp_name']);
$temp[$count]['cell']=array(substr($lp_item['publicated_on'], 0,10), $item['title'], $lp_item['lp_name']);
$count++;
}
}

@ -758,11 +758,11 @@ class Display {
* Requirements: declare the jquery, jquery-ui libraries + the jquery-ui.css in the $htmlHeadXtra variable before the display_header
* Add this script
* @example
* <script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
* <script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
* @param array list of the tab titles
* @param array content that will be showed
* @param string the id of the container of the tab in the example "tabs"
@ -798,7 +798,7 @@ class Display {
}
/**
*
* Displays the html needed by the grid_js function
*/
public static function grid_html($div_id){
$table = self::tag('table','',array('id'=>$div_id));
@ -806,9 +806,10 @@ class Display {
return $table;
}
/**
* This is just a wrapper to use the jqgrid For the other options go here http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
* This function need to be in the ready jquery function --> $(function() { }
/**
* This is just a wrapper to use the jqgrid For the other options go here http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
* This function need to be in the ready jquery function example --> $(function() { <?php echo Display::grid_js('grid' ...); ?> }
* In order to work this function needs the Display::grid_html function with the same div id
* @param string div id
* @param string url where the jqgrid will ask for data
* @param array Visible columns (you should use get_lang). An array in which we place the names of the columns. This is the text that appears in the head of the grid (Header layer). Example: colname {name:'date', index:'date', width:120, align:'right'},
@ -868,13 +869,15 @@ class Display {
$obj->data = $data_var;
$obj->datatype = 'local';
$json.="\n";
}
}
$json_encode = json_encode($obj);
if (!empty($data)) {
//Converts the "data":"js_variable" to "data":js_variable
$json_encode = str_replace('"data":"'.$data_var.'"','"data":'.$data_var.'',$json_encode);
$json_encode = str_replace('"data":"'.$data_var.'"','"data":'.$data_var.'',$json_encode);
}
//Fixing true/false js values that doesn't need the ""
$json_encode = str_replace(':"true"',':true',$json_encode);
$json_encode = str_replace(':"false"',':false',$json_encode);
$json .= '$("#'.$div_id.'").jqGrid(';
$json .= $json_encode;

@ -700,7 +700,7 @@ function get_all_exercise_results($exercise_id, $course_code, $session_id = 0) {
}
/**
* Gets all exercise results (NO Exercises in LPs )from a given exercise id, course, session
* Gets all exercise results (NO Exercises in LPs) from a given exercise id, course, session
* @param int exercise id
* @param string course code
* @param int session id

@ -194,31 +194,42 @@ foreach($final_array as $session_data) {
}
//echo '<pre>';print_r($my_real_array) ;
//Default grid settings
//All Learnpaths grid settings (First tab, first subtab)
$url = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_default&session_id='.$session_id;
$columns = array('Date','Course', 'LP');
$column_model = array(array('name'=>'date', 'index'=>'date', 'width'=>'120', 'align'=>'right'),
array('name'=>'course', 'index'=>'course', 'width'=>'120', 'align'=>'right'),
array('name'=>'lp', 'index'=>'lp', 'width'=>'120', 'align'=>'right'));
$column_model = array(array('name'=>'date', 'index'=>'date', 'width'=>'80', 'align'=>'left'),
array('name'=>'course', 'index'=>'course', 'width'=>'500', 'align'=>'left'),
array('name'=>'lp', 'index'=>'lp', 'width'=>'200', 'align'=>'center'));
//Course grid settings
$extra_params['autowidth'] = 'true'; //use the width of the parent
//$extra_params['forceFit'] = 'true'; //use the width of the parent
//$extra_params['altRows'] = 'true'; //zebra style
//Per course grid settings
$url_course = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_by_course&session_id='.$session_id;
$extra_params_course['grouping'] = 'true';
$extra_params_course['groupingView'] = array('groupField'=>array('course'),
'groupColumnShow'=>array('false'),
'groupText' => array('<b>Course {0} - {1} Item(s)</b>'));
$extra_params_course['autowidth'] = 'true'; //use the width of the parent
//Week grid
//Per Week grid
$url_week = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_by_week&session_id='.$session_id;
$column_week = array('Week','Date','Course', 'LP');
$column_week_model =array(array('name'=>'week', 'index'=>'week', 'width'=>'120', 'align'=>'right'),
array('name'=>'date', 'index'=>'date', 'width'=>'120', 'align'=>'right'),
array('name'=>'course', 'index'=>'course', 'width'=>'120', 'align'=>'right'),
array('name'=>'lp', 'index'=>'lp', 'width'=>'120', 'align'=>'right'));
$column_week_model =array(array('name'=>'week', 'index'=>'week', 'width'=>'80', 'align'=>'left'),
array('name'=>'date', 'index'=>'date', 'width'=>'80', 'align'=>'right'),
array('name'=>'course', 'index'=>'course', 'width'=>'500', 'align'=>'left'),
array('name'=>'lp', 'index'=>'lp', 'width'=>'200', 'align'=>'center'));
$extra_params_week['grouping'] = 'true';
$extra_params_week['groupingView'] = array('groupField'=>array('week'),
'groupColumnShow'=>'false',
'groupText' => array('<b>Week {0} - {1} Item(s)</b>'));
$extra_params_week['autowidth'] = 'true'; //use the width of the parent
//MyQCM grid
$column_exercise = array(get_lang('Course'),get_lang('Exercise'), get_lang('Attempt').' #', get_lang('Result'), get_lang('Note'), get_lang('Position'));
$column_exercise_model = array(array('name'=>'course', 'index'=>'course', 'width'=>'450', 'align'=>'left','sortable'=>'false'),
@ -230,6 +241,8 @@ $column_exercise_model = array(array('name'=>'course', 'index'=>'course',
);
$extra_params_exercise['grouping'] = 'true';
$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>Course {0} - {1} Item(s)</b>'));
//$extra_params_exercise['altRows'] = 'true';
?>
<br />
@ -243,7 +256,7 @@ $(function() {
$( "#tabs" ).tabs();
$( "#sub_tab" ).tabs();
<?php
echo Display::grid_js('list_default', $url, $columns,$column_model);
echo Display::grid_js('list_default', $url, $columns,$column_model,$extra_params);
echo Display::grid_js('list_course', $url_course, $columns,$column_model,$extra_params_course);
echo Display::grid_js('list_week', $url_week, $column_week,$column_week_model, $extra_params_week);
echo Display::grid_js('exercises', '', $column_exercise,$column_exercise_model, $extra_params_exercise, $my_real_array);
@ -259,7 +272,7 @@ $(function() {
$headers = array(get_lang('LearningPaths'), get_lang('MyQCM'), get_lang('MyResults'));
$sub_header = array(get_lang('AllLearningPaths'), get_lang('PerWeek'), get_lang('ByCourse'));
$tabs = Display::tabs($sub_header, array(Display::grid_html('list_default'), Display::grid_html('list_week'), Display::grid_html('list_course')),'sub_tab');
echo Display::tabs($headers, array($tabs, Display::grid_html('exercises'),'ccc'));
echo Display::tabs($headers, array($tabs, Display::grid_html('exercises'),$my_reporting));
// Footer
Display :: display_footer();
Loading…
Cancel
Save