Undo changes due recent merge

skala
Julio Montoya 13 years ago
parent ee8712d231
commit c08bf11d34
  1. 17
      .gitignore
  2. 17
      main/css/base.css
  3. 52
      main/document/document.php
  4. 213
      main/gradebook/lib/be/category.class.php
  5. 716
      main/gradebook/lib/fe/evalform.class.php
  6. 936
      main/inc/lib/sortable_table.class.php
  7. 1093
      main/inc/lib/userportal.lib.php
  8. 4849
      main/survey/survey.lib.php

17
.gitignore vendored

@ -1,22 +1,10 @@
# Chamilo configuration # Chamilo configuration
main/inc/conf main/inc/conf
<<<<<<< HEAD
app/cache/* app/cache/*
app/config/* app/config/*
app/data/* app/data/*
app/logs/* app/logs/*
# Temp directories
archive/*
archive/.htaccess
archive/index.html
=======
# Temp directories
archive/*
!archive/.htaccess
>>>>>>> julio19x
# Courses # Courses
courses/* courses/*
@ -44,10 +32,5 @@ searchdb/*
.idea/cssxfire.xml .idea/cssxfire.xml
*.orig *.orig
<<<<<<< HEAD
nbproject/* nbproject/*
vendor/.git vendor/.git
=======
nbproject/*
>>>>>>> julio19x

@ -262,27 +262,10 @@ form .formw input {
margin-top: 2px; margin-top: 2px;
} }
<<<<<<< HEAD
#accept_licence, #checkbox { #accept_licence, #checkbox {
margin-right: 5px; margin-right: 5px;
margin-top: -1px; margin-top: -1px;
=======
/* end chamilo forms fixes */
#top_main_content .span3 {
float: left;
}
#top_main_content .control-group .span3 {
float: none;
} }
#top_main_content .span9 {
float: left;
}
#top_main_content .span6 {
width: 460px;
>>>>>>> julio19x
}
/* end chamilo forms fixes */ /* end chamilo forms fixes */
/* New changes Chamilo 1.9 */ /* New changes Chamilo 1.9 */

