skala
Julio Montoya 13 years ago
commit c02c09fd06
  1. 10
      main/gradebook/gradebook_add_eval.php
  2. 6
      main/gradebook/gradebook_add_link.php
  3. 38
      main/gradebook/gradebook_edit_cat.php
  4. 9
      main/gradebook/gradebook_edit_eval.php
  5. 6
      main/gradebook/gradebook_edit_link.php
  6. 166
      main/gradebook/index.php
  7. 11
      main/gradebook/lib/be/category.class.php
  8. 8
      main/gradebook/lib/be/evaluation.class.php
  9. 50
      main/gradebook/lib/fe/catform.class.php
  10. 35
      main/gradebook/lib/fe/displaygradebook.php
  11. 66
      main/gradebook/lib/fe/evalform.class.php
  12. 36
      main/gradebook/lib/fe/gradebooktable.class.php
  13. 25
      main/gradebook/lib/fe/linkaddeditform.class.php
  14. 4
      main/gradebook/lib/gradebook_data_generator.class.php
  15. 15
      main/gradebook/lib/gradebook_functions.inc.php
  16. 9
      main/inc/lib/userportal.lib.php
  17. 5
      main/install/db_main.sql
  18. 8
      main/install/migrate-db-1.8.8-1.9.0-pre.sql
  19. 7
      main/template/default/layout/login_form.tpl

