Browse Source

More fixes in the work tool

Julio Montoya 13 years ago
parent
commit
e5e62e02e4
3 changed files with 56 additions and 23 deletions
  1. 6 1
      main/inc/ajax/model.ajax.php
  2. 10 4
      main/work/work.lib.php
  3. 40 18
      main/work/work.php

+ 6 - 1
main/inc/ajax/model.ajax.php

@@ -164,7 +164,12 @@ $is_tutor                   = api_is_allowed_to_edit(true);
 $columns = array();
 switch ($action) {    
     case 'get_work_user_list':        
-		$columns = array('type', 'firstname', 'lastname',  'username', 'qualification', 'sent_date', 'qualificator_id', 'actions');	
+        if (isset($_GET['type'])  && $_GET['type'] == 'simple') {
+            $columns = array('type', 'firstname', 'lastname',  'username', 'qualification', 'sent_date', 'qualificator_id', 'actions');	
+        } else {
+            $columns = array('type', 'firstname', 'lastname',  'username', 'sent_date', 'actions');	
+        }
+        
         
         $result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition);        
         break;

+ 10 - 4
main/work/work.lib.php

@@ -637,15 +637,19 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 							$expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00')."'";
 							Database::query('UPDATE '.$work_assigment.$expires_query.' WHERE c_id = '.$course_id.' AND id = '."'".$row['has_properties']."'");
 							$sql_add_publication = "UPDATE ".$work_table." SET has_properties  = '".$row['has_properties'].  "', view_properties=1 WHERE c_id = $course_id AND id ='".$row['id']."'";
-							Database::query($sql_add_publication);
-						
+							Database::query($sql_add_publication);						
 			
 							$ends_query = ' SET ends_on = '."'".($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00')."'";
 							Database::query('UPDATE '.$work_assigment.$ends_query.' WHERE c_id = '.$course_id.' AND id = '."'".$row['has_properties']."'");
 							$sql_add_publication = "UPDATE ".$work_table." SET has_properties  = '".$row['has_properties'].  "', view_properties=1 WHERE c_id = $course_id AND id ='".$row['id']."'";
 							Database::query($sql_add_publication);
+                                                        
+                            $qualification_value = isset($_POST['qualification']['qualification']) ? intval($_POST['qualification']['qualification']) : 0;
+                            $enable_qualification = !empty($qualification_value) ? 1 : 0;
+                            $sql_add_publication = "UPDATE ".$work_table." SET enable_qualification  = '".$enable_qualification.  "' WHERE c_id = $course_id AND id ='".$row['id']."'";
+							Database::query($sql_add_publication);
 				
-                            $sql = 'UPDATE '.$work_table.' SET 
+                             $sql = 'UPDATE '.$work_table.' SET 
                                                  allow_text_assignment = '."'".intval($_POST['allow_text_assignment'])."'".' ,
                                                  title = '."'".Database::escape_string($_POST['dir_name'])."'".',  
                                                  description = '."'".Database::escape_string($_POST['description'])."'".', 
@@ -1598,7 +1602,7 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
                 $qualification_exists = true;
             }
             