@ -1152,10 +1152,10 @@ if ($curdirpath != '/' && $curdirpath != $group_properties['directory'] && !$is_
if ($is_certificate_mode && $curdirpath != '/certificates') { if ($is_certificate_mode && $curdirpath != '/certificates') {
?> ?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq(); ?>&amp;curdirpath=<?php echo urlencode( <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq(); ?>&amp;curdirpath=<?php echo urlencode(
(dirname($curdirpath) == '\\') ? '/' : dirname($curdirpath) (dirname($curdirpath) == '\\') ? '/' : dirname($curdirpath)
); ?>"> ); ?>">
<?php Display::display_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
@ -1175,15 +1175,15 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
// Create new document // Create new document
if (!$is_certificate_mode) { if (!$is_certificate_mode) {
?> ?>
<a href="create_document.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>"> <a href="create_document.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>">
<?php Display::display_icon('new_document.png', get_lang('CreateDoc'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_document.png', get_lang('CreateDoc'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
// Create new draw // Create new draw
if (api_get_setting('enabled_support_svg') == 'true') { if (api_get_setting('enabled_support_svg') == 'true') {
if (api_browser_support('svg')) { if (api_browser_support('svg')) {
?> ?>
<a href="create_draw.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>"> <a href="create_draw.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>">
<?php Display::display_icon('new_draw.png', get_lang('Draw'), '', ICON_SIZE_MEDIUM); ?></a>&nbsp; <?php Display::display_icon('new_draw.png', get_lang('Draw'), '', ICON_SIZE_MEDIUM); ?></a>&nbsp;
<?php <?php
} else { } else {
Display::display_icon('new_draw_na.png', get_lang('BrowserDontSupportsSVG'), '', ICON_SIZE_MEDIUM); Display::display_icon('new_draw_na.png', get_lang('BrowserDontSupportsSVG'), '', ICON_SIZE_MEDIUM);
@ -1193,8 +1193,8 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
// Create new paint // Create new paint
if (api_get_setting('enabled_support_pixlr') == 'true') { if (api_get_setting('enabled_support_pixlr') == 'true') {
?> ?>
<a href="create_paint.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>"> <a href="create_paint.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>">
<?php Display::display_icon('new_paint.png', get_lang('PhotoRetouching'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_paint.png', get_lang('PhotoRetouching'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
@ -1202,24 +1202,24 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
// Record an image clip from my webcam // Record an image clip from my webcam
if (api_get_setting('enable_webcam_clip') == 'true') { if (api_get_setting('enable_webcam_clip') == 'true') {
?> ?>
<a href="webcam_clip.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>"> <a href="webcam_clip.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>">
<?php Display::display_icon('webcam.png', get_lang('WebCamClip'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('webcam.png', get_lang('WebCamClip'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
// Record audio (nanogong) // Record audio (nanogong)
if (api_get_setting('enable_nanogong') == 'true') { if (api_get_setting('enable_nanogong') == 'true') {
?> ?>
<a href="record_audio.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>"> <a href="record_audio.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>">
<?php Display::display_icon('new_recording.png', get_lang('RecordMyVoice'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_recording.png', get_lang('RecordMyVoice'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
// Record audio (wami record) // Record audio (wami record)
if (api_get_setting('enable_wami_record') == 'true') { if (api_get_setting('enable_wami_record') == 'true') {
?> ?>
<a href="record_audio_wami.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>"> <a href="record_audio_wami.php?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>">
<?php Display::display_icon('new_recording.png', get_lang('RecordMyVoice'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_recording.png', get_lang('RecordMyVoice'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
@ -1228,8 +1228,8 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
$dt2a = 'google'; $dt2a = 'google';
$req_dt2a = '&amp;dt2a='.$dt2a; $req_dt2a = '&amp;dt2a='.$dt2a;
?> ?>
<a href="create_audio.php?<?php echo api_get_cidreq(); ?>&amp;id=<?php echo $document_id.$req_dt2a; ?>"> <a href="create_audio.php?<?php echo api_get_cidreq(); ?>&amp;id=<?php echo $document_id.$req_dt2a; ?>">
<?php Display::display_icon('new_sound.png', get_lang('CreateAudio'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_sound.png', get_lang('CreateAudio'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
} }
@ -1237,9 +1237,9 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
// Create new certificate // Create new certificate
if ($is_certificate_mode) { if ($is_certificate_mode) {
?> ?>
<a href="create_document.php?<?php echo api_get_cidreq( <a href="create_document.php?<?php echo api_get_cidreq(
); ?>&id=<?php echo $document_id; ?>&certificate=true&selectcat=<?php echo $selectcat; ?>"> ); ?>&id=<?php echo $document_id; ?>&certificate=true&selectcat=<?php echo $selectcat; ?>">
<?php Display::display_icon('new_certificate.png', get_lang('CreateCertificate'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_certificate.png', get_lang('CreateCertificate'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
// File upload link // File upload link
@ -1258,8 +1258,8 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
// Create directory // Create directory
if (!$is_certificate_mode) { if (!$is_certificate_mode) {
?> ?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>&createdir=1"> <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq(); ?>&id=<?php echo $document_id; ?>&createdir=1">
<?php Display::display_icon('new_folder.png', get_lang('CreateDir'), '', ICON_SIZE_MEDIUM); ?></a> <?php Display::display_icon('new_folder.png', get_lang('CreateDir'), '', ICON_SIZE_MEDIUM); ?></a>
<?php <?php
} }
} }
@ -1268,7 +1268,6 @@ $table_footer = '';
$total_size = 0; $total_size = 0;
if (isset($docs_and_folders) && is_array($docs_and_folders)) { if (isset($docs_and_folders) && is_array($docs_and_folders)) {
<<<<<<< HEAD
if (api_get_group_id() == 0 || (api_is_allowed_to_edit() || GroupManager::is_subscribed( if (api_get_group_id() == 0 || (api_is_allowed_to_edit() || GroupManager::is_subscribed(
api_get_user_id(), api_get_user_id(),
api_get_group_id() api_get_group_id()
@ -1276,9 +1275,6 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
api_get_user_id() api_get_user_id()
)) ))
) { ) {
=======
if (api_get_group_id() == 0 || ( api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()))) {
>>>>>>> julio19x
// Create a sortable table with our data // Create a sortable table with our data
$sortable_data = array(); $sortable_data = array();

@ -224,11 +224,11 @@ class Category implements GradebookItem
$sql .= " AND (session_id IS NULL OR session_id = 0) "; $sql .= " AND (session_id IS NULL OR session_id = 0) ";
} else {*/ } else {*/
if (empty($session_id)) { if (empty($session_id)) {
$sql .= ' AND (session_id IS NULL OR session_id = 0) '; $sql .= ' AND (session_id IS NULL OR session_id = 0) ';
} else { } else {
$sql .= ' AND session_id = '.(int) $session_id.' '; $sql .= ' AND session_id = '.(int) $session_id.' ';
} }
//} //}
$paramcount ++; $paramcount ++;
} }
@ -246,9 +246,9 @@ class Category implements GradebookItem
if (isset($visible)) { if (isset($visible)) {
$visible = Database::escape_string($visible); $visible = Database::escape_string($visible);
if ($paramcount != 0) { if ($paramcount != 0) {
$sql .= ' AND'; $sql .= ' AND';
} else { } else {
$sql .= ' WHERE'; $sql .= ' WHERE';
} }
$sql .= ' visible = '.intval($visible); $sql .= ' visible = '.intval($visible);
$paramcount ++; $paramcount ++;
@ -319,7 +319,7 @@ class Category implements GradebookItem
$sql .= ',course_code'; $sql .= ',course_code';
} }
if (isset($this->parent)) { if (isset($this->parent)) {
$sql .= ',parent_id'; $sql .= ',parent_id';
} }
if (!empty($this->session_id)) { if (!empty($this->session_id)) {
$sql .= ', session_id'; $sql .= ', session_id';
@ -345,9 +345,9 @@ class Category implements GradebookItem
$visible = intval($this->is_visible()); $visible = intval($this->is_visible());
$sql .= ") VALUES ('".Database::escape_string($this->get_name())."'" $sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
.','.intval($this->get_user_id()) .','.intval($this->get_user_id())
.','.Database::escape_string($this->get_weight()) .','.Database::escape_string($this->get_weight())
.','.$visible; .','.$visible;
if (isset($this->description)) { if (isset($this->description)) {
$sql .= ",'".Database::escape_string($this->get_description())."'"; $sql .= ",'".Database::escape_string($this->get_description())."'";
} }
@ -355,7 +355,7 @@ class Category implements GradebookItem
$sql .= ",'".Database::escape_string($this->get_course_code())."'"; $sql .= ",'".Database::escape_string($this->get_course_code())."'";
} }
if (isset($this->parent)) { if (isset($this->parent)) {
$sql .= ','.intval($this->get_parent_id()); $sql .= ','.intval($this->get_parent_id());
} }
if (!empty($this->session_id)) { if (!empty($this->session_id)) {
$sql .= ', '.intval($this->get_session_id()); $sql .= ', '.intval($this->get_session_id());
@ -430,7 +430,7 @@ class Category implements GradebookItem
} else { } else {
$sql .= 'null'; $sql .= 'null';
} }
$sql .= ', parent_id = '; $sql .= ', parent_id = ';
if (isset($this->parent)) { if (isset($this->parent)) {
$sql .= intval($this->get_parent_id()); $sql .= intval($this->get_parent_id());
} else { } else {
@ -550,17 +550,17 @@ class Category implements GradebookItem
/** /**
* Shows all information of an category * Shows all information of an category
*/ */
public function shows_all_information_an_category ($selectcat='') { public function shows_all_information_an_category ($selectcat='') {
if($selectcat=='') { if($selectcat=='') {
return null; return null;
} else { } else {
$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql='SELECT name,description,user_id,course_code,parent_id,weight,visible,certif_min_score,session_id FROM '.$tbl_category.' c WHERE c.id='.intval($selectcat); $sql='SELECT name,description,user_id,course_code,parent_id,weight,visible,certif_min_score,session_id FROM '.$tbl_category.' c WHERE c.id='.intval($selectcat);
$result=Database::query($sql); $result=Database::query($sql);
$row=Database::fetch_array($result,'ASSOC'); $row=Database::fetch_array($result,'ASSOC');
return $row; return $row;
} }
} }
// OTHER FUNCTIONS // OTHER FUNCTIONS
/** /**
@ -575,8 +575,8 @@ class Category implements GradebookItem
} }
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT count(id) AS number' $sql = 'SELECT count(id) AS number'
.' FROM '.$tbl_grade_categories .' FROM '.$tbl_grade_categories
." WHERE name = '".Database::escape_string($name)."'"; ." WHERE name = '".Database::escape_string($name)."'";
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
$parent = Category::load($parent); $parent = Category::load($parent);
@ -584,10 +584,10 @@ class Category implements GradebookItem
if (isset($code) && $code != '0') { if (isset($code) && $code != '0') {
$main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql .= ' AND user_id IN (' $sql .= ' AND user_id IN ('
.' SELECT user_id FROM '.$main_course_user_table .' SELECT user_id FROM '.$main_course_user_table
." WHERE course_code = '".Database::escape_string($code)."'" ." WHERE course_code = '".Database::escape_string($code)."'"
.' AND status = '.COURSEMANAGER .' AND status = '.COURSEMANAGER
.')'; .')';
} else { } else {
$sql .= ' AND user_id = '.api_get_user_id(); $sql .= ' AND user_id = '.api_get_user_id();
} }
@ -608,8 +608,8 @@ class Category implements GradebookItem
/** /**
* Checks if the certificate is available for the given user in this category * Checks if the certificate is available for the given user in this category
* @param integer User ID * @param integer User ID
* @return boolean True if conditions match, false if fails * @return boolean True if conditions match, false if fails
*/ */
public function is_certificate_available($user_id) { public function is_certificate_available($user_id) {
$score = $this->calc_score($user_id, $this->course_code); $score = $this->calc_score($user_id, $this->course_code);
@ -627,34 +627,6 @@ class Category implements GradebookItem
* A category is a course if it has a course code and no parent category. * A category is a course if it has a course code and no parent category.
*/ */
public function is_course() { public function is_course() {
<<<<<<< HEAD
return (isset($this->course_code) && !empty($this->course_code)
&& (!isset($this->parent) || $this->parent == 0));
}
/**
* Calculate the score of this category
* @param $stud_id student id (default: all students - then the average is returned)
* @return array (score sum, weight sum)
* or null if no scores available
*/
public function calc_score ($stud_id = null, $course_code = '', $session_id = null) {
// get appropriate subcategories, evaluations and links
if (!empty($course_code)) {
$cats = $this->get_subcategories($stud_id, $course_code, $session_id);
$evals = $this->get_evaluations($stud_id, false, $course_code);
$links = $this->get_links($stud_id, false, $course_code);
} else {
$cats = $this->get_subcategories($stud_id);
$evals = $this->get_evaluations($stud_id);
$links = $this->get_links($stud_id);
}
// calculate score
$rescount = 0;
$ressum = 0;
$weightsum = 0;
=======
return (isset($this->course_code) && !empty($this->course_code) return (isset($this->course_code) && !empty($this->course_code)
&& (!isset($this->parent) || $this->parent == 0)); && (!isset($this->parent) || $this->parent == 0));
} }
@ -662,8 +634,8 @@ class Category implements GradebookItem
/** /**
* Calculate the score of this category * Calculate the score of this category
* @param $stud_id student id (default: all students - then the average is returned) * @param $stud_id student id (default: all students - then the average is returned)
* @return array (score sum, weight sum) * @return array (score sum, weight sum)
* or null if no scores available * or null if no scores available
*/ */
public function calc_score ($stud_id = null, $course_code = '', $session_id = null) { public function calc_score ($stud_id = null, $course_code = '', $session_id = null) {
// get appropriate subcategories, evaluations and links // get appropriate subcategories, evaluations and links
@ -681,13 +653,6 @@ class Category implements GradebookItem
$rescount = 0; $rescount = 0;
$ressum = 0; $ressum = 0;
$weightsum = 0; $weightsum = 0;
/*$debug = false;
if ($stud_id == 11) {
$debug = true;
}
if ($debug) var_dump($links);*/
>>>>>>> julio19x
if (!empty($cats)) { if (!empty($cats)) {
foreach ($cats as $cat) { foreach ($cats as $cat) {
@ -700,28 +665,6 @@ class Category implements GradebookItem
if (isset($catres)) { if (isset($catres)) {
$ressum += (($catres[0]/$catres[1]) * $catweight); $ressum += (($catres[0]/$catres[1]) * $catweight);
} }
<<<<<<< HEAD
}
}
if (!empty($evals)) {
foreach ($evals as $eval) {
$evalres = $eval->calc_score($stud_id);
if (isset($evalres) && $eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$rescount++;
$weightsum += $evalweight;
$ressum += (($evalres[0]/$evalres[1]) * $evalweight);
} else {
}
}
}
if (!empty($links)) {
foreach ($links as $link) {
$linkres = $link->calc_score($stud_id);
=======
} }
} }
@ -742,8 +685,6 @@ class Category implements GradebookItem
if (!empty($links)) { if (!empty($links)) {
foreach ($links as $link) { foreach ($links as $link) {
$linkres = $link->calc_score($stud_id); $linkres = $link->calc_score($stud_id);
//if ($debug) var_dump($linkres);
>>>>>>> julio19x
if (isset($linkres) && $link->get_weight() != 0) { if (isset($linkres) && $link->get_weight() != 0) {
$linkweight = $link->get_weight(); $linkweight = $link->get_weight();
@ -808,8 +749,8 @@ class Category implements GradebookItem
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT *' $sql = 'SELECT *'
.' FROM '.$tbl_grade_categories .' FROM '.$tbl_grade_categories
.' WHERE parent_id = 0'; .' WHERE parent_id = 0';
if (!api_is_allowed_to_edit()) { if (!api_is_allowed_to_edit()) {
$sql .= ' AND visible = 1'; $sql .= ' AND visible = 1';
//proceed with checks on optional parameters course & session //proceed with checks on optional parameters course & session
@ -820,7 +761,7 @@ class Category implements GradebookItem
// could be an improvement // could be an improvement
if (!empty($session_id)) { if (!empty($session_id)) {
$sql .= " AND course_code = '".Database::escape_string($course_code)."'" $sql .= " AND course_code = '".Database::escape_string($course_code)."'"
." AND session_id = ".(int)$session_id; ." AND session_id = ".(int)$session_id;
} else { } else {
$sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0"; $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0";
} }
@ -848,11 +789,11 @@ class Category implements GradebookItem
} }
} else { } else {
$sql .= ' AND course_code in' $sql .= ' AND course_code in'
.' (SELECT course_code' .' (SELECT course_code'
.' FROM '.$main_course_user_table .' FROM '.$main_course_user_table
.' WHERE user_id = '.api_get_user_id() .' WHERE user_id = '.api_get_user_id()
.' AND status = '.COURSEMANAGER .' AND status = '.COURSEMANAGER
.')'; .')';
} }
}elseif (api_is_platform_admin()) { }elseif (api_is_platform_admin()) {
if (isset($session_id) && $session_id!=0) { if (isset($session_id) && $session_id!=0) {
@ -868,7 +809,7 @@ class Category implements GradebookItem
// course independent categories // course independent categories
if (empty($course_code)) { if (empty($course_code)) {
$cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats); $cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats);
} }
return $cats; return $cats;
@ -891,8 +832,8 @@ class Category implements GradebookItem
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT *' $sql = 'SELECT *'
.' FROM '.$tbl_grade_categories .' FROM '.$tbl_grade_categories
.' WHERE parent_id = 0'; .' WHERE parent_id = 0';
if (!empty($course_code)) { if (!empty($course_code)) {
$sql .= " AND course_code = '".Database::escape_string($course_code)."' "; $sql .= " AND course_code = '".Database::escape_string($course_code)."' ";
if (!empty($session_id)) { if (!empty($session_id)) {
@ -1057,7 +998,7 @@ class Category implements GradebookItem
$targets = Category::add_subtree($targets, $level+1, $cat->get_id(),null); $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),null);
} }
} }
else { // student else { // student
$cats = Category::get_root_categories_for_student(api_get_user_id()); $cats = Category::get_root_categories_for_student(api_get_user_id());
foreach ($cats as $cat) { foreach ($cats as $cat) {
$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
@ -1093,16 +1034,16 @@ class Category implements GradebookItem
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu' $sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu'
.' WHERE cc.code = cu.course_code' .' WHERE cc.code = cu.course_code'
.' AND cu.status = '.COURSEMANAGER; .' AND cu.status = '.COURSEMANAGER;
if (!api_is_platform_admin()) { if (!api_is_platform_admin()) {
$sql .= ' AND cu.user_id = '.$user_id; $sql .= ' AND cu.user_id = '.$user_id;
} }
$sql .= ' AND cc.code NOT IN' $sql .= ' AND cc.code NOT IN'
.' (SELECT course_code FROM '.$tbl_grade_categories .' (SELECT course_code FROM '.$tbl_grade_categories
.' WHERE parent_id = 0' .' WHERE parent_id = 0'
// .' AND user_id = '.$user_id // .' AND user_id = '.$user_id
.' AND course_code IS NOT null)'; .' AND course_code IS NOT null)';
$result = Database::query($sql); $result = Database::query($sql);
$cats=array(); $cats=array();
@ -1123,10 +1064,10 @@ class Category implements GradebookItem
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu' $sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu'
.' WHERE cc.code = cu.course_code' .' WHERE cc.code = cu.course_code'
.' AND cu.status = '.COURSEMANAGER; .' AND cu.status = '.COURSEMANAGER;
if (!api_is_platform_admin()) { if (!api_is_platform_admin()) {
$sql .= ' AND cu.user_id = '.intval($user_id); $sql .= ' AND cu.user_id = '.intval($user_id);
} }
$result = Database::query($sql); $result = Database::query($sql);
@ -1177,7 +1118,7 @@ class Category implements GradebookItem
return true; return true;
} else { } else {
$cats = Category::load(null, null, null, $this->id, $cats = Category::load(null, null, null, $this->id,
api_is_allowed_to_edit() ? null : 1); api_is_allowed_to_edit() ? null : 1);
foreach ($cats as $cat) { foreach ($cats as $cat) {
if ($cat->has_evaluations_with_results_for_student ($stud_id)) { if ($cat->has_evaluations_with_results_for_student ($stud_id)) {
return true; return true;
@ -1199,7 +1140,7 @@ class Category implements GradebookItem
$creator = (api_is_allowed_to_edit() && !api_is_platform_admin()) ? api_get_user_id() : null; $creator = (api_is_allowed_to_edit() && !api_is_platform_admin()) ? api_get_user_id() : null;
$crsindcats = Category::load(null,$creator,'0',$cat_id, $crsindcats = Category::load(null,$creator,'0',$cat_id,
api_is_allowed_to_edit() ? null : 1); api_is_allowed_to_edit() ? null : 1);
if (!empty($crsindcats)) { if (!empty($crsindcats)) {
foreach ($crsindcats as $crsindcat) { foreach ($crsindcats as $crsindcat) {
@ -1229,7 +1170,7 @@ class Category implements GradebookItem
*/ */
public function get_subcategories ($stud_id = null, $course_code = null, $session_id = null, $order = null) { public function get_subcategories ($stud_id = null, $course_code = null, $session_id = null, $order = null) {
// 1 student // 1 student
if (isset($stud_id)) { if (isset($stud_id)) {
// special case: this is the root // special case: this is the root
if ($this->id == 0) { if ($this->id == 0) {
return Category::get_root_categories_for_student ($stud_id, $course_code, $session_id); return Category::get_root_categories_for_student ($stud_id, $course_code, $session_id);
@ -1242,12 +1183,12 @@ class Category implements GradebookItem
// root // root
if ($this->id == 0) { if ($this->id == 0) {
return $this->get_root_categories_for_teacher(api_get_user_id(), $course_code, $session_id, false); return $this->get_root_categories_for_teacher(api_get_user_id(), $course_code, $session_id, false);
// inside a course // inside a course
} elseif (!empty($this->course_code)) { } elseif (!empty($this->course_code)) {
return Category::load(null, null, $this->course_code, $this->id, null, $session_id, $order); return Category::load(null, null, $this->course_code, $this->id, null, $session_id, $order);
} elseif (!empty($course_code)) { } elseif (!empty($course_code)) {
return Category::load(null, null, $course_code, $this->id, null, $session_id, $order); return Category::load(null, null, $course_code, $this->id, null, $session_id, $order);
// course independent // course independent
} else { } else {
return Category::load(null, api_get_user_id(), 0, $this->id, null); return Category::load(null, api_get_user_id(), 0, $this->id, null);
} }
@ -1331,8 +1272,8 @@ class Category implements GradebookItem
} elseif (isset($stud_id)) { } elseif (isset($stud_id)) {
// 1 student $stud_id // 1 student $stud_id
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$course_code, $this->id, $links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$course_code, $this->id,
api_is_allowed_to_edit() ? null : 1); api_is_allowed_to_edit() ? null : 1);
} elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) { } elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) {
// all students -> only for course/platform admin // all students -> only for course/platform admin
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id, null); $links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id, null);
} }
@ -1369,7 +1310,7 @@ class Category implements GradebookItem
public function get_icon_name() { public function get_icon_name() {
return 'cat'; return 'cat';
} }
/** /**
* Find category by name * Find category by name
* @param string $name_mask search string * @param string $name_mask search string
* @return array category objects matching the search criterium * @return array category objects matching the search criterium
@ -1385,16 +1326,16 @@ class Category implements GradebookItem
} }
/** /**
* This function, locks a category , only one who can unlock it is the platform administrator. * This function, locks a category , only one who can unlock it is the platform administrator.
* @param int locked 1 or unlocked 0 * @param int locked 1 or unlocked 0
* @return bool * @return bool
* *
* */ * */
function lock($locked) { function lock($locked) {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = "UPDATE $table SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'"; $sql = "UPDATE $table SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
Database::query($sql); Database::query($sql);
} }
function lock_all_items($locked) { function lock_all_items($locked) {
if (api_get_setting('gradebook_locking_enabled') == 'true') { if (api_get_setting('gradebook_locking_enabled') == 'true') {
@ -1455,10 +1396,10 @@ class Category implements GradebookItem
for ($count=0; $count < count($evals_links); $count++) { for ($count=0; $count < count($evals_links); $count++) {
$item = $evals_links[$count]; $item = $evals_links[$count];
$score = $item->calc_score($user_id); $score = $item->calc_score($user_id);
$divide = ( ($score[1])==0 ) ? 1 : $score[1]; $divide = ( ($score[1])==0 ) ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()]; $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$item_value = $score[0]/$divide*$item->get_weight()*$sub_cat_percentage/$main_weight; $item_value = $score[0]/$divide*$item->get_weight()*$sub_cat_percentage/$main_weight;
$item_total_value += $item_value; $item_total_value += $item_value;
} }
$item_total_value = (float)$item_total_value; $item_total_value = (float)$item_total_value;

@ -28,39 +28,39 @@ $(document).ready(function () {
class EvalForm extends FormValidator class EvalForm extends FormValidator
{ {
const TYPE_ADD= 1; const TYPE_ADD= 1;
const TYPE_EDIT= 2; const TYPE_EDIT= 2;
const TYPE_MOVE= 3; const TYPE_MOVE= 3;
const TYPE_RESULT_ADD= 4; const TYPE_RESULT_ADD= 4;
const TYPE_RESULT_EDIT= 5; const TYPE_RESULT_EDIT= 5;
const TYPE_ALL_RESULTS_EDIT= 6; const TYPE_ALL_RESULTS_EDIT= 6;
const TYPE_ADD_USERS_TO_EVAL= 7; const TYPE_ADD_USERS_TO_EVAL= 7;
private $evaluation_object; private $evaluation_object;
private $result_object; private $result_object;
private $extra; private $extra;
/** /**
* Builds a form containing form items based on a given parameter * Builds a form containing form items based on a given parameter
* @param int form_type 1=add, 2=edit,3=move,4=result_add * @param int form_type 1=add, 2=edit,3=move,4=result_add
* @param obj cat_obj the category object * @param obj cat_obj the category object
* @param obj res_obj the result object * @param obj res_obj the result object
* @param string form name * @param string form name
* @param method * @param method
* @param action * @param action
*/ */
public function __construct($form_type, $evaluation_object, $result_object, $form_name, $method= 'post', $action= null, $extra1 = null, $extra2 = null) { public function __construct($form_type, $evaluation_object, $result_object, $form_name, $method= 'post', $action= null, $extra1 = null, $extra2 = null) {
parent::__construct($form_name, $method, $action); parent::__construct($form_name, $method, $action);
if (isset ($evaluation_object)) { if (isset ($evaluation_object)) {
$this->evaluation_object= $evaluation_object; $this->evaluation_object= $evaluation_object;
} }
if (isset ($result_object)) { if (isset ($result_object)) {
$this->result_object= $result_object; $this->result_object= $result_object;
} }
if (isset ($extra1)) { if (isset ($extra1)) {
$this->extra = $extra1; $this->extra = $extra1;
} }
switch ($form_type) { switch ($form_type) {
case self :: TYPE_EDIT: case self :: TYPE_EDIT:
@ -85,48 +85,48 @@ class EvalForm extends FormValidator
$this->build_add_user_to_eval(); $this->build_add_user_to_eval();
break; break;
} }
$this->setDefaults(); $this->setDefaults();
} }
/** /**
* This form will build a form to add users to an evaluation * This form will build a form to add users to an evaluation
*/ */
protected function build_add_user_to_eval() { protected function build_add_user_to_eval() {
$this->addElement('header', get_lang('ChooseUser')); $this->addElement('header', get_lang('ChooseUser'));
$select= $this->addElement('select', 'firstLetterUser', get_lang('FirstLetter'), null, array( $select= $this->addElement('select', 'firstLetterUser', get_lang('FirstLetter'), null, array(
'onchange'=> 'document.add_users_to_evaluation.submit()' 'onchange'=> 'document.add_users_to_evaluation.submit()'
)); ));
$select->addOption('',''); $select->addOption('','');
for ($i = 65; $i <= 90; $i ++) { for ($i = 65; $i <= 90; $i ++) {
$letter = chr($i); $letter = chr($i);
if (isset($this->extra) && $this->extra == $letter) { if (isset($this->extra) && $this->extra == $letter) {
$select->addOption($letter,$letter,'selected'); $select->addOption($letter,$letter,'selected');
} else { } else {
$select->addOption($letter,$letter); $select->addOption($letter,$letter);
} }
} }
$select= $this->addElement('select', 'add_users', null, null, array ( $select= $this->addElement('select', 'add_users', null, null, array (
'multiple' => 'multiple', 'multiple' => 'multiple',
'size' => '15', 'size' => '15',
'style' => 'width:250px' 'style' => 'width:250px'
)); ));
foreach ($this->evaluation_object->get_not_subscribed_students() as $user) { foreach ($this->evaluation_object->get_not_subscribed_students() as $user) {
if ( (!isset($this->extra)) || empty($this->extra) || api_strtoupper(api_substr($user[1],0,1)) == $this->extra ) { if ( (!isset($this->extra)) || empty($this->extra) || api_strtoupper(api_substr($user[1],0,1)) == $this->extra ) {
$select->addoption($user[1] . ' ' . $user[2] . ' (' . $user[3] . ')', $user[0]); $select->addoption($user[1] . ' ' . $user[2] . ' (' . $user[3] . ')', $user[0]);
} }
} }
$this->addElement('submit', 'submit_button', get_lang('AddUserToEval')); $this->addElement('submit', 'submit_button', get_lang('AddUserToEval'));
} }
/** /**
* This function builds a form to edit all results in an evaluation * This function builds a form to edit all results in an evaluation
*/ */
protected function build_all_results_edit_form() { protected function build_all_results_edit_form() {
//extra field for check on maxvalue //extra field for check on maxvalue
$this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max()); $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
$this->addElement('hidden', 'minvalue', 0); $this->addElement('hidden', 'minvalue', 0);
$this->addElement('header', get_lang('EditResult')); $this->addElement('header', get_lang('EditResult'));
$renderer =& $this->defaultRenderer(); $renderer =& $this->defaultRenderer();
// set new form template // set new form template
$form_template = '<form{attributes}> $form_template = '<form{attributes}>
@ -136,19 +136,19 @@ class EvalForm extends FormValidator
$renderer->setFormTemplate($form_template); $renderer->setFormTemplate($form_template);
if (api_is_western_name_order()){ if (api_is_western_name_order()){
$renderer->setHeaderTemplate( $renderer->setHeaderTemplate(
'<tr> '<tr>
<th>'.get_lang('OfficialCode').'</th> <th>'.get_lang('OfficialCode').'</th>
<th>'.get_lang('UserName').'</th> <th>'.get_lang('UserName').'</th>
<th>'.get_lang('FirstName').'</th> <th>'.get_lang('FirstName').'</th>
<th>'.get_lang('LastName').'</th> <th>'.get_lang('LastName').'</th>
<th>'.get_lang('Qualify').'</th> <th>'.get_lang('Qualify').'</th>
</tr>' </tr>'
); );
} else { } else {
$renderer->setHeaderTemplate( $renderer->setHeaderTemplate(
'<tr> '<tr>
<th>'.get_lang('OfficialCode').'</th> <th>'.get_lang('OfficialCode').'</th>
<th>'.get_lang('UserName').'</th> <th>'.get_lang('UserName').'</th>
<th>'.get_lang('LastName').'</th> <th>'.get_lang('LastName').'</th>
<th>'.get_lang('FirstName').'</th> <th>'.get_lang('FirstName').'</th>
@ -156,7 +156,7 @@ class EvalForm extends FormValidator
</tr>' </tr>'
); );
} }
$template_submit = '<tr> $template_submit = '<tr>
<td colspan="4" ></td> <td colspan="4" ></td>
<td > <td >
{element} {element}
@ -164,42 +164,42 @@ class EvalForm extends FormValidator
</td> </td>
</tr>'; </tr>';
$results_and_users = array(); $results_and_users = array();
foreach ($this->result_object as $result) { foreach ($this->result_object as $result) {
$user = api_get_user_info($result->get_user_id()); $user = api_get_user_info($result->get_user_id());
$results_and_users[] = array ('result' => $result, 'user' => $user); $results_and_users[] = array ('result' => $result, 'user' => $user);
} }
usort($results_and_users, array ('EvalForm', 'sort_by_user')); usort($results_and_users, array ('EvalForm', 'sort_by_user'));
$defaults = array(); $defaults = array();
foreach ($results_and_users as $result_and_user) { foreach ($results_and_users as $result_and_user) {
$user = $result_and_user['user']; $user = $result_and_user['user'];
$result = $result_and_user['result']; $result = $result_and_user['result'];
$renderer = &$this->defaultRenderer(); $renderer = &$this->defaultRenderer();
$this->add_textfield('score[' . $result->get_id() . ']', $this->add_textfield('score[' . $result->get_id() . ']',
$this->build_stud_label($user['user_id'], $user['username'], $user['lastname'], $user['firstname']), $this->build_stud_label($user['user_id'], $user['username'], $user['lastname'], $user['firstname']),
false, false,
array ('class' => "span2", array ('class' => "span2",
'maxlength' => 5)); 'maxlength' => 5));
$this->addRule('score[' . $result->get_id() . ']', get_lang('OnlyNumbers'), 'numeric'); $this->addRule('score[' . $result->get_id() . ']', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array ( $this->addRule(array (
'score[' . $result->get_id() . ']', 'maxvalue'), get_lang('OverMax'), 'compare', '<='); 'score[' . $result->get_id() . ']', 'maxvalue'), get_lang('OverMax'), 'compare', '<=');
$this->addRule(array ( $this->addRule(array (
'score[' . $result->get_id() . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>='); 'score[' . $result->get_id() . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$defaults['score[' . $result->get_id() . ']'] = $result->get_score(); $defaults['score[' . $result->get_id() . ']'] = $result->get_score();
if (api_is_western_name_order() ) { if (api_is_western_name_order() ) {
$user_info = '<td align="left" >'.$user['firstname'].'</td>'; $user_info = '<td align="left" >'.$user['firstname'].'</td>';
$user_info .= '<td align="left" >'.$user['lastname'].'</td>'; $user_info .= '<td align="left" >'.$user['lastname'].'</td>';
} else { } else {
$user_info = '<td align="left" >'.$user['lastname'].'</td>'; $user_info = '<td align="left" >'.$user['lastname'].'</td>';
$user_info .= '<td align="left" >'.$user['firstname'].'</td>'; $user_info .= '<td align="left" >'.$user['firstname'].'</td>';
} }
$template = '<tr> $template = '<tr>
<td align="left" >'.$user['official_code'].'</td> <td align="left" >'.$user['official_code'].'</td>
<td align="left" >'.$user['username'].'</td> <td align="left" >'.$user['username'].'</td>
'.$user_info.' '.$user_info.'
@ -207,57 +207,57 @@ class EvalForm extends FormValidator
<!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error --> <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
</td> </td>
</tr>'; </tr>';
$renderer->setElementTemplate($template,'score[' . $result->get_id() . ']'); $renderer->setElementTemplate($template,'score[' . $result->get_id() . ']');
} }
$this->setDefaults($defaults); $this->setDefaults($defaults);
$this->addElement('style_submit_button', 'submit',get_lang('EditResult'),'class="save"'); $this->addElement('style_submit_button', 'submit',get_lang('EditResult'),'class="save"');
$renderer->setElementTemplate($template_submit,'submit'); $renderer->setElementTemplate($template_submit,'submit');
} }
/** /**
* This function builds a form to move an item to another category * This function builds a form to move an item to another category
* *
*/ */
protected function build_move_form() { protected function build_move_form() {
$renderer = & $this->defaultRenderer(); $renderer = & $this->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span> '); $renderer->setElementTemplate('<span>{element}</span> ');
$this->addElement('static', null, null, '"'.$this->evaluation_object->get_name().'" '); $this->addElement('static', null, null, '"'.$this->evaluation_object->get_name().'" ');
$this->addElement('static', null, null, get_lang('MoveTo').' : '); $this->addElement('static', null, null, get_lang('MoveTo').' : ');
$select= $this->addElement('select', 'move_cat', null, null); $select= $this->addElement('select', 'move_cat', null, null);
foreach ($this->evaluation_object->get_target_categories() as $cat) { foreach ($this->evaluation_object->get_target_categories() as $cat) {
for ($i= 0; $i < $cat[2]; $i++) { for ($i= 0; $i < $cat[2]; $i++) {
$line .= '&mdash;'; $line .= '&mdash;';
} }
$select->addoption($line . ' ' . $cat[1], $cat[0]); $select->addoption($line . ' ' . $cat[1], $cat[0]);
$line= ''; $line= '';
} }
$this->addElement('style_submit_button' , 'submit', get_lang('Ok'),'class="save"'); $this->addElement('style_submit_button' , 'submit', get_lang('Ok'),'class="save"');
} }
/** /**
* Builds a result form containing inputs for all students with a given course_code * Builds a result form containing inputs for all students with a given course_code
*/ */
protected function build_result_add_form() { protected function build_result_add_form() {
$renderer =& $this->defaultRenderer(); $renderer =& $this->defaultRenderer();
$renderer->setFormTemplate( $renderer->setFormTemplate(
'<form{attributes}> '<form{attributes}>
<table class="data_table"> <table class="data_table">
{content} {content}
</table> </table>
</form>' </form>'
); );
$tblusers = get_users_in_course($this->evaluation_object->get_course_code()); $tblusers = get_users_in_course($this->evaluation_object->get_course_code());
$nr_users = 0; $nr_users = 0;
//extra field for check on maxvalue //extra field for check on maxvalue
$this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max()); $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
$this->addElement('hidden', 'minvalue', 0); $this->addElement('hidden', 'minvalue', 0);
$this->addElement('header', get_lang('AddResult')); $this->addElement('header', get_lang('AddResult'));
if (api_is_western_name_order()){ if (api_is_western_name_order()){
$renderer->setHeaderTemplate( $renderer->setHeaderTemplate(
'<tr> '<tr>
<th>'.get_lang('OfficialCode').'</th> <th>'.get_lang('OfficialCode').'</th>
<th>'.get_lang('UserName').'</th> <th>'.get_lang('UserName').'</th>
<th>'.get_lang('FirstName').'</th> <th>'.get_lang('FirstName').'</th>
<th>'.get_lang('LastName').'</th> <th>'.get_lang('LastName').'</th>
@ -266,8 +266,8 @@ class EvalForm extends FormValidator
); );
} else { } else {
$renderer->setHeaderTemplate( $renderer->setHeaderTemplate(
'<tr> '<tr>
<th>'.get_lang('OfficialCode').'</th> <th>'.get_lang('OfficialCode').'</th>
<th>'.get_lang('UserName').'</th> <th>'.get_lang('UserName').'</th>
<th>'.get_lang('LastName').'</th> <th>'.get_lang('LastName').'</th>
<th>'.get_lang('FirstName').'</th> <th>'.get_lang('FirstName').'</th>
@ -276,19 +276,19 @@ class EvalForm extends FormValidator
); );
} }
foreach ($tblusers as $user) { foreach ($tblusers as $user) {
$element_name = 'score['.$user[0].']'; $element_name = 'score['.$user[0].']';
//user_id, user.username, lastname, firstname //user_id, user.username, lastname, firstname
$this->add_textfield($element_name, $this->add_textfield($element_name,
$this->build_stud_label($user[0], $user[1], $user[2], $user[3]), $this->build_stud_label($user[0], $user[1], $user[2], $user[3]),
false, false,
array ('class' => 'span1','maxlength' => 5)); array ('class' => 'span1','maxlength' => 5));
$this->addRule($element_name, get_lang('OnlyNumbers'), 'numeric'); $this->addRule($element_name, get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array($element_name,'maxvalue'), get_lang('OverMax'), 'compare', '<='); $this->addRule(array($element_name,'maxvalue'), get_lang('OverMax'), 'compare', '<=');
$this->addRule(array($element_name,'minvalue'), get_lang('UnderMin'), 'compare', '>='); $this->addRule(array($element_name,'minvalue'), get_lang('UnderMin'), 'compare', '>=');
if (api_is_western_name_order() ) { if (api_is_western_name_order() ) {
$user_info = '<td align="left" >'.$user[3].'</td>'; $user_info = '<td align="left" >'.$user[3].'</td>';
@ -297,7 +297,7 @@ class EvalForm extends FormValidator
$user_info = '<td align="left" >'.$user[2].'</td>'; $user_info = '<td align="left" >'.$user[2].'</td>';
$user_info .= '<td align="left" >'.$user[3].'</td>'; $user_info .= '<td align="left" >'.$user[3].'</td>';
} }
$nr_users++; $nr_users++;
$template = '<tr> $template = '<tr>
<td align="left" >'.$user[4].'</td> <td align="left" >'.$user[4].'</td>
@ -307,11 +307,11 @@ class EvalForm extends FormValidator
<!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error --> <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
</td> </td>
</tr>'; </tr>';
$renderer->setElementTemplate($template, $element_name); $renderer->setElementTemplate($template, $element_name);
} }
$this->addElement('hidden', 'nr_users', $nr_users); $this->addElement('hidden', 'nr_users', $nr_users);
$this->addElement('hidden', 'evaluation_id', $this->result_object->get_evaluation_id()); $this->addElement('hidden', 'evaluation_id', $this->result_object->get_evaluation_id());
$this->addElement('style_submit_button', 'submit', get_lang('AddResult'),'class="save"'); $this->addElement('style_submit_button', 'submit', get_lang('AddResult'),'class="save"');
$template_submit = '<tr> $template_submit = '<tr>
<td colspan="4" ></td> <td colspan="4" ></td>
@ -320,68 +320,68 @@ class EvalForm extends FormValidator
<!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error --> <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
</td> </td>
</tr>'; </tr>';
$renderer->setElementTemplate($template_submit, 'submit'); $renderer->setElementTemplate($template_submit, 'submit');
} }
/** /**
* Builds a form to edit a result * Builds a form to edit a result
*/ */
protected function build_result_edit_form() { protected function build_result_edit_form() {
$this->setDefaults(array ( $this->setDefaults(array (
'score' => $this->result_object->get_score(), 'score' => $this->result_object->get_score(),
'maximum' => $this->evaluation_object->get_max() 'maximum' => $this->evaluation_object->get_max()
)); ));
$userinfo= api_get_user_info($this->result_object->get_user_id()); $userinfo= api_get_user_info($this->result_object->get_user_id());
$renderer =& $this->defaultRenderer(); $renderer =& $this->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span> '); $renderer->setElementTemplate('<span>{element}</span> ');
$this->addElement('label', get_lang('User'), $userinfo['complete_name']); $this->addElement('label', get_lang('User'), $userinfo['complete_name']);
$this->add_textfield('score', array(get_lang('Score'), null, '/ '.$this->evaluation_object->get_max()), false, array ( $this->add_textfield('score', array(get_lang('Score'), null, '/ '.$this->evaluation_object->get_max()), false, array (
'size' => '4', 'size' => '4',
'class' => 'span1', 'class' => 'span1',
'maxlength' => '5' 'maxlength' => '5'
)); ));
/* $this->add_textfield('maximum', null, false, array ( /* $this->add_textfield('maximum', null, false, array (
'size' => '4', 'size' => '4',
'maxlength' => '5', 'maxlength' => '5',
'disabled' => 'disabled' 'disabled' => 'disabled'
));*/ ));*/
$this->addElement('style_submit_button', 'submit', get_lang('Edit'),'class="save"');
$this->addElement('hidden', 'minvalue', 0);
$this->addElement('hidden', 'hid_user_id', $this->result_object->get_user_id());
$this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
$this->addRule('score', get_lang('OnlyNumbers'), 'numeric',null,'client');
$this->addRule(array (
'score',
'maxvalue'
), get_lang('OverMax'), 'compare', '<=','client');
$this->addRule(array (
'score',
'minvalue'
), get_lang('UnderMin'), 'compare', '>=','client');
}
/**
* Builds a form to add an evaluation
*/
protected function build_add_form() {
$this->setDefaults(array ( 'hid_user_id' => $this->evaluation_object->get_user_id(),
'hid_category_id' => $this->evaluation_object->get_category_id(),
'hid_course_code' => $this->evaluation_object->get_course_code(), 'created_at' => api_get_utc_datetime()));
$this->build_basic_form(0);
if ($this->evaluation_object->get_course_code() == null) {
$this->addElement('checkbox', 'adduser', null, get_lang('AddUserToEval'));
} else {
$this->addElement('checkbox', 'addresult', null, get_lang('AddResult'));
}
$this->addElement('style_submit_button', 'submit', get_lang('AddAssessment'),'class="add"');
}
$this->addElement('style_submit_button', 'submit', get_lang('Edit'),'class="save"'); /**
$this->addElement('hidden', 'minvalue', 0); * Builds a form to edit an evaluation
$this->addElement('hidden', 'hid_user_id', $this->result_object->get_user_id()); */
$this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max()); protected function build_editing_form() {
$this->addRule('score', get_lang('OnlyNumbers'), 'numeric',null,'client');
$this->addRule(array (
'score',
'maxvalue'
), get_lang('OverMax'), 'compare', '<=','client');
$this->addRule(array (
'score',
'minvalue'
), get_lang('UnderMin'), 'compare', '>=','client');
}
/**
* Builds a form to add an evaluation
*/
protected function build_add_form() {
$this->setDefaults(array ( 'hid_user_id' => $this->evaluation_object->get_user_id(),
'hid_category_id' => $this->evaluation_object->get_category_id(),
'hid_course_code' => $this->evaluation_object->get_course_code(), 'created_at' => api_get_utc_datetime()));
$this->build_basic_form(0);
if ($this->evaluation_object->get_course_code() == null) {
$this->addElement('checkbox', 'adduser', null, get_lang('AddUserToEval'));
} else {
$this->addElement('checkbox', 'addresult', null, get_lang('AddResult'));
}
$this->addElement('style_submit_button', 'submit', get_lang('AddAssessment'),'class="add"');
}
/**
* Builds a form to edit an evaluation
*/
protected function build_editing_form() {
$parent_cat = Category :: load($this->evaluation_object->get_category_id()); $parent_cat = Category :: load($this->evaluation_object->get_category_id());
if ($parent_cat[0]->get_parent_id() == 0) { if ($parent_cat[0]->get_parent_id() == 0) {
$weight_mask = $this->evaluation_object->get_weight(); $weight_mask = $this->evaluation_object->get_weight();
@ -392,43 +392,43 @@ class EvalForm extends FormValidator
} }
$weight_mask = $this->evaluation_object->get_weight(); $weight_mask = $this->evaluation_object->get_weight();
$this->setDefaults(array ( 'hid_id' => $this->evaluation_object->get_id(), $this->setDefaults(array ( 'hid_id' => $this->evaluation_object->get_id(),
'name' => $this->evaluation_object->get_name(), 'name' => $this->evaluation_object->get_name(),
'description' => $this->evaluation_object->get_description(), 'description' => $this->evaluation_object->get_description(),
'hid_user_id' => $this->evaluation_object->get_user_id(), 'hid_user_id' => $this->evaluation_object->get_user_id(),
'hid_course_code' => $this->evaluation_object->get_course_code(), 'hid_course_code' => $this->evaluation_object->get_course_code(),
'hid_category_id' => $this->evaluation_object->get_category_id(), 'hid_category_id' => $this->evaluation_object->get_category_id(),
'created_at' => api_get_utc_datetime($this->evaluation_object->get_date()), 'created_at' => api_get_utc_datetime($this->evaluation_object->get_date()),
'weight' => $weight, 'weight' => $weight,
'weight_mask' => $weight_mask, 'weight_mask' => $weight_mask,
'max' => $this->evaluation_object->get_max(), 'max' => $this->evaluation_object->get_max(),
'visible' => $this->evaluation_object->is_visible())); 'visible' => $this->evaluation_object->is_visible()));
$id_current=isset($this->id)?$this->id :null; $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->build_basic_form(1);
$this->addElement('style_submit_button', 'submit', get_lang('ModifyEvaluation'),'class="save"'); $this->addElement('style_submit_button', 'submit', get_lang('ModifyEvaluation'),'class="save"');
} }
/** /**
* Builds a basic form that is used in add and edit * Builds a basic form that is used in add and edit
*/ */
private function build_basic_form($edit= 0) { private function build_basic_form($edit= 0) {
$form_title = get_lang('NewEvaluation'); $form_title = get_lang('NewEvaluation');
if ($_GET['editeval']==1) { if ($_GET['editeval']==1) {
$form_title = get_lang('EditEvaluation'); $form_title = get_lang('EditEvaluation');
} }
$this->addElement('header', $form_title); $this->addElement('header', $form_title);
$this->addElement('hidden', 'zero', 0); $this->addElement('hidden', 'zero', 0);
$this->addElement('hidden', 'hid_user_id'); $this->addElement('hidden', 'hid_user_id');
$this->addElement('hidden', 'hid_course_code'); $this->addElement('hidden', 'hid_course_code');
$this->add_textfield('name', get_lang('EvaluationName'), true, array ( $this->add_textfield('name', get_lang('EvaluationName'), true, array (
'class' => 'span3', 'class' => 'span3',
'maxlength' => '50', 'maxlength' => '50',
'id' => 'evaluation_title' 'id' => 'evaluation_title'
)); ));
$cat_id = $this->evaluation_object->get_category_id(); $cat_id = $this->evaluation_object->get_category_id();
@ -466,117 +466,101 @@ class EvalForm extends FormValidator
} }
} }
} }
<<<<<<< HEAD
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));
=======
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array ( $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array (
'size' => '4', 'size' => '4',
'maxlength' => '5', 'maxlength' => '5',
'class' => 'span1' 'class' => 'span1'
)); ));
>>>>>>> julio19x
/*$this->add_textfield('weight', array(null, null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array ( /*$this->add_textfield('weight', array(null, null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
'size' => '4', 'size' => '4',
'maxlength' => '5', 'maxlength' => '5',
'class' => 'span1' 'class' => 'span1'
<<<<<<< HEAD
));*/ ));*/
======= if ($edit) {
));*/ if (!$this->evaluation_object->has_results()) {
$this->add_textfield('max', get_lang('QualificationNumeric'), true, array (
'class' => 'span1',
>>>>>>> julio19x 'maxlength' => '5'
if ($edit) { ));
if (!$this->evaluation_object->has_results()) { } else {
$this->add_textfield('max', get_lang('QualificationNumeric'), true, array ( $this->add_textfield('max', array(get_lang('QualificationNumeric'), get_lang('CannotChangeTheMaxNote')), false, array (
'class' => 'span1', 'class' => 'span1',
'maxlength' => '5' 'maxlength' => '5',
)); 'disabled' => 'disabled'
} else { ));
$this->add_textfield('max', array(get_lang('QualificationNumeric'), get_lang('CannotChangeTheMaxNote')), false, array ( }
'class' => 'span1', } else {
'maxlength' => '5', $this->add_textfield('max', get_lang('QualificationNumeric'), true, array (
'disabled' => 'disabled' 'class' => 'span1',
)); 'maxlength' => '5'
} ));
} else {
$this->add_textfield('max', get_lang('QualificationNumeric'), true, array (
'class' => 'span1',
'maxlength' => '5'
));
$default_max = api_get_setting('gradebook_default_weight'); $default_max = api_get_setting('gradebook_default_weight');
$defaults['max'] = isset($default_max) ? $default_max : 100; $defaults['max'] = isset($default_max) ? $default_max : 100;
$this->setDefaults($defaults); $this->setDefaults($defaults);
} }
$this->addElement('textarea', 'description', get_lang('Description'), array ( $this->addElement('textarea', 'description', get_lang('Description'), array (
'rows' => '3', 'rows' => '3',
'class' => 'span3', 'class' => 'span3',
)); ));
$this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'required'); $this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'required');
$this->addElement('checkbox', 'visible', null, get_lang('Visible')); $this->addElement('checkbox', 'visible', null, get_lang('Visible'));
$this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric'); $this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>='); $this->addRule(array('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$this->addRule('max', get_lang('OnlyNumbers'), 'numeric'); $this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array('max', 'zero'), get_lang('NegativeValue'), 'compare', '>='); $this->addRule(array('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$setting = api_get_setting('tool_visible_by_default_at_creation'); $setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1; $visibility_default = 1;
if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
$visibility_default = 0; $visibility_default = 0;
} }
$this->setDefaults(array('visible' => $visibility_default)); $this->setDefaults(array('visible' => $visibility_default));
} }
function display() { function display() {
parent :: display(); parent :: display();
} }
function setDefaults($defaults= array(), $filter = null) { function setDefaults($defaults= array(), $filter = null) {
parent :: setDefaults($defaults, $filter); parent :: setDefaults($defaults, $filter);
} }
private function build_stud_label ($id, $username,$lastname, $firstname) { private function build_stud_label ($id, $username,$lastname, $firstname) {
$opendocurl_start = ''; $opendocurl_start = '';
$opendocurl_end = ''; $opendocurl_end = '';
// evaluation's origin is a link // evaluation's origin is a link
if ($this->evaluation_object->get_category_id() < 0) { if ($this->evaluation_object->get_category_id() < 0) {
$link = LinkFactory :: get_evaluation_link ($this->evaluation_object->get_id()); $link = LinkFactory :: get_evaluation_link ($this->evaluation_object->get_id());
$doc_url = $link->get_view_url($id); $doc_url = $link->get_view_url($id);
if ($doc_url != null) { if ($doc_url != null) {
$opendocurl_start .= '<a href="'. $doc_url . '" target="_blank">'; $opendocurl_start .= '<a href="'. $doc_url . '" target="_blank">';
$opendocurl_end = '</a>'; $opendocurl_end = '</a>';
} }
} }
return $opendocurl_start . api_get_person_name($firstname, $lastname) .' ('.$username.')'. $opendocurl_end; return $opendocurl_start . api_get_person_name($firstname, $lastname) .' ('.$username.')'. $opendocurl_end;
} }
function sort_by_user ($item1, $item2) { function sort_by_user ($item1, $item2) {
$user1 = $item1['user']; $user1 = $item1['user'];
$user2 = $item2['user']; $user2 = $item2['user'];
if (api_sort_by_first_name()) { if (api_sort_by_first_name()) {
$result = api_strcmp($user1['firstname'], $user2['firstname']); $result = api_strcmp($user1['firstname'], $user2['firstname']);
if ($result == 0) { if ($result == 0) {
return api_strcmp($user1['lastname'], $user2['lastname']); return api_strcmp($user1['lastname'], $user2['lastname']);
} }
} else { } else {
$result = api_strcmp($user1['lastname'], $user2['lastname']); $result = api_strcmp($user1['lastname'], $user2['lastname']);
if ($result == 0) { if ($result == 0) {
return api_strcmp($user1['firstname'], $user2['firstname']); return api_strcmp($user1['firstname'], $user2['firstname']);
} }
} }
return $result; return $result;
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save