'; //jQuery $htmlHeadXtra[] = ''; api_block_anonymous_users(); $htmlHeadXtra[]= ''; $tbl_forum_thread = Database :: get_course_table(TABLE_FORUM_THREAD); $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $filter_confirm_msg = true; $filter_warning_msg = true; $session_id = api_get_session_id(); ///direct access to one evaluation $cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init if (empty($cats)) { $cats = Category :: load(0, null, $course_code, null, null, $session_id, false);//first time $first_time=1; } $_GET['selectcat'] = $cats[0]->get_id(); if (isset($_GET['isStudentView'])) { if ( (isset($_GET['selectcat']) && $_GET['selectcat']>0) && (isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { $interbreadcrumb[]= array ( 'url' => 'index.php'.'?selectcat=0&isStudentView='.$_GET['isStudentView'], 'name' => get_lang('ToolGradebook') ); } } if ( (isset($_GET['selectcat']) && $_GET['selectcat']>0) && (isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { Display :: display_header(); //Introduction tool: student view Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction')); $category= $_GET['selectcat']; $stud_id=api_get_user_id(); $course_code=api_get_course_id(); $session_id=api_get_session_id(); $cats = Category :: load ($category, null, null, null, null, null, false); $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); $addparams=array(); $gradebooktable= new GradebookTable($cats[0], $allcat, $alleval,$alllink, $addparams); $gradebooktable->display(); Display :: display_footer(); exit; } else { if ( !isset($_GET['selectcat']) && ($_SESSION['studentview']=='studentview') || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='true') ) { // if ( !isset($_GET['selectcat']) && ($_SESSION['studentview']=='studentview') && ($status<>1 && !api_is_platform_admin()) || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='true' && $status<>1 && !api_is_platform_admin()) ) { Display :: display_header(get_lang('Gradebook')); //Introduction tool: student view Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction')); $stud_id=api_get_user_id(); $course_code=api_get_course_id(); $session_id=api_get_session_id(); $addparams=array(); $cats = Category :: load (0, null, null, null, null, null, false); $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); $gradebooktable= new GradebookTable($cats[0], $allcat, $alleval,$alllink, $addparams); $gradebooktable->display(); Display :: display_footer(); exit; } } // ACTIONS //this is called when there is no data for the course admin if (isset ($_GET['createallcategories'])) { block_students(); $coursecat= Category :: get_not_created_course_categories(api_get_user_id()); if (!count($coursecat) == 0) { foreach ($coursecat as $row) { $cat= new Category(); $cat->set_name($row[1]); $cat->set_course_code($row[0]); $cat->set_description(null); $cat->set_user_id(api_get_user_id()); $cat->set_parent_id(0); $cat->set_weight(0); $cat->set_visible(0); $cat->add(); unset ($cat); } } header('Location: '.$_SESSION['gradebook_dest'].'?addallcat=&selectcat=0'); exit; } //show logs evaluations if (isset ($_GET['visiblelog'])) { header('Location: ' . api_get_self().'/gradebook_showlog_eval.php'); exit; } //move a category if (isset ($_GET['movecat'])) { block_students(); $cats= Category :: load($_GET['movecat']); if (!isset ($_GET['targetcat'])) { $move_form= new CatForm(CatForm :: TYPE_MOVE, $cats[0], 'move_cat_form', null, api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat']) . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); if ($move_form->validate()) { header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&movecat=' . Security::remove_XSS($_GET['movecat']) . '&targetcat=' . $move_form->exportValue('move_cat')); exit; } } else { $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']))) { $cats[0]->move_to_cat($targetcat[0]); header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); exit; } unset ($targetcat); } unset ($cats); } //move an evaluation if (isset ($_GET['moveeval'])) { block_students(); $evals= Evaluation :: load($_GET['moveeval']); if (!isset ($_GET['targetcat'])) { $move_form= new EvalForm(EvalForm :: TYPE_MOVE, $evals[0], null, 'move_eval_form', null, api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval']) . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); if ($move_form->validate()) { header('Location: ' .api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&moveeval=' . Security::remove_XSS($_GET['moveeval']) . '&targetcat=' . $move_form->exportValue('move_cat')); exit; } } else { $targetcat= Category :: load($_GET['targetcat']); $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); if (!($course_to_crsind && !isset($_GET['confirm']))) { $evals[0]->move_to_cat($targetcat[0]); header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); exit; } unset ($targetcat); } unset ($evals); } //move a link if (isset ($_GET['movelink'])) { block_students(); $link= LinkFactory :: load($_GET['movelink']); $move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); if ($move_form->validate()) { $targetcat= Category :: load($move_form->exportValue('move_cat')); $link[0]->move_to_cat($targetcat[0]); unset ($link); header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); exit; } } //parameters for categories if (isset ($_GET['visiblecat'])) { block_students(); if (isset ($_GET['set_visible'])) { $visibility_command= 1; } else { $visibility_command= 0; } $cats= Category :: load($_GET['visiblecat']); $cats[0]->set_visible($visibility_command); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); unset ($cats); if ($visibility_command) { $confirmation_message = get_lang('ViMod'); $filter_confirm_msg = false; } else { $confirmation_message = get_lang('InViMod'); $filter_confirm_msg = false; } } 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(); } } $confirmation_message = get_lang('CategoryDeleted'); $filter_confirm_msg = false; } //parameters for evaluations if (isset ($_GET['visibleeval'])) { block_students(); if (isset ($_GET['set_visible'])) { $visibility_command= 1; } else { $visibility_command= 0; } $eval= Evaluation :: load($_GET['visibleeval']); $eval[0]->set_visible($visibility_command); $eval[0]->save(); unset ($eval); if ($visibility_command) { $confirmation_message = get_lang('ViMod'); $filter_confirm_msg = false; } else { $confirmation_message = get_lang('InViMod'); $filter_confirm_msg = false; } } if (isset ($_GET['deleteeval'])) { block_students(); $eval= Evaluation :: load($_GET['deleteeval']); if ($eval[0] != null) { $eval[0]->delete_with_results(); } $confirmation_message = get_lang('GradebookEvaluationDeleted'); $filter_confirm_msg = false; } //parameters for links if (isset ($_GET['visiblelink'])) { block_students(); if (isset ($_GET['set_visible'])) { $visibility_command= 1; } else { $visibility_command= 0; } $link= LinkFactory :: load($_GET['visiblelink']); $link[0]->set_visible($visibility_command); $link[0]->save(); unset ($link); if ($visibility_command) { $confirmation_message = get_lang('ViMod'); $filter_confirm_msg = false; } else { $confirmation_message = get_lang('InViMod'); $filter_confirm_msg = false; } } if (isset ($_GET['deletelink'])) { block_students(); $get_delete_link=Security::remove_XSS($_GET['deletelink']); //fixing #5229 if (!empty($get_delete_link)) { $link= LinkFactory :: load($get_delete_link); if ($link[0] != null) { // clean forum qualify $sql='UPDATE '.$tbl_forum_thread.' SET thread_qualify_max=0,thread_weight=0,thread_title_qualify="" WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' WHERE id='.$get_delete_link.' AND type = '.LINK_FORUM_THREAD.');'; Database::query($sql); // clean attendance $sql='UPDATE '.$tbl_attendance.' SET attendance_qualify_max=0, attendance_weight = 0, attendance_qualify_title="" WHERE id=(SELECT ref_id FROM '.$tbl_grade_links.' WHERE id='.$get_delete_link.' AND type = '.LINK_ATTENDANCE.');'; Database::query($sql); $link[0]->delete(); } unset ($link); $confirmation_message = get_lang('LinkDeleted'); $filter_confirm_msg = false; } } if (!empty($course_to_crsind) && !isset($_GET['confirm'])) { block_students(); if (!isset($_GET['movecat']) && !isset($_GET['moveeval'])) { die ('Error: movecat or moveeval not defined'); } $button = '
'; $warning_message = get_lang('MoveWarning').'
' . get_lang('Print') . '';
//add header
$new_content_html=$new_content[0].$print.''.$new_content_html;
if ($cat_id=strval(intval($cat_id))) {
if (UserManager::is_user_certified($cat_id,$user_id)===true){
header('Content-Type: text/html; charset='. $charset);
echo $new_content_html;
exit;
} else {
$my_new_content_html=$new_content_html;
$my_new_content_html=mb_convert_encoding($my_new_content_html,'UTF-8',$charset);
file_put_contents($my_path_certificate,$my_new_content_html);
header('Content-Type: text/html; charset='. $charset);
echo $new_content_html;
}
$path_certificate='/'.$name.'.html';
update_user_info_about_certificate($cat_id,$user_id,$path_certificate);
exit;
}
} else {
Display :: display_reduced_header();
Display :: display_warning_message(get_lang('NoCertificateAvailable'));
}
}
/*$pdf= new Cezpdf('a4','landscape');
$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
$pdf->ezSetMargins(30, 30, 50, 50);
//line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom)
$pdf->line(50,50,790,50);
$pdf->line(50,550,790,550);
$pdf->ezSetY(450);
$pdf->ezImage(api_get_path(SYS_CODE_PATH).'img/dokeos_logo_certif.png',1,400,'','center','');
$pdf->ezSetY(480);
$pdf->ezText($certif_text,28,array('justification'=>'center'));
//$pdf->ezSetY(750);
$pdf->ezSetY(50);
$pdf->ezText($date,18,array('justification'=>'center'));
$pdf->ezSetY(580);
$pdf->ezText($organization_name,22,array('justification'=>'left'));
$pdf->ezSetY(580);
$pdf->ezText($portal_name,22,array('justification'=>'right'));
$pdf->ezStream();*/
}
exit;
} else { //in any other case (no search, no pdf), print the available gradebooks
// Important note: loading a category will actually load the *contents* of
// this category. This means that, to show the categories of a course,
// we have to show the root category and show its subcategories that
// are inside this course. This is done at the time of calling
// $cats[0]->get_subcategories(), not at the time of doing Category::load()
// $category comes from GET['selectcat']
$course_code = api_get_course_id();
$session_id = api_get_session_id();
//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.
//hack for delete a gradebook from inside course
$clean_deletecat=Security::remove_XSS($_GET['deletecat']);
if (!empty($clean_deletecat))
{
exit;
}
//end hack
$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();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
if (!empty($session_id)) {
$my_session_id=api_get_session_id();
$s_name = api_get_session_name($my_session_id);
$cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name);
$cat->set_session_id($session_id);
} else {
$cat->set_name($course_code);
}
$cat->set_course_code($course_code);
$cat->set_description(null);
$cat->set_user_id(api_get_user_id());
$cat->set_parent_id(0);
$cat->set_weight(100);
$cat->set_visible(0);
$can_edit = api_is_allowed_to_edit(true, true);
if ($can_edit) {
$cat->add();
}
unset ($cat);
}
unset($cats);
}
$cats = Category :: load ($category, null, null, null, null, null, false);
//with this fix the teacher only can view 1 gradebook
//$stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
if (api_is_platform_admin()) {
$stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
} else {
$stud_id= api_get_user_id();
}
$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());
/*
if (isset($_GET['search'])) {
$addparams['search'] = $keyword;
}
*/
if (isset ($_GET['studentoverview'])) {
$addparams['studentoverview'] = '';
}
//$addparams['cidReq']='';
if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
$addparams['cidReq']=Security::remove_XSS($_GET['cidReq']);
} else {
$addparams['cidReq']='';
}
$gradebooktable= new GradebookTable($cats[0], $allcat, $alleval,$alllink, $addparams);
$no_qualification = false;
if (( count($allcat) == 0) && ( count($alleval) == 0 ) && ( count($alllink) == 0 )) {
$no_qualification = true;
if ((($is_course_admin) && (!isset ($_GET['selectcat']))) && api_is_course_tutor()) {
Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '
'.get_lang('EditCategory').'';
$modify_icons .= '
'.get_lang('DeleteAll').'';
$modify_icons .= '
'.$op_cat_weight.' '.' '.$opt_cat_cert_min.' '.$opt_cat_descrip.'
'.get_lang('Certificates').' '.get_lang('langTotal').': '.$scoretotal_display;
echo '