Skip to content

Commit

Permalink
Add session_id in gradebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Mar 27, 2015
1 parent 0e088a1 commit 545330d
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 75 deletions.
4 changes: 2 additions & 2 deletions main/gradebook/gradebook.php
Expand Up @@ -576,7 +576,7 @@ function confirmation ()
}
// Here we are in a sub category
if ($category != '0') {
DisplayGradebook:: display_header_gradebook(
DisplayGradebook:: header(
$cats[0],
1,
$_GET['selectcat'],
Expand All @@ -586,7 +586,7 @@ function confirmation ()
);
} else {
// This is the root category
DisplayGradebook:: display_header_gradebook(
DisplayGradebook:: header(
$cats[0],
(((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1),
0,
Expand Down
64 changes: 33 additions & 31 deletions main/gradebook/index.php
Expand Up @@ -96,6 +96,7 @@ function confirmation() {
$filter_warning_msg = true;

$cats = Category :: load(null, null, $course_code, null, null, $session_id, false);

$first_time = null;

if (empty($cats)) {
Expand Down Expand Up @@ -151,7 +152,7 @@ function confirmation() {

// ACTIONS
//this is called when there is no data for the course admin
if (isset ($_GET['createallcategories'])) {
if (isset($_GET['createallcategories'])) {
GradebookUtils::block_students();
$coursecat= Category :: get_not_created_course_categories($stud_id);
if (!count($coursecat) == 0) {
Expand All @@ -173,13 +174,13 @@ function confirmation() {
}

//show logs evaluations
if (isset ($_GET['visiblelog'])) {
if (isset($_GET['visiblelog'])) {
header('Location: ' . api_get_self().'/gradebook_showlog_eval.php');
exit;
}

//move a category
if (isset ($_GET['movecat'])) {
if (isset($_GET['movecat'])) {
GradebookUtils::block_students();
$cats= Category :: load($_GET['movecat']);
if (!isset ($_GET['targetcat'])) {
Expand All @@ -196,7 +197,7 @@ function confirmation() {
exit;
}
} else {
$targetcat= Category :: load($_GET['targetcat']);
$targetcat = Category :: load($_GET['targetcat']);
$course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);

if (!($course_to_crsind && !isset($_GET['confirm']))) {
Expand All @@ -210,7 +211,7 @@ function confirmation() {
}

//move an evaluation
if (isset ($_GET['moveeval'])) {
if (isset($_GET['moveeval'])) {
GradebookUtils::block_students();
$evals= Evaluation :: load($_GET['moveeval']);
if (!isset ($_GET['targetcat'])) {
Expand Down Expand Up @@ -244,7 +245,7 @@ function confirmation() {
}

//move a link
if (isset ($_GET['movelink'])) {
if (isset($_GET['movelink'])) {
GradebookUtils::block_students();
$link= LinkFactory :: load($_GET['movelink']);
$move_form = new LinkForm(
Expand All @@ -266,15 +267,15 @@ function confirmation() {
}

//parameters for categories
if (isset ($_GET['visiblecat'])) {
if (isset($_GET['visiblecat'])) {
GradebookUtils::block_students();

if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
} else {
$visibility_command= 0;
}
$cats= Category :: load($_GET['visiblecat']);
$cats = Category :: load($_GET['visiblecat']);
$cats[0]->set_visible($visibility_command);
$cats[0]->save();
$cats[0]->apply_visibility_to_children();
Expand Down Expand Up @@ -302,8 +303,9 @@ function confirmation() {
$confirmation_message = get_lang('CategoryDeleted');
$filter_confirm_msg = false;
}

//parameters for evaluations
if (isset ($_GET['visibleeval'])) {
if (isset($_GET['visibleeval'])) {
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
Expand All @@ -322,6 +324,7 @@ function confirmation() {
$filter_confirm_msg = false;
}
}

//parameters for evaluations
if (isset($_GET['lockedeval'])) {
GradebookUtils::block_students();
Expand All @@ -339,9 +342,9 @@ function confirmation() {
}

$filter_confirm_msg = false;

}
if (isset ($_GET['deleteeval'])) {

if (isset($_GET['deleteeval'])) {
GradebookUtils::block_students();
$eval= Evaluation :: load($_GET['deleteeval']);
if ($eval[0] != null) {
Expand All @@ -350,8 +353,9 @@ function confirmation() {
$confirmation_message = get_lang('GradebookEvaluationDeleted');
$filter_confirm_msg = false;
}

//parameters for links
if (isset ($_GET['visiblelink'])) {
if (isset($_GET['visiblelink'])) {
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
Expand Down Expand Up @@ -441,7 +445,7 @@ function confirmation() {
}

//actions on the sortabletable
if (isset ($_POST['action'])) {
if (isset($_POST['action'])) {
GradebookUtils::block_students();
$number_of_selected_items= count($_POST['id']);

Expand All @@ -450,8 +454,7 @@ function confirmation() {
$filter_warning_msg = false;
} else {
switch ($_POST['action']) {

case 'deleted' :
case 'deleted':
$number_of_deleted_categories= 0;
$number_of_deleted_evaluations= 0;
$number_of_deleted_links= 0;
Expand Down Expand Up @@ -486,10 +489,10 @@ function confirmation() {
$confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>';
$filter_confirm_msg = false;
break;
case 'setvisible' :
case 'setvisible':
foreach ($_POST['id'] as $indexstr) {
if (substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(substr($indexstr, 4));
$cats = Category :: load(substr($indexstr, 4));
$cats[0]->set_visible(1);
$cats[0]->save();
$cats[0]->apply_visibility_to_children();
Expand All @@ -508,10 +511,10 @@ function confirmation() {
$confirmation_message = get_lang('ItemsVisible');
$filter_confirm_msg = false;
break;
case 'setinvisible' :
case 'setinvisible':
foreach ($_POST['id'] as $indexstr) {
if (substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(substr($indexstr, 4));
$cats = Category :: load(substr($indexstr, 4));
$cats[0]->set_visible(0);
$cats[0]->save();
$cats[0]->apply_visibility_to_children();
Expand Down Expand Up @@ -609,15 +612,15 @@ function confirmation() {

//load data for category, evaluation and links
if (empty($_GET['selectcat'])) {
$category= 0;
$category = 0;
} else {
$category= $_GET['selectcat'];
$category = $_GET['selectcat'];
}
$simple_search_form='';

if (isset($_GET['studentoverview'])) {
//@todo this code also seems to be deprecated ...
$cats= Category :: load($category);
$cats = Category :: load($category);
$stud_id= (api_is_allowed_to_edit() ? null : $stud_id);
$allcat= array ();
$alleval= $cats[0]->get_evaluations($stud_id, true);
Expand Down Expand Up @@ -656,6 +659,7 @@ function confirmation() {
//if $category = 0 (which happens when GET['selectcat'] is undefined)
// then Category::load() will create a new 'root' category with empty
// course and session fields in memory (Category::create_root_category())

if ($_in_course === true) {
// When *inside* a course, we want to make sure there is one (and only
// one) category for this course or for this session.
Expand All @@ -671,7 +675,7 @@ function confirmation() {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
if (empty($cats)) {
// There is no category for this course+session, so create one
$cat= new Category();
$cat = new Category();
if (!empty($session_id)) {
$s_name = api_get_session_name($session_id);
$cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name);
Expand All @@ -690,10 +694,11 @@ function confirmation() {
if ($can_edit) {
$cat->add();
}
unset ($cat);
unset($cat);
}
unset($cats);
}

$cats = Category::load($category, null, null, null, null, null, false);

//with this fix the teacher only can view 1 gradebook
Expand All @@ -706,19 +711,17 @@ function confirmation() {
$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);
//whether we found a category or not, we now have a category object with
// empty or full subcats
}

// add params to the future links (in the table shown)
$addparams = array ('selectcat' => $cats[0]->get_id());
$addparams = array('selectcat' => $cats[0]->get_id());

if (isset ($_GET['studentoverview'])) {
if (isset($_GET['studentoverview'])) {
$addparams['studentoverview'] = '';
}
//$addparams['cidReq']='';
if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
$addparams['cidReq']=Security::remove_XSS($_GET['cidReq']);
$addparams['cidReq'] = Security::remove_XSS($_GET['cidReq']);
} else {
$addparams['cidReq']='';
}
Expand Down Expand Up @@ -849,8 +852,7 @@ function confirmation() {
} else {
// This is the father
// Create gradebook/add gradebook links.

DisplayGradebook::display_header_gradebook(
DisplayGradebook::header(
$cat,
0,
$cat->get_id(),
Expand Down

0 comments on commit 545330d

Please sign in to comment.