@ -30,6 +30,7 @@ if (isset ($_GET['selectcat']) && (!empty ($_GET['selectcat']))) {
$evaladd->set_category_id(0);
}
$form = new EvalForm(EvalForm :: TYPE_ADD, $evaladd, null, 'add_eval_form',null,api_get_self() . '?selectcat=' .$select_cat);
if ($form->validate()) {
$values = $form->exportValues();
$eval = new Evaluation();
@ -42,12 +43,17 @@ if ($form->validate()) {
}
//Always add the gradebook to the course
$eval->set_course_code(api_get_course_id());
$eval->set_course_code(api_get_course_id());
$eval->set_category_id($values['hid_category_id']);
$parent_cat = Category :: load($values['hid_category_id']);
$global_weight = $cat[0]->get_weight();
$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$eval->set_weight($values['weight']);
$eval->set_max($values['max']);
if (empty ($values['visible'])) {
$visible = 0;
} else {

@ -68,6 +68,12 @@ if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0') {
} else {
$link->set_ref_id($addvalues['select_link']);
}
$parent_cat = Category :: load($addvalues['select_gradebook']);
$global_weight = $category[0]->get_weight();
$addvalues['weight'] = $addvalues['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$link->set_weight($addvalues['weight']);
if ($link->needs_max()) {

@ -10,10 +10,10 @@
$language_file = 'gradebook';
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
require_once api_get_path(LIBRARY_PATH).'grade_model.lib.php';
api_block_anonymous_users();
block_students();
@ -100,13 +100,14 @@ if ($form->validate()) {
}else {
$cat->set_course_code($values['course_code']);
}
$cat->set_description($values['description']);
$cat->set_skills($values['skills']);
$cat->set_grade_model_id($values['grade_model_id']);
$cat->set_description($values['description']);
$cat->set_skills($values['skills']);
$cat->set_user_id($values['hid_user_id']);
$cat->set_parent_id($values['hid_parent_id']);
$cat->set_weight($values['weight']);
if ($values['hid_parent_id'] == 0 ) {
$cat->set_certificate_min_score($values['certif_min_score']);
}
@ -117,6 +118,35 @@ if ($form->validate()) {
}
$cat->set_visible($visible);
$cat->save();
$parent_id = $cat->get_parent_id();
if ($parent_id == 0) {
//do something
if (isset($values['grade_model_id']) && !empty($values['grade_model_id'])) {
$obj = new GradeModel();
$components = $obj->get_components($values['grade_model_id']);
foreach ($components as $component) {
$gradebook = new Gradebook();
$params = array();
$params['name'] = $component['acronym'];
$params['description'] = $component['title'];
$params['user_id'] = api_get_user_id();
$params['parent_id'] = $cat->get_id();
$params['weight'] = $component['percentage']/100*$values['weight'];
$params['session_id'] = api_get_session_id();
$params['course_code'] = api_get_course_id();
$params['grade_model_id'] = api_get_session_id();
$gradebook->save($params);
}
}
}
header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id());
exit;
}

@ -27,7 +27,14 @@ if ($form->validate()) {
$eval->set_user_id($values['hid_user_id']);
$eval->set_course_code($values['hid_course_code']);
$eval->set_category_id($values['hid_category_id']);
$eval->set_weight($values['weight']);
$parent_cat = Category :: load($values['hid_category_id']);
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0] -> get_weight();
$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$eval->set_weight($values['weight']);
$eval->set_max($values['max']);
if (empty ($values['visible'])) {
$visible = 0;

@ -32,7 +32,11 @@ $cats = Category :: load(null, null, $course_code, null, null, $session_id, fals
$form = new LinkAddEditForm(LinkAddEditForm :: TYPE_EDIT, $cats, null, $link, 'edit_link_form', api_get_self() . '?selectcat=' . $linkcat. '&editlink=' . $linkedit);
if ($form->validate()) {
$values = $form->exportValues();
$values = $form->exportValues();
$parent_cat = Category :: load($values['select_gradebook']);
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$link->set_weight($values['weight']);
if (!empty($values['select_gradebook'])) {

@ -505,7 +505,6 @@ if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
// DISPLAY HEADERS AND MESSAGES
if (!isset($_GET['exportpdf'])) {
if (isset ($_GET['studentoverview'])) {
$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('ToolGradebook'));
@ -521,16 +520,6 @@ if (!isset($_GET['exportpdf'])) {
Display :: display_header('');
} else {
Display :: display_header(get_lang('ToolGradebook'));
/*if ( ($_SESSION['studentview']=='studentview') || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='true') ) {
$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;
}*/
}
}
@ -589,27 +578,6 @@ if (empty ($_GET['selectcat'])) {
$category= $_GET['selectcat'];
}
$simple_search_form='';
// search disabled in course context
/*
$simple_search_form= new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']));
$values= $simple_search_form->exportValues();
$keyword = '';
if (isset($_GET['search']) && !empty($_GET['search']))
$keyword = Security::remove_XSS($_GET['search']);
if ($simple_search_form->validate() && (empty($keyword)))
$keyword = $values['keyword'];
*/
/* search disabled in course context
if (!empty($keyword))
{
$cats= Category :: load($category);
$allcat= array ();
$alleval= Evaluation :: find_evaluations($keyword, $cats[0]->get_id());
$alllink= LinkFactory :: find_links($keyword, $cats[0]->get_id());
}
else
*/
if (isset ($_GET['studentoverview'])) {
//@todo this code also seems to be deprecated ...
@ -717,12 +685,6 @@ if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
$addparams['cidReq']='';
}
$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') . '<br /><br /><form name="createcat" method="post" action="' . api_get_self() . '?createallcategories=1"><input type="submit" value="' . get_lang('CreateAllCat') . '"></form>',false);
}
}
//here we are in a sub category
if ($category != '0') {
@ -780,9 +742,7 @@ if ($category != '0') {
$cattotal = Category :: load($category_id);
//echo 'start';
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
//echo 'end'; var_dump($scoretotal);
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
//Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global
$my_score_in_gradebook = round($scoretotal[0],2);
@ -823,36 +783,65 @@ if (api_is_allowed_to_edit(null, true)) {
//
} else {
if (((isset ($_GET['selectcat']) && $_GET['selectcat']==0) || ((isset($_GET['cidReq']) && $_GET['cidReq']!==''))) || isset($_GET['isStudentView']) && $_GET['isStudentView']=='false') {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
if (!$first_time=1) {
}
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
}
}
}
if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?cidReq='.$course_code.'" />';
} else {
/*$models = api_get_settings_options('grading_model');
$course_grading_model_id = api_get_course_setting('course_grading_model');
$grading_model = '';
if (!empty($course_grading_model_id)) {
if (!empty($models)) {
foreach($models as $option) {
if (intval($option['id']) == $course_grading_model_id) {
$grading_model = $option['value'];
}
}
}
}
$grading_contents = api_grading_model_functions($grading_model, 'to_array');
$grading_string = api_grading_model_functions($grading_model, 'decorate');*/
} else {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
if (!empty($cats)) {
//$items = $grading_contents['items'];
if (!empty($cats)) {
//Getting grade models
$obj = new GradeModel();
$grade_models = $obj->get_all();
$options = array(0 => get_lang('none'));
foreach ($grade_models as $item) {
$options[$item['id']] = $item['name'];
}
$grade_model_id = $cats[0]->get_grade_model_id();
//No children
if (count($cats) == 1 && !isset($grade_model_id)) {
$form = new FormValidator('grade_model_settings');
$form->addElement('select', 'grade_model', get_lang('SelectGradeModel'), $options);
$form->addElement('style_submit_button', 'submit', get_lang('Save'), 'class="save"');
$form->display();
if ($form->validate()) {
$value = $form->exportValue('grade_model');
$gradebook = new Gradebook();
$gradebook->update(array('id'=> $cat->get_id(), 'grade_model_id' => $value), true);
//do something
$obj = new GradeModel();
$components = $obj->get_components($value);
foreach ($components as $component) {
$gradebook = new Gradebook();
$params = array();
$params['name'] = $component['acronym'];
$params['description'] = $component['title'];
$params['user_id'] = api_get_user_id();
$params['parent_id'] = $cat->get_id();
$params['weight'] = $component['percentage'];
$params['session_id'] = api_get_session_id();
$params['course_code'] = api_get_course_id();
$params['grade_model_id'] = api_get_session_id();
$gradebook->save($params);
//Reloading cats
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
}
}
}
$i = 0;
foreach ($cats as $cat) {
@ -869,51 +858,10 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
if (api_is_allowed_to_edit(null,true)) {
//Showing the grading system
if (!empty($grading_string)) {
Display::display_normal_message(get_lang('GradeModel').': '.$grading_string);
}
}
$obj = new GradeModel();
$grade_models = $obj->get_all();
$options = array(0 => get_lang('none'));
foreach ($grade_models as $item) {
$options[$item['id']] = $item['name'];
}
//No children
if (empty($allcat)) {
$form = new FormValidator('grade_model_settings');
$form->addElement('select', 'grade_model', get_lang('SelectGradeModel'), $options);
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
$form->display();
if ($form->validate()) {
$value = $form->exportValue('grade_model');
$gradebook = new Gradebook();
$gradebook->update(array('id'=> $cat->get_id(), 'grade_model_id' => $value), true);
//do something
$obj = new GradeModel();
$components = $obj->get_components($value);
foreach ($components as $component) {
$gradebook = new Gradebook();
$params = array();
$params['name'] = $component['acronym'];
$params['description'] = $component['title'];
$params['user_id'] = api_get_user_id();
$params['parent_id'] = $cat->get_id();
$params['weight'] = $component['percentage'];
$params['session_id'] = api_get_session_id();
$params['course_code'] = api_get_course_id();
$params['grade_model_id'] = api_get_session_id();
$gradebook->save($params);
}
}
}
if (!empty($grade_models[$grade_model_id])) {
Display::display_normal_message(get_lang('GradeModel').': '.$grade_models[$grade_model_id]['name']);
}
}
$gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams);
$gradebooktable->display();
}

@ -334,12 +334,11 @@ class Category implements GradebookItem
}
/**
* Update the properties of this category in the database
* @todo fix me
*/
public function save() {
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'UPDATE '.$tbl_grade_categories
." SET name = '".Database::escape_string($this->get_name())."'"
.', description = ';
$sql = 'UPDATE '.$tbl_grade_categories." SET name = '".Database::escape_string($this->get_name())."'".', description = ';
if (isset($this->description)) {
$sql .= "'".Database::escape_string($this->get_description())."'";
} else {
@ -364,13 +363,17 @@ class Category implements GradebookItem
} else {
$sql .= 'null';
}
if (isset($this->grade_model_id)) {
$sql .= ', grade_model_id = '.intval($this->get_grade_model_id());
}
$sql .= ', weight = '.Database::escape_string($this->get_weight())
.', visible = '.intval($this->is_visible())
.' WHERE id = '.intval($this->id);
Database::query($sql);
$gradebook= new Gradebook();
$res = $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false));
$gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false));
}

