@ -38,21 +38,6 @@ if (empty($my_selectcat)) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    api_not_allowed();  
					 
					 
					 
					    api_not_allowed();  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// 	DISPLAY HEADERS AND MESSAGES  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if (isset ($_GET['studentoverview'])) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook'));  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Display :: display_header(get_lang('FlatView'));  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    } elseif (isset ($_GET['search'])) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook'));  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Display :: display_header(get_lang('SearchResults'));  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    } else {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=1', 'name' => get_lang('Gradebook'));  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $interbreadcrumb[] = array ('url' => '#','name' => get_lang('EditAllWeights'));  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Display :: display_header('');  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$course_id			  =	get_course_id_by_link_id($my_selectcat);  
					 
					 
					 
					$course_id			  =	get_course_id_by_link_id($my_selectcat);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$table_link           = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);  
					 
					 
					 
					$table_link           = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -70,17 +55,6 @@ $table_evaluated[LINK_ATTENDANCE]         = array(TABLE_ATTENDANCE, 'attendance_ 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$table_evaluated[LINK_SURVEY]             = array(TABLE_SURVEY, 'code', 'survey_id', get_lang('Survey'));  
					 
					 
					 
					$table_evaluated[LINK_SURVEY]             = array(TABLE_SURVEY, 'code', 'survey_id', get_lang('Survey'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$submitted = isset($_POST['submitted'])?$_POST['submitted']:'';  
					 
					 
					 
					$submitted = isset($_POST['submitted'])?$_POST['submitted']:'';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					if ($submitted==1) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '< br  / > < br  / > ';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if (isset($_POST['evaluation'])) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        require_once 'lib/be/evaluation.class.php';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $eval_log = new Evaluation();  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if (isset($_POST['link'])) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        require_once 'lib/be/abstractlink.class.php';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        //$eval_link_log = new AbstractLink();  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$output='';  
					 
					 
					 
					$output='';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$my_cat = Category::load($my_selectcat);  
					 
					 
					 
					$my_cat = Category::load($my_selectcat);  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -98,41 +72,15 @@ $masked_total = $parent_cat[0]->get_weight(); 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$sql = 'SELECT * FROM '.$table_link.' WHERE category_id = '.$my_selectcat;  
					 
					 
					 
					$sql = 'SELECT * FROM '.$table_link.' WHERE category_id = '.$my_selectcat;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$result = Database::query($sql);  
					 
					 
					 
					$result = Database::query($sql);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$links = Database::store_result($result, 'ASSOC');  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					while ($row = Database ::fetch_array($result) ) { 
					 
					 
					 
					foreach ($links as & $row ) { 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					    $item_weight = $row['weight'];  
					 
					 
					 
					    $item_weight = $row['weight'];  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    //$item_weight = $masked_total*$item_weight/$original_total;  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    //update only if value changed  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if (isset($_POST['link'][$row['id']])) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        //$new_weight = trim($_POST['link'][$row['id']]*$original_total/$masked_total);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $new_weight = trim($_POST['link'][$row['id']]);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        AbstractLink::add_link_log($row['id']);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Database::query('UPDATE '.$table_link.' SET weight = '."'".Database::escape_string($new_weight)."'".' WHERE id = '.$row['id']);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $item_weight = trim($_POST['link'][$row['id']]);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        //Update weight for attendance  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $sql = 'SELECT ref_id FROM '.$table_link.' WHERE id = '.intval($row['id']).' AND type='.LINK_ATTENDANCE;  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $rs_attendance  = Database::query($sql);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if (Database::num_rows($rs_attendance) > 0) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            $row_attendance = Database::fetch_array($rs_attendance);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            $upd_attendance = 'UPDATE '.$tbl_attendance.' SET attendance_weight ='.floatval($_POST['link'][$row['id']]).'  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                WHERE c_id = '.$course_id.' AND  id = '.intval($row_attendance['ref_id']);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            Database::query($upd_attendance);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        }  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        //Update weight into forum thread  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $sql_t = 'UPDATE '.$tbl_forum_thread.' SET thread_weight='.floatval($_POST['link'][$row['id']]).'  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    WHERE c_id = '.$course_id.' AND thread_id = (SELECT ref_id FROM '.$table_link.' WHERE id='.intval($row['id']).' AND type='.LINK_FORUM_THREAD.' ) ';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Database::query($sql_t);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        //Update weight into student publication(work)  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $sql_t='UPDATE '.$tbl_work.' SET weight='.floatval($_POST['link'][$row['id']]).'  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                WHERE  c_id = '.$course_id.' AND id = (SELECT ref_id FROM '.$table_link.' WHERE id='.intval($row['id']).' AND type = '.LINK_STUDENTPUBLICATION.' ) ';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Database::query($sql_t);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    $tempsql = Database::query('SELECT * FROM '.get_table_type_course($row['type']).' WHERE c_id = '.$course_id.' AND '.$table_evaluated[$row['type']][2].' = '.$row['ref_id']);  
					 
					 
					 
					    $sql = 'SELECT * FROM '.get_table_type_course($row['type']).'  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    $resource_name = Database ::fetch_array($tempsql);  
					 
					 
					 
					            WHERE c_id = '.$course_id.' AND '.$table_evaluated[$row['type']][2].' = '.$row['ref_id'];  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $result = Database::query($sql);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $resource_name = Database ::fetch_array($result);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if (isset($resource_name['lp_type'])) {  
					 
					 
					 
					    if (isset($resource_name['lp_type'])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $resource_name = $resource_name[2];  
					 
					 
					 
					        $resource_name = $resource_name[2];  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -140,33 +88,130 @@ while ($row = Database ::fetch_array($result)) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $resource_name = $resource_name[1];  
					 
					 
					 
					        $resource_name = $resource_name[1];  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    $output.= '< tr > < td > '.build_type_icon_tag($row['type']).'< / td > < td >  '.$resource_name.' '.Display::label($table_evaluated[$row['type']][3],'info').' < / td > ';  
					 
					 
					 
					    $row['resource_name'] = $resource_name;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    $output.= '< td > < input  type = "hidden"  name = "link_'.$row['id'].'"  value = "'.$resource_name.'"  / > < input  size = "10"  type = "text"  name = "link['.$row['id'].']"  value = "'.$item_weight.'" / > < / td > < / tr > ';  
					 
					 
					 
					
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    //update only if value changed  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    if (isset($_POST['link'][$row['id']])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $new_weight = trim($_POST['link'][$row['id']]);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        updateLinkWeight($row['id'], $resource_name, $new_weight);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $item_weight = $new_weight;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$sql = Database::query('SELECT * FROM '.$table_evaluation.' WHERE category_id = '.$my_selectcat);  
					 
					 
					 
					    $output.= '< tr > < td > '.build_type_icon_tag($row['type']).'< / td >   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					while ($row = Database ::fetch_array($sql)) {  
					 
					 
					 
					               < td >  '.$resource_name.' '.Display::label($table_evaluated[$row['type']][3],'info').' < / td > ';  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    $item_weight = $row['weight'];  
					 
					 
					 
					    $output.= '< td >   
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    < input  type = "hidden"  name = "link_'.$row['id'].'"  value = "'.$resource_name.'"  / >   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    < input  size = "10"  type = "text"  name = "link['.$row['id'].']"  value = "'.$item_weight.'" / >   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					               < / td > < / tr > ';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$sql = 'SELECT * FROM '.$table_evaluation.' WHERE category_id = '.$my_selectcat;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$result = Database::query($sql);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$evaluations = Database::store_result($result);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					foreach ($evaluations as $evaluationRow) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    //$item_weight = $row['weight'];  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    //$item_weight = $masked_total*$item_weight/$original_total;  
					 
					 
					 
					    //$item_weight = $masked_total*$item_weight/$original_total;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $item_weight = $evaluationRow['weight'];  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    //update only if value changed  
					 
					 
					 
					    //update only if value changed  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if (isset($_POST['evaluation'][$row['id']])) {  
					 
					 
					 
					    if (isset($_POST['evaluation'][$evaluationRow['id']])) {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					        Evaluation::add_evaluation_log($row['id']);  
					 
					 
					 
					        $new_weight = trim($_POST['evaluation'][$evaluationRow['id']]);  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					        //$new_weight = trim($_POST['evaluation'][$row['id']]*$original_total/$masked_total);  
					 
					 
					 
					        updateEvaluationWeight($evaluationRow['id'], $new_weight);  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					        $new_weight = trim($_POST['evaluation'][$row['id']]);  
					 
					 
					 
					        $item_weight = $new_weight;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					        $update_sql = 'UPDATE '.$table_evaluation.' SET weight = '."'".Database::escape_string($new_weight)."'".' WHERE id = '.$row['id'];  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        Database::query($update_sql);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        $item_weight = trim($_POST['evaluation'][$row['id']]);  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    $type_evaluated = isset($row['type']) ? $table_evaluated[$type_evaluated][3] : null;  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    $output.= '< tr > < td > '.build_type_icon_tag('evalnotempty').'< / td > < td > '.$row['name'].' '.Display::label(get_lang('Evaluation').$type_evaluated).'< / td > ';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    $output.= '< td > < input  type = "hidden"  name = "eval_'.$row['id'].'"  value = "'.$row['name'].'"  / > < input  type = "text"  size = "10"  name = "evaluation['.$row['id'].']"  value = "'.$item_weight.'" / > < / td > < / tr > ';  
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					    }  
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $output.= '< tr > < td > '.build_type_icon_tag('evalnotempty').'< / td > < td > '.$evaluationRow['name'].' '.Display::label(get_lang('Evaluation')).'< / td > ';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $output.= '< td > < input  type = "hidden"  name = "eval_'.$evaluationRow['id'].'"  value = "'.$evaluationRow['name'].'"  / > < input  type = "text"  size = "10"  name = "evaluation['.$evaluationRow['id'].']"  value = "'.$item_weight.'" / > < / td > < / tr > ';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					//by iflorespaz  
					 
					 
					 
					//by iflorespaz  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$my_api_cidreq = api_get_cidreq();  
					 
					 
					 
					$my_api_cidreq = api_get_cidreq();  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					if ($my_api_cidreq=='') {  
					 
					 
					 
					if ($my_api_cidreq=='') {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    $my_api_cidreq='cidReq='.$my_category['course_code'];  
					 
					 
					 
					    $my_api_cidreq='cidReq='.$my_category['course_code'];  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$currentUrl = api_get_self().'?'.api_get_cidreq().'&selectcat='.$my_selectcat;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$form = new FormValidator('auto_weight', 'post', $currentUrl);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$form->addHeader(get_lang('AutoWeight'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$form->addLabel(null, get_lang('AutoWeightExplanation'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$form->add_button('autoweight', get_lang('AutoWeight'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					if ($form->validate()) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $itemCount = count($links) + count($evaluations);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $weight = round($original_total / $itemCount, 2);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $total = $weight * $itemCount;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $diff = null;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    if ($original_total !== $total) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        if ($total > $original_total) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            $diff = $total - $original_total;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $total = 0;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    $diffApplied = false;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    foreach ($links as $link) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $weightToApply = $weight;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        if ($diffApplied == false) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            if (!empty($diff)) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                $weightToApply = $weight - $diff;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                $diffApplied = true;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        updateLinkWeight(  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            $link['id'],  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            $link['resource_name'],  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            $weightToApply  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        );  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    foreach ($evaluations as $evaluation) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $weightToApply = $weight;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        if ($diffApplied == false) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            if (!empty($diff)) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                $weightToApply = $weight - $diff;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                $diffApplied = true;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        updateEvaluationWeight(  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            $evaluation['id'],  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            $weightToApply  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        );  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    header('Location:'.$currentUrl);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    exit;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					// 	DISPLAY HEADERS AND MESSAGES  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    if (isset ($_GET['studentoverview'])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        Display :: display_header(get_lang('FlatView'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    } elseif (isset ($_GET['search'])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        Display :: display_header(get_lang('SearchResults'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    } else {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=1', 'name' => get_lang('Gradebook'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $interbreadcrumb[] = array ('url' => '#','name' => get_lang('EditAllWeights'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        Display :: display_header('');  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					if ($submitted==1) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '< br  / > < br  / > ';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    if (isset($_POST['evaluation'])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        require_once 'lib/be/evaluation.class.php';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        $eval_log = new Evaluation();  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    if (isset($_POST['link'])) {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        require_once 'lib/be/abstractlink.class.php';  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        //$eval_link_log = new AbstractLink();  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					?>  
					 
					 
					 
					?>  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    < div  class = "actions" >   
					 
					 
					 
					    < div  class = "actions" >   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        < a  href = " <?php  echo  Security :: remove_XSS ( $_SESSION [ 'gradebook_dest' ]) . '?' . $my_api_cidreq  ?> &selectcat= <?php  echo  $my_selectcat  ?> " > 
  
					 
					 
					 
					        < a  href = " <?php  echo  Security :: remove_XSS ( $_SESSION [ 'gradebook_dest' ]) . '?' . $my_api_cidreq  ?> &selectcat= <?php  echo  $my_selectcat  ?> " > 
  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -176,6 +221,12 @@ if ($my_api_cidreq=='') { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					<?php  
					 
					 
					 
					<?php  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $masked_total);  
					 
					 
					 
					$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $masked_total);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					Display::display_normal_message($warning_message, false);  
					 
					 
					 
					Display::display_normal_message($warning_message, false);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$form->display();  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$formNormal = new FormValidator('normal_weight', 'post', $currentUrl);  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$formNormal->addHeader(get_lang('EditWeight'));  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					$formNormal->display();  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					?>  
					 
					 
					 
					?>  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    < form  method = "post"  action = "gradebook_edit_all.php? <?php  echo  $my_api_cidreq  ?> &selectcat= <?php  echo  $my_selectcat ?> " > 
  
					 
					 
					 
					    < form  method = "post"  action = "gradebook_edit_all.php? <?php  echo  $my_api_cidreq  ?> &selectcat= <?php  echo  $my_selectcat ?> " > 
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        < table  class = "data_table" >   
					 
					 
					 
					        < table  class = "data_table" >