-            $qualification_string = '-';
+            $qualification_string = '';
             
             if ($qualification_exists) {
                 if ($work['qualification'] == '') {
@@ -1628,11 +1632,13 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
 
                 //File name
                 $link_to_download = null;
+                
                 if ($work['contains_file']) {
                     $link_to_download = '<a href="download.php?id='.$item_id.'">'.Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
                 } else {
                     $link_to_download = '<a href="view.php?id='.$item_id.'">'.Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a> ';
                 } 
+                
                 $work['qualification'] = $qualification_string;
 
                 //Date

+ 40 - 18
main/work/work.php

@@ -596,7 +596,7 @@ switch ($action) {
 	
 					if ($is_allowed_to_edit && ($_POST['qualification'] !='' )) {
 						$add_to_update = ', qualificator_id ='."'".api_get_user_id()."',";
-						$add_to_update .= ' qualification ='."'".Database::escape_string($_POST['qualification'])."',";
+						$add_to_update .= ' qualification = '."'".Database::escape_string($_POST['qualification'])."',";
 						$add_to_update .= ' date_of_qualification ='."'".api_get_utc_datetime()."'";
 					}
 	
@@ -884,7 +884,7 @@ switch ($action) {
 				// insert into student_publication_assignment	
 				//return something like this: 2008-02-45 00:00:00
 	
-				$enable_calification = isset($_POST['qualification_value']) ? 1 : 0;
+				$enable_calification = isset($_POST['qualification_value']) && !empty($_POST['qualification_value']) ? 1 : 0;
 				
 				if (!empty($_POST['type1']) || !empty($_POST['type2'])) {
 					$sql_add_homework = "INSERT INTO $TSTDPUBASG SET
@@ -1164,21 +1164,43 @@ switch ($action) {
 		}
         
         //User works
-        if (isset($work_id) && !empty($work_id) && !$display_list_users_without_publication) {
-                        
-            $columns        = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), 
-                                    get_lang('Qualification'), get_lang('Date'),  get_lang('Status'), get_lang('Actions'));
-            $column_model   = array (
-                array('name'=>'type',           'index'=>'file',            'width'=>'12',   'align'=>'left', 'search' => 'false'),                        
-                array('name'=>'firstname',      'index'=>'firstname',       'width'=>'50',   'align'=>'left', 'search' => 'true'),                        
-                array('name'=>'lastname',		'index'=>'lastname',        'width'=>'50',   'align'=>'left', 'search' => 'true'),
-                array('name'=>'username',       'index'=>'username',        'width'=>'30',   'align'=>'left', 'search' => 'true'),                    
-//                array('name'=>'file',           'index'=>'file',            'width'=>'20',   'align'=>'left', 'search' => 'false'),
-                array('name'=>'qualification',	'index'=>'qualification',	'width'=>'20',   'align'=>'left', 'search' => 'true'),                        
-                array('name'=>'sent_date',           'index'=>'sent_date',            'width'=>'60',   'align'=>'left', 'search' => 'true'),                        
-                array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30',   'align'=>'left', 'search' => 'true'),      
-                array('name'=>'actions',        'index'=>'actions',         'width'=>'40',   'align'=>'left', 'search' => 'false', 'sortable'=>'false')
-            );
+        if (isset($work_id) && !empty($work_id) && !$display_list_users_without_publication) {            
+            $work_data = get_work_assignment_by_id($work_id);                    
+            $check_weight = intval($my_folder_data['weight']);
+            
+            if (!empty($work_data['enable_qualification']) && !empty($check_weight)) {
+                $type = 'simple';
+                $columns        = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), 
+                                        get_lang('Qualification'), get_lang('Date'),  get_lang('Status'), get_lang('Actions'));
+                $column_model   = array (
+                    array('name'=>'type',           'index'=>'file',            'width'=>'12',   'align'=>'left', 'search' => 'false'),                        
+                    array('name'=>'firstname',      'index'=>'firstname',       'width'=>'50',   'align'=>'left', 'search' => 'true'),                        
+                    array('name'=>'lastname',		'index'=>'lastname',        'width'=>'50',   'align'=>'left', 'search' => 'true'),
+                    array('name'=>'username',       'index'=>'username',        'width'=>'30',   'align'=>'left', 'search' => 'true'),                    
+    //                array('name'=>'file',           'index'=>'file',            'width'=>'20',   'align'=>'left', 'search' => 'false'),
+                    array('name'=>'qualification',	'index'=>'qualification',	'width'=>'20',   'align'=>'left', 'search' => 'true'),                        
+                    array('name'=>'sent_date',           'index'=>'sent_date',            'width'=>'60',   'align'=>'left', 'search' => 'true'),                        
+                    array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30',   'align'=>'left', 'search' => 'true'),      
+                    array('name'=>'actions',        'index'=>'actions',         'width'=>'40',   'align'=>'left', 'search' => 'false', 'sortable'=>'false')
+                    
+                );
+            } else {
+                $type = 'complex';
+                $columns        = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), 
+                                         get_lang('Date'),  get_lang('Actions'));
+                $column_model   = array (
+                    array('name'=>'type',           'index'=>'file',            'width'=>'12',   'align'=>'left', 'search' => 'false'),                        
+                    array('name'=>'firstname',      'index'=>'firstname',       'width'=>'50',   'align'=>'left', 'search' => 'true'),                        
+                    array('name'=>'lastname',		'index'=>'lastname',        'width'=>'50',   'align'=>'left', 'search' => 'true'),
+                    array('name'=>'username',       'index'=>'username',        'width'=>'30',   'align'=>'left', 'search' => 'true'),                    
+    //                array('name'=>'file',           'index'=>'file',            'width'=>'20',   'align'=>'left', 'search' => 'false'),
+                    //array('name'=>'qualification',	'index'=>'qualification',	'width'=>'20',   'align'=>'left', 'search' => 'true'),                        
+                    array('name'=>'sent_date',       'index'=>'sent_date',            'width'=>'60',   'align'=>'left', 'search' => 'true'),                        
+                    //array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30',   'align'=>'left', 'search' => 'true'),      
+                    array('name'=>'actions',        'index'=>'actions',         'width'=>'40',   'align'=>'left', 'search' => 'false', 'sortable'=>'false')
+                );
+            }
+         
 
             $extra_params = array();
 
@@ -1192,7 +1214,7 @@ switch ($action) {
             //$extra_params['rowList'] = array(10, 20 ,30);
             
             $extra_params['sortname'] = 'firstname';            
-            $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$work_id;
+            $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$work_id.'&type='.$type;
             ?>
             <script>
                 $(function() {