@ -208,8 +208,7 @@ class Evaluation implements GradebookItem
/**
* Insert this evaluation into the database
*/
public function add()
{
public function add() {
if (isset($this->name) && isset($this->user_id) && isset($this->weight) && isset ($this->eval_max) && isset($this->visible)) {
$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
@ -228,7 +227,7 @@ class Evaluation implements GradebookItem
$sql .= ',type';
$sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
.','.intval($this->get_user_id())
.','.intval($this->get_weight())
.','.floatval($this->get_weight())
.','.intval($this->get_max())
.','.intval($this->is_visible());
if (isset($this->description)) {
@ -301,11 +300,12 @@ class Evaluation implements GradebookItem
} else {
$sql .= 'null';
}
$sql .= ', weight = '.Database::escape_string($this->get_weight())
$sql .= ', weight = "'.Database::escape_string($this->get_weight()).'" '
.', max = '.Database::escape_string($this->get_max())
.', visible = '.intval($this->is_visible())
.' WHERE id = '.intval($this->id);
//recorded history
$eval_log=new Evaluation();
$eval_log->add_evaluation_log($this->id);
Database::query($sql);

@ -115,13 +115,23 @@ class CatForm extends FormValidator {
* Builds an form to edit a category
*/
protected function build_editing_form() {
$skills = $this->category_object->get_skills_for_select();
$skills = $this->category_object->get_skills_for_select();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
//Freeze or not
$test_cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
$links = $test_cats[0]->get_links();
$grade_model_id = $this->category_object->get_grade_model_id();
if (empty($links)) {
$grade_model_id = 0;
}
$this->setDefaults(array(
'name' => $this->category_object->get_name(),
'description' => $this->category_object->get_description(),
'hid_user_id' => $this->category_object->get_user_id(),
'hid_parent_id' => $this->category_object->get_parent_id(),
'grade_model_id' => $grade_model_id,
'skills' => $skills,
'weight' => $this->category_object->get_weight(),
'visible' => $this->category_object->is_visible(),
@ -135,8 +145,7 @@ class CatForm extends FormValidator {
private function build_basic_form() {
$this->addElement('hidden', 'zero', 0);
$this->add_textfield('name', get_lang('CategoryName'), true, array('size'=>'54','maxlength'=>'50'));
$this->add_textfield('name', get_lang('CategoryName'), true, array('size'=>'54','maxlength'=>'50'));
$this->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
if (isset($this->category_object) && $this->category_object->get_parent_id() == 0) {
@ -157,8 +166,7 @@ class CatForm extends FormValidator {
$grading_contents = api_grading_model_functions($grading_model, 'to_array');
*/
if (0) {
if (0) {
/*$course_code = api_get_course_id();
$session_id = api_get_session_id();
@ -174,13 +182,18 @@ class CatForm extends FormValidator {
//$this->addRule('weight',get_lang('ThisFieldIsRequired'),'required');
$this->freeze('weight'); */
} else {
$this->add_textfield('weight', array(get_lang('TotalWeight'), get_lang('TotalSumOfWeights')), true, array('value'=>$value,'size'=>'4','maxlength'=>'5'));
$global_weight = api_get_setting('gradebook_default_weight');
if (isset($global_weight)) {
$value = $global_weight;
} else {
$value = 100;
}
$this->add_textfield('weight', array(get_lang('TotalWeight'), get_lang('TotalSumOfWeights')), true, array('value'=>$value, 'size'=>'4','maxlength'=>'5'));
$this->addRule('weight',get_lang('ThisFieldIsRequired'),'required');
}
if (api_is_platform_admin() || api_is_drh()) {
//the magic should be here
//the magic should be here
$skills = $this->category_object->get_skills();
$this->addElement('select', 'skills', array(get_lang('Skills'), get_lang('SkillsAchievedWhenAchievingThisGradebook')), null, array('id'=>'skills', 'multiple'=>'multiple'));
$content = '';
@ -205,8 +218,27 @@ class CatForm extends FormValidator {
$this->addElement('hidden','hid_user_id');
$this->addElement('hidden','hid_parent_id');
$this->addElement('textarea', 'description', get_lang('Description'),array('rows'=>'3','cols' => '34'));
$this->addElement('textarea', 'description', get_lang('Description'),array('class'=>'span3','cols' => '34'));
if (isset($this->category_object) && $this->category_object->get_parent_id() == 0) {
//Getting grade models
$obj = new GradeModel();
$grade_models = $obj->get_all();
$options = array(0 => get_lang('none'));
foreach ($grade_models as $item) {
$options[$item['id']] = $item['name'];
}
$this->addElement('select', 'grade_model_id', array(get_lang('GradeModel'), get_lang('OnlyActiveWhenThereAreAnyComponents')), $options);
//Freeze or not
$test_cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
$links = $test_cats[0]->get_links();
if (count($test_cats) > 1 || !empty($links)) {
$this->freeze('grade_model_id');
}
}
if ($this->form_type == self :: TYPE_ADD) {
$this->addElement('style_submit_button', null, get_lang('AddCategory'), 'class="save"');
} else {

@ -381,15 +381,10 @@ class DisplayGradebook
}
}
if (!$is_course_admin && $status<>1 && $selectcat<>0) {
$user_id = api_get_user_id();
//$user= get_user_info_from_id($user_id);
$catcourse = Category::load($catobj->get_id());
$scoredisplay = ScoreDisplay :: instance();
//$scorecourse = $catcourse[0]->calc_score($user_id);
$scoredisplay = ScoreDisplay :: instance();
// generating the total score for a course
$allevals= $catcourse[0]->get_evaluations($user_id,true);
@ -397,36 +392,30 @@ class DisplayGradebook
$evals_links = array_merge($allevals, $alllinks);
$item_value=0;
$item_total=0;
$item_total_value = 0;
for ($count=0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
$score = $item->calc_score($user_id);
$my_score_denom =($score[1]==0) ? 1 : $score[1];
$item_value = $score[0]/$my_score_denom * $item->get_weight();
//$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
//$percentage = round($item->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$catobj->get_weight(), 2);
//$item_value = $percentage*$item_value;
$item_value = $score[0]/$my_score_denom * $item->get_weight();
$sub_item_total = $item->get_weight();
//$item_total += $percentage*100;
$item_total += $item->get_weight();
$item_total_value += $item_value;
//$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
/*$item_value = $item_value*$catcourse[0]->get_weight();
$sub_item_total = $item->get_weight()*$catcourse[0]->get_weight();
*/
//var_dump($item_value.' - '.$sub_item_total);
$item_total += $sub_item_total;
$item_total_value += $item_value;
}
$item_total = round($item_total);
$item_value = number_format($item_total_value, 2);
//$item_value = number_format($item_total_value, api_get_setting('gradebook_number_decimals'));
$item_value = number_format($item_total_value, 2);
$total_score = array($item_value, $item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
//$cattotal = Category :: load(0);
//$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
//$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
//$scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['firstname'], $user['lastname']).'</b><br />';
if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search']))) {
$scoreinfo.= '<h2>'.get_lang('Total') . ' : ' . $scorecourse_display . '</h2>';
}

@ -285,7 +285,7 @@ class EvalForm extends FormValidator
$this->add_textfield($element_name,
$this->build_stud_label($user[0], $user[1], $user[2], $user[3]),
false,
array ('size' => 4,'maxlength' => 5));
array ('class' => 'span1','maxlength' => 5));
$this->addRule($element_name, get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array($element_name,'maxvalue'), get_lang('OverMax'), 'compare', '<=');
@ -381,20 +381,30 @@ class EvalForm extends FormValidator
/**
* Builds a form to edit an evaluation
*/
protected function build_editing_form() {
$this->setDefaults(array ( 'hid_id' => $this->evaluation_object->get_id(),
'name' => $this->evaluation_object->get_name(),
'description' => $this->evaluation_object->get_description(),
'hid_user_id' => $this->evaluation_object->get_user_id(),
'hid_course_code' => $this->evaluation_object->get_course_code(),
'hid_category_id' => $this->evaluation_object->get_category_id(),
'created_at' => api_get_utc_datetime($this->evaluation_object->get_date()),
'weight' => $this->evaluation_object->get_weight(), 'max' => $this->evaluation_object->get_max(), 'visible' => $this->evaluation_object->is_visible()));
protected function build_editing_form() {
$parent_cat = Category :: load($this->evaluation_object->get_category_id());
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
//$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$weight_mask = $global_weight*$this->evaluation_object->get_weight()/$parent_cat[0]->get_weight() ;
$this->setDefaults(array ( 'hid_id' => $this->evaluation_object->get_id(),
'name' => $this->evaluation_object->get_name(),
'description' => $this->evaluation_object->get_description(),
'hid_user_id' => $this->evaluation_object->get_user_id(),
'hid_course_code' => $this->evaluation_object->get_course_code(),
'hid_category_id' => $this->evaluation_object->get_category_id(),
'created_at' => api_get_utc_datetime($this->evaluation_object->get_date()),
'weight' => $weight,
'weight_mask' => $weight_mask,
'max' => $this->evaluation_object->get_max(),
'visible' => $this->evaluation_object->is_visible()));
$id_current=isset($this->id)?$this->id :null;
$this->addElement('hidden', 'hid_id',$id_current);
$this->addElement('hidden', 'hid_id', $id_current);
$this->build_basic_form(1);
$this->addElement('style_submit_button', 'submit', get_lang('ModifyEvaluation'),'class="save"');
}
/**
* Builds a basic form that is used in add and edit
*/
@ -432,14 +442,19 @@ class EvalForm extends FormValidator
if (!empty($all_categories)) {
foreach ($all_categories as $my_cat) {
if ($my_cat->get_course_code() == api_get_course_id()) {
if ($my_cat->get_parent_id() == 0 ) {
$default_weight = $my_cat->get_weight();
$select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
if ($my_cat->get_course_code() == api_get_course_id()) {
$grade_model_id = $my_cat->get_grade_model_id();
if (empty($grade_model_id)) {
if ($my_cat->get_parent_id() == 0) {
$default_weight = $my_cat->get_weight();
$select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
} else {
$select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
}
} else {
$select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
$select_gradebook->addoption(get_lang('Select'), 0);
}
if ($this->evaluation_object->get_category_id() == $my_cat->get_id()) {
$default_weight = $my_cat->get_weight();
@ -447,14 +462,21 @@ class EvalForm extends FormValidator
}
}
}
$global_weight = api_get_setting('gradebook_default_weight');
$this->add_textfield('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$global_weight.'] '), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));
/*$this->add_textfield('weight', array(null, null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));*/
if ($edit) {
if (!$this->evaluation_object->has_results()) {
$this->add_textfield('max', get_lang('QualificationNumeric'), true, array (
@ -480,8 +502,8 @@ class EvalForm extends FormValidator
'cols' => '34'
));
$this->addElement('checkbox', 'visible', null, get_lang('Visible'));
$this->addRule('weight', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array ('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
}

@ -134,6 +134,7 @@ class GradebookTable extends SortableTable {
//status of user in course
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$status_user = api_get_status_of_user_in_course($user_id, $course_code);
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
@ -143,7 +144,8 @@ class GradebookTable extends SortableTable {
$weight_total_links = 0;
$main_categories = array();
$main_cat = Category :: load(null, null, $course_code, null, null, $session_id, false);
foreach ($data_array as $data) {
// list of items inside the gradebook (exercises, lps, forums, etc)
@ -157,9 +159,10 @@ class GradebookTable extends SortableTable {
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
if (api_is_allowed_to_edit(null, true)) {
//id
$row[] = $this->build_id_column($item);
}
}
//Type
$row[] = $this->build_type_column($item);
//Name
@ -174,9 +177,14 @@ class GradebookTable extends SortableTable {
//Description
$row[] = $invisibility_span_open.$data[2] . $invisibility_span_close;
//Weight
$row[] = $invisibility_span_open .Display::tag('h4', $data[3] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;
//$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;
//$average = $data['3']/$this->currentcat->get_weight()*100;
$scoredisplay = ScoreDisplay :: instance();
$average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_PERCENT, SCORE_BOTH, true);
$row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;
$category_weight = $item->get_weight();
@ -186,13 +194,13 @@ class GradebookTable extends SortableTable {
$cattotal = Category :: load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$item_value = $scoretotal[0];
$item_value = number_format($item_value, 2, '.', ' ');
$item_value = number_format($item_value, api_get_setting('gradebook_number_decimals'), '.', ' ');
}
//Date
//$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
//Admins get an edit column
//Edit (for admins)
if (api_is_allowed_to_edit(null, true)) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
@ -236,8 +244,7 @@ class GradebookTable extends SortableTable {
//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>' : '';
$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();
@ -251,10 +258,13 @@ class GradebookTable extends SortableTable {
$row[] = $invisibility_span_open."&nbsp;&nbsp;&nbsp; ".$this->build_name_link($item) . $invisibility_span_close;
//Description
//$row[] = $invisibility_span_open.$data[2] . $invisibility_span_close;
$row[] = $invisibility_span_open.$data[2] . $invisibility_span_close;
//Weight
$row[] = $invisibility_span_open . $data[3] .' / '.$category_weight.$invisibility_span_close;
//$row[] = $invisibility_span_open . $data[3] .' / '.$category_weight.$invisibility_span_close;
$weight = $data[3]/$category_weight*$main_cat[0]->get_weight();
$row[] = $invisibility_span_open . $weight.$invisibility_span_close;
if (api_is_allowed_to_edit(null, true)) {
//$weight_total_links += intval($data[3]);
@ -282,6 +292,8 @@ class GradebookTable extends SortableTable {
if (count($eval_n_links)> 0 && $status_user!=1 ) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
//$my_score = $data[5]->get_eval_max()/;
//var_dump($data[5]);
$row[] = $value_data;
}
}
@ -494,7 +506,7 @@ class GradebookTable extends SortableTable {
switch ($item->get_item_type()) {
// category
case 'C' :
return build_edit_icons_cat($item, $this->currentcat->get_id());
return build_edit_icons_cat($item, $this->currentcat);
// evaluation
case 'E' :
return build_edit_icons_eval($item, $this->currentcat->get_id());

@ -83,17 +83,32 @@ class LinkAddEditForm extends FormValidator
}
}
$global_weight = api_get_setting('gradebook_default_weight');
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$global_weight.'] '), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));
/*
// ELEMENT: weight
$this->add_textfield('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));
));*/
$this->addRule('weight',get_lang('OnlyNumbers'),'numeric');
$this->addRule(array ('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT) {
$defaults['weight'] = $link->get_weight();
$this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric');
$this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT) {
$parent_cat = Category :: load($link->get_category_id());
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
//$defaults['weight'] = $link->get_weight();
$defaults['weight_mask'] = $values['weight'] ;
$defaults['select_gradebook'] = $link->get_category_id();
}

@ -101,7 +101,9 @@ class GradebookDataGenerator
}*/
if (count($this->evals_links) > 0) {
if (!api_is_allowed_to_edit() || $status_user != 1 ) {
$row[] = $this->build_result_column($item, $ignore_score_color);
$row[] = $item;
}
}
$data[] = $row;
@ -216,7 +218,7 @@ class GradebookDataGenerator
return null;
}
private function build_date_column ($item) {
private function build_date_column($item) {
$date = $item->get_date();
if (!isset($date) || empty($date)) {
return '';

@ -196,11 +196,18 @@ function get_icon_file_name ($type) {
* @param int $selectcat id of selected category
*/
function build_edit_icons_cat($cat, $selectcat) {
$show_message=$cat->show_message_resource_delete($cat->get_course_code());
$show_message = $cat->show_message_resource_delete($cat->get_course_code());
$grade_model_id = $selectcat->get_grade_model_id();
$selectcat = $selectcat->get_id();
if ($show_message===false) {
$visibility_icon= ($cat->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command= ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible';
$modify_icons= '<a href="gradebook_edit_cat.php?editcat='.$cat->get_id().'&amp;cidReq='.$cat->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
if (empty($grade_model_id)) {
$modify_icons= '<a href="gradebook_edit_cat.php?editcat='.$cat->get_id().'&amp;cidReq='.$cat->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $cat->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . ' ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).'</a>';
@ -212,8 +219,10 @@ function build_edit_icons_cat($cat, $selectcat) {
//$modify_icons .= '&nbsp;<img src="../img/deplacer_fichier_na.gif" border="0" title="' . get_lang('Move') . '" alt="" />';
}
$modify_icons .= ' <a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;cidReq='.$cat->get_course_code().'&selectcat=' . $cat->get_id() . '"> '.
if (empty($grade_model_id)) {
$modify_icons .= ' <a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;cidReq='.$cat->get_course_code().'&selectcat=' . $cat->get_id() . '"> '.
Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_SMALL).' </a>';
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '&amp;cidReq='.$cat->get_course_code().'" onclick="return confirmation();">'.Display::return_icon('delete.png', get_lang('DeleteAll'),'',ICON_SIZE_SMALL).'</a>';

@ -683,15 +683,12 @@ class IndexManager {
$id_label = null;
if (!empty($id)) {
$id_label = " id = $id ";
}
$html= '<div '.$id_label.' class="well sidebar-nav">';
//$html.= '<div class="menusection">';
}
$html= '<div '.$id_label.' class="well sidebar-nav">';
if (!empty($title)) {
$html.= '<h4>'.$title.'</h4>';
}
$html.= $content;
//$html.= '</div>';
$html.= $content;
$html.= '</div>';
return $html;
}

@ -851,7 +851,8 @@ VALUES
('courses_default_creation_visibility', NULL, 'radio', 'Course', '2', 'CoursesDefaultCreationVisibilityTitle', 'CoursesDefaultCreationVisibilityComment', NULL, NULL, 1),
('allow_browser_sniffer', NULL, 'radio', 'Tuning', 'false', 'AllowBrowserSnifferTitle', 'AllowBrowserSnifferComment', NULL, NULL, 0),
('enable_wami_record',NULL,'radio','Tools','false','EnableWamiRecordTitle','EnableWamiRecordComment',NULL,NULL, 0),
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.17486','DatabaseVersion','', NULL, NULL, 0);
('gradebook_default_weight', NULL, 'textfield', 'Gradebook', '100', 'GradebookDefaultWeightTitle', 'GradebookDefaultWeightComment', NULL, NULL, 0),
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.17536','DatabaseVersion','', NULL, NULL, 0);
/*
('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1),
@ -1349,7 +1350,7 @@ CREATE TABLE IF NOT EXISTS gradebook_evaluation (
course_code varchar(40) default NULL,
category_id int default NULL,
created_at DATETIME NOT NULL default '0000-00-00 00:00:00',
weight smallint NOT NULL,
weight FLOAT NOT NULL,
max float unsigned NOT NULL,
visible tinyint NOT NULL,
type varchar(40) NOT NULL default 'evaluation',

@ -146,6 +146,7 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value,
INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_wami_record', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_wami_record', 'false', 'No');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('gradebook_default_weight', NULL, 'textfield', 'Gradebook', '100', 'GradebookDefaultWeightTitle', 'GradebookDefaultWeightComment', NULL, NULL, 0);
-- Course ranking
@ -173,9 +174,10 @@ CREATE TABLE grade_model (id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255)
CREATE TABLE grade_components (id INTEGER NOT NULL AUTO_INCREMENT, percentage VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, acronym VARCHAR(255) NOT NULL, grade_model_id INTEGER NOT NULL, PRIMARY KEY (id));
ALTER TABLE gradebook_category ADD COLUMN grade_model_id INT DEFAULT 0;
UPDATE settings_current SET title = 'DatabaseVersion' WHERE variable = 'chamilo_database_version';
ALTER TABLE gradebook_evaluation MODIFY COLUMN weight FLOAT NOT NULL;
-- Do not move this query
UPDATE settings_current SET selected_value = '1.9.0.17486' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.9.0.17536' WHERE variable = 'chamilo_database_version';
-- xxSTATSxx
ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT '';
@ -201,4 +203,6 @@ ALTER TABLE student_publication ADD COLUMN allow_text_assignment INTEGER NOT NUL
ALTER TABLE quiz ADD COLUMN random_by_category INT NOT NULL DEFAULT 0;
ALTER TABLE quiz ADD COLUMN text_when_finished TEXT DEFAULT NULL;
ALTER TABLE quiz ADD COLUMN display_category_name INT NOT NULL DEFAULT 1;
ALTER TABLE quiz ADD COLUMN pass_percentage INT DEFAULT NULL;
ALTER TABLE quiz ADD COLUMN pass_percentage INT DEFAULT NULL;

@ -1,10 +1,5 @@
<div id="login_block" class="well sidebar-nav">
<div class="menusection">
<span class="menusectioncaption">
{{"Login"|get_lang}}
</span>
</div>
{{ login_language_form }}
{% if plugin_login_top is not null %}

Loading…
Cancel
Save