Minor - fixing PHP warnings.

1.9.x
Julio Montoya 12 years ago
parent a3e653fb95
commit e9eeddad4e
  1. 28
      main/gradebook/gradebook_add_cat.php
  2. 18
      main/gradebook/index.php
  3. 157
      main/gradebook/lib/fe/gradebooktable.class.php

@ -42,12 +42,12 @@ $(document).ready(function () {
});
$(".closebutton").click(function() {
var skill_id = ($(this).attr("id")).split("_")[1];
if (skill_id) {
$.ajax({
url: "'.api_get_path(WEB_AJAX_PATH).'skill.ajax.php?a=remove_skill",
var skill_id = ($(this).attr("id")).split("_")[1];
if (skill_id) {
$.ajax({
url: "'.api_get_path(WEB_AJAX_PATH).'skill.ajax.php?a=remove_skill",
data: "gradebook_id=' . $edit_cat . '&skill_id="+skill_id,
success: function(return_value) {
success: function(return_value) {
if (return_value == 1 ) {
$("#skill_"+skill_id).remove();
}
@ -100,7 +100,13 @@ if ($_in_course) {
$catadd->set_course_code(api_get_course_id());
$form = new CatForm(CatForm :: TYPE_ADD, $catadd, 'add_cat_form', null, api_get_self() . '?selectcat='.$get_select_cat);
$form = new CatForm(
CatForm :: TYPE_ADD,
$catadd,
'add_cat_form',
null,
api_get_self() . '?selectcat='.$get_select_cat.'&'.api_get_cidreq()
);
if ($form->validate()) {
$values = $form->exportValues();
@ -116,17 +122,18 @@ if ($form->validate()) {
}
} else {
$cat->set_name($values['name']);
$cat->set_course_code($values['course_code']);//?
$cat->set_course_code($values['course_code']);
}
$cat->set_session_id(api_get_session_id());
//Always add the gradebook to the course
$cat->set_course_code(api_get_course_id());
$cat->set_skills($values['skills']);
$cat->set_description($values['description']);
$cat->set_user_id($values['hid_user_id']);
$cat->set_parent_id($values['hid_parent_id']);
$cat->set_weight($values['weight']);
if (empty ($values['visible'])) {
$visible = 0;
} else {
@ -156,7 +163,8 @@ $display_form = true;
$display_form = false;
}
}*/
if ($display_form)
if ($display_form) {
$form->display();
}
Display :: display_footer();

@ -312,13 +312,15 @@ if (isset ($_GET['visiblecat'])) {
if (isset($_GET['deletecat'])) {
block_students();
$cats = Category :: load($_GET['deletecat']);
//delete all categories,subcategories and results
if ($cats[0] != null) {
if ($cats[0]->get_id() != 0) {
// better don't try to delete the root...
$cats[0]->delete_all();
}
}
if (isset($cats[0])) {
//delete all categories,subcategories and results
if ($cats[0] != null) {
if ($cats[0]->get_id() != 0) {
// better don't try to delete the root...
$cats[0]->delete_all();
}
}
}
$confirmation_message = get_lang('CategoryDeleted');
$filter_confirm_msg = false;
}
@ -834,7 +836,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$allcatSession = $catsResult;
foreach ($allcatSession as $catSession) {
if ($catSession->get_parent_id() == 0) {
continue;
continue;
}
$allcat[] = $catSession;
}

@ -264,101 +264,103 @@ class GradebookTable extends SortableTable
$cats = Category::load($parent_id, null, null, null, null, null);
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cats[0]->get_evaluations($stud_id);
$alllink = $cats[0]->get_links($stud_id);
if (isset($cats[0])) {
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cats[0]->get_evaluations($stud_id);
$alllink = $cats[0]->get_links($stud_id);
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
$data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
$data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
$total_weight = 0;
$total_weight = 0;
// Links.
// Links.
foreach ($data_array as $data) {
$row = array();
$item = $data[0];
foreach ($data_array as $data) {
$row = array();
$item = $data[0];
//if the item is invisible, wrap it in a span with class invisible
$invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
//if the item is invisible, wrap it in a span with class invisible
$invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
$main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
$main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
$main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
$main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_id_column($item);
}
$row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_id_column($item);
}
// Name.
$row[] = $invisibility_span_open."&nbsp;&nbsp;&nbsp; ".$this->build_name_link($item) . $invisibility_span_close;
$row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
// Description.
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
// Name.
$row[] = $invisibility_span_open."&nbsp;&nbsp;&nbsp; ".$this->build_name_link($item) . $invisibility_span_close;
$weight = $data[3];
$total_weight += $weight;
// Description.
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
$weight = $data[3];
$total_weight += $weight;
if (api_is_allowed_to_edit(null, true)) {
//$weight_total_links += intval($data[3]);
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$item_value = $scoretotal[0];
}
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
// Admins get an edit column.
if (api_is_allowed_to_edit(null, true)) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
if ($show_message === false) {
$row[] = $this->build_edit_column($item);
if (api_is_allowed_to_edit(null, true)) {
//$weight_total_links += intval($data[3]);
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$item_value = $scoretotal[0];
}
} else {
//students get the results and certificates columns
$eval_n_links = array_merge($alleval, $alllink);
if (count($eval_n_links)> 0 && $status_user!=1 ) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
$score = $item->calc_score(api_get_user_id());
$new_score = $data[3]* $score[0] / $score[1];
$row[] = Display::tip($new_score, $data[4]);
// Admins get an edit column.
if (api_is_allowed_to_edit(null, true)) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
if ($show_message === false) {
$row[] = $this->build_edit_column($item);
}
} else {
//students get the results and certificates columns
$eval_n_links = array_merge($alleval, $alllink);
if (count($eval_n_links)> 0 && $status_user!=1 ) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
$score = $item->calc_score(api_get_user_id());
$new_score = $data[3]* $score[0] / $score[1];
$row[] = Display::tip($new_score, $data[4]);
}
}
if (!empty($cats)) {
$row[] = null;
}
}
if (!empty($cats)) {
$row[] = null;
}
}
$row['child_of'] = $parent_id;
$row['child_of'] = $parent_id;
$sortable_data[] = $row;
}
$sortable_data[] = $row;
}
// "Warning row"
if (!empty($data_array)) {
if (api_is_allowed_to_edit()) {
// Compare the category weight to the sum of all weights inside the category
if (intval($total_weight) == $category_weight) {
$label = null;
$total = score_badges(array($total_weight.' / '.$category_weight, '100'));
} else {
$label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight) );
$total = Display::badge($total_weight.' / '.$category_weight, 'warning');
// "Warning row"
if (!empty($data_array)) {
if (api_is_allowed_to_edit()) {
// Compare the category weight to the sum of all weights inside the category
if (intval($total_weight) == $category_weight) {
$label = null;
$total = score_badges(array($total_weight.' / '.$category_weight, '100'));
} else {
$label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight) );
$total = Display::badge($total_weight.' / '.$category_weight, 'warning');
}
$row = array(
null,
null,
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',
null,
$total.' '.$label,
'child_of' => $parent_id
);
$sortable_data[] = $row;
}
$row = array(
null,
null,
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',
null,
$total.' '.$label,
'child_of' => $parent_id
);
$sortable_data[] = $row;
}
}
}
@ -498,10 +500,11 @@ class GradebookTable extends SortableTable
*/
private function build_name_link ($item)
{
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
switch ($item->get_item_type()) {
// category
case 'C' :
$prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.Security::remove_XSS($_GET['view']);
$prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.$view;
if (isset($_GET['isStudentView'])) {
if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) {

Loading…
Cancel
Save