Using jqgrid in work see BT#4131 partial

skala
Julio Montoya 13 years ago
parent 773b5e979a
commit bd08d27809
  1. BIN
      main/img/icons/22/default.png
  2. 30
      main/inc/ajax/model.ajax.php
  3. 22
      main/inc/ajax/work.ajax.php
  4. 410
      main/inc/lib/document.lib.php
  5. 564
      main/work/work.lib.php
  6. 85
      main/work/work.php

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -21,7 +21,7 @@ if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
if ($action != 'get_exercise_results') {
if (!in_array($action, array('get_exercise_results', 'get_work_user_list'))) {
api_protect_admin_script(true);
}
@ -97,6 +97,11 @@ if (!$sidx) $sidx = 1;
//@todo rework this
switch ($action) {
case 'get_work_user_list':
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$work_id = $_REQUEST['work_id'];
$count = get_count_work($work_id);
break;
case 'get_exercise_results':
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
require_once $libpath.'groupmanager.lib.php';
@ -152,17 +157,21 @@ if ($_REQUEST['oper'] == 'del') {
$obj->delete($_REQUEST['id']);
}
//4. Querying the DB for the elements
$is_allowedToEdit = api_is_allowed_to_edit(null,true);
$is_tutor = api_is_allowed_to_edit(true);
//5. Querying the DB for the elements
$columns = array();
switch ($action) {
case 'get_work_user_list':
$columns = array('type', 'firstname', 'lastname', 'username', 'qualification', 'sent_date', 'qualificator_id', 'actions');
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition);
break;
case 'get_exercise_results':
$course = api_get_course_info();
$is_allowedToEdit = api_is_allowed_to_edit(null,true);
$is_tutor = api_is_allowed_to_edit(true);
//used inside get_exam_results_data()
$documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
if ($is_allowedToEdit || $is_tutor) {
$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score','status','actions');
} else {
@ -220,7 +229,7 @@ switch ($action) {
}
$result = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));
$new_result = array();
foreach($result as $item) {
foreach ($result as $item) {
if (!$item['status']) {
$item['name'] = '<font style="color:#AAA">'.$item['name'].'</font>';
}
@ -269,15 +278,16 @@ switch ($action) {
}
//var_dump($result);
$allowed_actions = array('get_careers', 'get_promotions', 'get_usergroups', 'get_gradebooks', 'get_sessions', 'get_exercise_results', 'get_work_user_list');
//5. Creating an obj to return a json
if (in_array($action, array('get_careers', 'get_promotions', 'get_usergroups', 'get_gradebooks', 'get_sessions', 'get_exercise_results'))) {
if (in_array($action, $allowed_actions)) {
$response = new stdClass();
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$i=0;
if (!empty($result)) {
foreach($result as $row) {
foreach ($result as $row) {
//print_r($row);
// if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235
if ($row['id'] == "") {
@ -286,7 +296,7 @@ if (in_array($action, array('get_careers', 'get_promotions', 'get_usergroups', '
$response->rows[$i]['id']=$row['id'];
}
$array = array();
foreach($columns as $col) {
foreach ($columns as $col) {
$array[] = $row[$col];
}
$response->rows[$i]['cell']=$array;

@ -0,0 +1,22 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
switch ($action) {
case 'get_work_user_list':
break;
default:
echo '';
}
exit;

@ -74,214 +74,214 @@ class DocumentManager {
// All MIME types in an array (from 1.6, this is the authorative source)
// Please, keep this alphabetical if you add something to this list!
$mime_types = array(
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asf' => 'video/x-ms-asf',
'asc' => 'text/plain',
'au' => 'audio/basic',
'avi' => 'video/x-msvideo',
'bcpio' => 'application/x-bcpio',
'bin' => 'application/octet-stream',
'bmp' => 'image/bmp',
'cdf' => 'application/x-netcdf',
'class' => 'application/octet-stream',
'cpio' => 'application/x-cpio',
'cpt' => 'application/mac-compactpro',
'csh' => 'application/x-csh',
'css' => 'text/css',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'djv' => 'image/vnd.djvu',
'djvu' => 'image/vnd.djvu',
'dll' => 'application/octet-stream',
'dmg' => 'application/x-diskcopy',
'dms' => 'application/octet-stream',
'doc' => 'application/msword',
'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'dvi' => 'application/x-dvi',
'dwg' => 'application/vnd.dwg',
'dxf' => 'application/vnd.dxf',
'dxr' => 'application/x-director',
'eps' => 'application/postscript',
'epub' => 'application/epub+zip',
'etx' => 'text/x-setext',
'exe' => 'application/octet-stream',
'ez' => 'application/andrew-inset',
'gif' => 'image/gif',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'hdf' => 'application/x-hdf',
'hqx' => 'application/mac-binhex40',
'htm' => 'text/html',
'html' => 'text/html',
'ice' => 'x-conference-xcooltalk',
'ief' => 'image/ief',
'iges' => 'model/iges',
'igs' => 'model/iges',
'jar' => 'application/java-archiver',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'application/x-javascript',
'kar' => 'audio/midi',
'lam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'latex' => 'application/x-latex',
'lha' => 'application/octet-stream',
'log' => 'text/plain',
'lzh' => 'application/octet-stream',
'm1a' => 'audio/mpeg',
'm2a' => 'audio/mpeg',
'm3u' => 'audio/x-mpegurl',
'man' => 'application/x-troff-man',
'me' => 'application/x-troff-me',
'mesh' => 'model/mesh',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mov' => 'video/quicktime',
'movie' => 'video/x-sgi-movie',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mp4' => 'video/mpeg4-generic',
'mpa' => 'audio/mpeg',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpga' => 'audio/mpeg',
'ms' => 'application/x-troff-ms',
'msh' => 'model/mesh',
'mxu' => 'video/vnd.mpegurl',
'nc' => 'application/x-netcdf',
'oda' => 'application/oda',
'oga'=> 'audio/ogg',
'ogg'=> 'application/ogg',
'ogx'=> 'application/ogg',
'ogv'=> 'video/ogg',
'pbm' => 'image/x-portable-bitmap',
'pct' => 'image/pict',
'pdb' => 'chemical/x-pdb',
'pdf' => 'application/pdf',
'pgm' => 'image/x-portable-graymap',
'pgn' => 'application/x-chess-pgn',
'pict' => 'image/pict',
'png' => 'image/png',
'pnm' => 'image/x-portable-anymap',
'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'pps' => 'application/vnd.ms-powerpoint',
'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'ppm' => 'image/x-portable-pixmap',
'ppt' => 'application/vnd.ms-powerpoint',
'pps' => 'application/vnd.ms-powerpoint',
'ps' => 'application/postscript',
'qt' => 'video/quicktime',
'ra' => 'audio/x-realaudio',
'ram' => 'audio/x-pn-realaudio',
'rar' => 'image/x-rar-compressed',
'ras' => 'image/x-cmu-raster',
'rgb' => 'image/x-rgb',
'rm' => 'audio/x-pn-realaudio',
'roff' => 'application/x-troff',
'rpm' => 'audio/x-pn-realaudio-plugin',
'rtf' => 'text/rtf',
'rtx' => 'text/richtext',
'sgm' => 'text/sgml',
'sgml' => 'text/sgml',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'silo' => 'model/mesh',
'sib' => 'application/X-Sibelius-Score',
'sit' => 'application/x-stuffit',
'skd' => 'application/x-koan',
'skm' => 'application/x-koan',
'skp' => 'application/x-koan',
'skt' => 'application/x-koan',
'smi' => 'application/smil',
'smil' => 'application/smil',
'snd' => 'audio/basic',
'so' => 'application/octet-stream',
'spl' => 'application/x-futuresplash',
'src' => 'application/x-wais-source',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'svf' => 'application/vnd.svf',
'svg' => 'image/svg+xml',
//'svgz' => 'image/svg+xml',
'swf' => 'application/x-shockwave-flash',
'sxc' => 'application/vnd.sun.xml.calc',
'sxi' => 'application/vnd.sun.xml.impress',
'sxw' => 'application/vnd.sun.xml.writer',
't' => 'application/x-troff',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'texi' => 'application/x-texinfo',
'texinfo' => 'application/x-texinfo',
'tga' => 'image/x-targa',
'tif' => 'image/tif',
'tiff' => 'image/tiff',
'tr' => 'application/x-troff',
'tsv' => 'text/tab-seperated-values',
'txt' => 'text/plain',
'ustar' => 'application/x-ustar',
'vcd' => 'application/x-cdlink',
'vrml' => 'model/vrml',
'wav' => 'audio/x-wav',
'wbmp' => 'image/vnd.wap.wbmp',
'wbxml' => 'application/vnd.wap.wbxml',
'wml' => 'text/vnd.wap.wml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmls' => 'text/vnd.wap.wmlscript',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'wma' => 'video/x-ms-wma',
'wmv' => 'audio/x-ms-wmv',
'wrl' => 'model/vrml',
'xbm' => 'image/x-xbitmap',
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'xls' => 'application/vnd.ms-excel',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'xml' => 'text/xml',
'xpm' => 'image/x-xpixmap',
'xsl' => 'text/xml',
'xwd' => 'image/x-windowdump',
'xyz' => 'chemical/x-xyz',
'zip' => 'application/zip'
);
if ($filename === true) {
return $mime_types;
}
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asf' => 'video/x-ms-asf',
'asc' => 'text/plain',
'au' => 'audio/basic',
'avi' => 'video/x-msvideo',
'bcpio' => 'application/x-bcpio',
'bin' => 'application/octet-stream',
'bmp' => 'image/bmp',
'cdf' => 'application/x-netcdf',
'class' => 'application/octet-stream',
'cpio' => 'application/x-cpio',
'cpt' => 'application/mac-compactpro',
'csh' => 'application/x-csh',
'css' => 'text/css',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'djv' => 'image/vnd.djvu',
'djvu' => 'image/vnd.djvu',
'dll' => 'application/octet-stream',
'dmg' => 'application/x-diskcopy',
'dms' => 'application/octet-stream',
'doc' => 'application/msword',
'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'dvi' => 'application/x-dvi',
'dwg' => 'application/vnd.dwg',
'dxf' => 'application/vnd.dxf',
'dxr' => 'application/x-director',
'eps' => 'application/postscript',
'epub' => 'application/epub+zip',
'etx' => 'text/x-setext',
'exe' => 'application/octet-stream',
'ez' => 'application/andrew-inset',
'gif' => 'image/gif',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'hdf' => 'application/x-hdf',
'hqx' => 'application/mac-binhex40',
'htm' => 'text/html',
'html' => 'text/html',
'ice' => 'x-conference-xcooltalk',
'ief' => 'image/ief',
'iges' => 'model/iges',
'igs' => 'model/iges',
'jar' => 'application/java-archiver',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'application/x-javascript',
'kar' => 'audio/midi',
'lam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'latex' => 'application/x-latex',
'lha' => 'application/octet-stream',
'log' => 'text/plain',
'lzh' => 'application/octet-stream',
'm1a' => 'audio/mpeg',
'm2a' => 'audio/mpeg',
'm3u' => 'audio/x-mpegurl',
'man' => 'application/x-troff-man',
'me' => 'application/x-troff-me',
'mesh' => 'model/mesh',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mov' => 'video/quicktime',
'movie' => 'video/x-sgi-movie',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mp4' => 'video/mpeg4-generic',
'mpa' => 'audio/mpeg',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpga' => 'audio/mpeg',
'ms' => 'application/x-troff-ms',
'msh' => 'model/mesh',
'mxu' => 'video/vnd.mpegurl',
'nc' => 'application/x-netcdf',
'oda' => 'application/oda',
'oga'=> 'audio/ogg',
'ogg'=> 'application/ogg',
'ogx'=> 'application/ogg',
'ogv'=> 'video/ogg',
'pbm' => 'image/x-portable-bitmap',
'pct' => 'image/pict',
'pdb' => 'chemical/x-pdb',
'pdf' => 'application/pdf',
'pgm' => 'image/x-portable-graymap',
'pgn' => 'application/x-chess-pgn',
'pict' => 'image/pict',
'png' => 'image/png',
'pnm' => 'image/x-portable-anymap',
'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'pps' => 'application/vnd.ms-powerpoint',
'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'ppm' => 'image/x-portable-pixmap',
'ppt' => 'application/vnd.ms-powerpoint',
'pps' => 'application/vnd.ms-powerpoint',
'ps' => 'application/postscript',
'qt' => 'video/quicktime',
'ra' => 'audio/x-realaudio',
'ram' => 'audio/x-pn-realaudio',
'rar' => 'image/x-rar-compressed',
'ras' => 'image/x-cmu-raster',
'rgb' => 'image/x-rgb',
'rm' => 'audio/x-pn-realaudio',
'roff' => 'application/x-troff',
'rpm' => 'audio/x-pn-realaudio-plugin',
'rtf' => 'text/rtf',
'rtx' => 'text/richtext',
'sgm' => 'text/sgml',
'sgml' => 'text/sgml',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'silo' => 'model/mesh',
'sib' => 'application/X-Sibelius-Score',
'sit' => 'application/x-stuffit',
'skd' => 'application/x-koan',
'skm' => 'application/x-koan',
'skp' => 'application/x-koan',
'skt' => 'application/x-koan',
'smi' => 'application/smil',
'smil' => 'application/smil',
'snd' => 'audio/basic',
'so' => 'application/octet-stream',
'spl' => 'application/x-futuresplash',
'src' => 'application/x-wais-source',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'svf' => 'application/vnd.svf',
'svg' => 'image/svg+xml',
//'svgz' => 'image/svg+xml',
'swf' => 'application/x-shockwave-flash',
'sxc' => 'application/vnd.sun.xml.calc',
'sxi' => 'application/vnd.sun.xml.impress',
'sxw' => 'application/vnd.sun.xml.writer',
't' => 'application/x-troff',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'texi' => 'application/x-texinfo',
'texinfo' => 'application/x-texinfo',
'tga' => 'image/x-targa',
'tif' => 'image/tif',
'tiff' => 'image/tiff',
'tr' => 'application/x-troff',
'tsv' => 'text/tab-seperated-values',
'txt' => 'text/plain',
'ustar' => 'application/x-ustar',
'vcd' => 'application/x-cdlink',
'vrml' => 'model/vrml',
'wav' => 'audio/x-wav',
'wbmp' => 'image/vnd.wap.wbmp',
'wbxml' => 'application/vnd.wap.wbxml',
'wml' => 'text/vnd.wap.wml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmls' => 'text/vnd.wap.wmlscript',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'wma' => 'video/x-ms-wma',
'wmv' => 'audio/x-ms-wmv',
'wrl' => 'model/vrml',
'xbm' => 'image/x-xbitmap',
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'xls' => 'application/vnd.ms-excel',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'xml' => 'text/xml',
'xpm' => 'image/x-xpixmap',
'xsl' => 'text/xml',
'xwd' => 'image/x-windowdump',
'xyz' => 'chemical/x-xyz',
'zip' => 'application/zip'
);
//get the extension of the file
$extension = explode('.', $filename);
if ($filename === true) {
return $mime_types;
}
//$filename will be an array if a . was found
if (is_array($extension)) {
$extension = strtolower($extension[sizeof($extension) - 1]);
}
//file without extension
else {
$extension = 'empty';
}
//get the extension of the file
$extension = explode('.', $filename);
//if the extension is found, return the content type
if (isset($mime_types[$extension])) {
return $mime_types[$extension];
}
//else return octet-stream
return 'application/octet-stream';
//$filename will be an array if a . was found
if (is_array($extension)) {
$extension = strtolower($extension[sizeof($extension) - 1]);
}
//file without extension
else {
$extension = 'empty';
}
//if the extension is found, return the content type
if (isset($mime_types[$extension])) {
return $mime_types[$extension];
}
//else return octet-stream
return 'application/octet-stream';
}
/**

@ -405,32 +405,8 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
}
}
}
} else {
$parent_id = isset($my_folder_data['id']) ? $my_folder_data['id'] : 0;
if (!empty($group_id)) {
$group_query = " WHERE c_id = $course_id AND post_group_id = '".intval($group_id)."' "; // set to select only messages posted by the user's group
} else {
$group_query = " WHERE c_id = $course_id AND post_group_id = '0' ";
}
$subdirs_query = "AND parent_id = $parent_id ";
if ($is_allowed_to_edit) {
} else {
if (isset($course_info['show_score']) && $course_info['show_score'] == 1) {
$subdirs_query .= " AND user_id = ".api_get_user_id()." ";
} else {
$subdirs_query .= '';
}
}
$active_condition = ' AND active IN (1)';
$sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session ORDER BY title";
$sql_result = Database::query($sql_get_publications_list);
}
$edit_dir = isset($_GET['edit_dir']) ? $_GET['edit_dir'] : '';
$table_header = array();
@ -462,7 +438,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$group_id = api_get_group_id();
if (is_array($work_parents)) {
foreach ($work_parents as $work_parent) {
$sql_select_directory = "SELECT title, url, prop.insert_date, prop.lastedit_date, work.id, author, has_properties, view_properties, description, qualification, weight, allow_text_assignment
FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id AND prop.c_id = $course_id )
@ -571,7 +546,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$form_folder -> addElement('html', '</div>');
}
if ($homework['ends_on'] != '0000-00-00 00:00:00') {
$homework['ends_on'] = api_get_local_time($homework['ends_on']);
$there_is_a_end_date = true;
@ -738,12 +712,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$action = '';
$row = array();
$class = '';
//$a_count_directory = count_dir($work_dir.'/'.$dir, false);
$cant_files = 0;
$cant_dir = 0;
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
@ -839,111 +808,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
}
}
//If an id was loaded we loop through the documents
$my_assignment = get_work_assignment_by_id($id);
if (Database::num_rows($sql_result) > 0) {
while ($work = Database::fetch_object($sql_result)) {
//Get the author ID for that document from the item_property table
$is_author = false;
$can_read = false;
$item_property_data = api_get_item_property_info(api_get_course_int_id(), 'work', $work->id, api_get_session_id());
if (!$is_allowed_to_edit && $item_property_data['insert_user_id'] == api_get_user_id()) {
$is_author = true;
}
if ($course_info['show_score'] == 0 ) {
$can_read = true;
}
$user_info = api_get_user_info($item_property_data['insert_user_id']);
//display info depending on the permissions
if (($can_read && $work->accepted == '1') || ($is_author && $work->accepted == '1') || $is_allowed_to_edit || CourseManager::is_course_teacher($item_property_data['insert_user_id'], $_course['code'])) {
$row = array();
if ($work->accepted == '0') {
$class = 'class="invisible"';
} else {
$class = '';
}
$qualification_string = '';
if ($qualification_exists) {
if ($work->qualification == '') {
$qualification_string = '<b style="color:orange"> - </b>';
} else {
$qualification_string = '<b style="color:blue">'.$work->qualification.'</b>';
}
}
$add_string = '';
$time_expires = api_strtotime($my_assignment['expires_on'], 'UTC');
if (!empty($my_assignment['expires_on']) && $my_assignment['expires_on'] != '0000-00-00 00:00:00' && $time_expires < api_strtotime($work->sent_date, 'UTC')) {
$add_string = ' <b style="color:red">'.get_lang('Expired').'</b>';
}
$row[] = '<a href="download.php?id='.$work->id.'">'.build_document_icon_tag('file', substr(basename($work->url), 13)).'</a>';
if ($work->contains_file) {
$row[] = '<a href="download.php?id='.$work->id.'"'.$class.'>'.Display::return_icon('save.png', get_lang('Save'),array('style' => 'float:right;'), ICON_SIZE_SMALL).' '.$work->title.'</a><br />'.$work->description;
} else {
$row[] = '<a href="view.php?id='.$work->id.'"'.$class.'>'.$work->title.'</a><br />'.$work->description;
}
$row[] = $user_info['firstname']; // $work->author;
$row[] = $user_info['lastname'];
if ($qualification_exists) {
$row[] = $qualification_string;
}
$work_sent_date_local = api_get_local_time($work->sent_date);
$row[] = date_to_str_ago($work_sent_date_local).$add_string.'<br /><span class="dropbox_date">'.api_format_date($work_sent_date_local).'</span>';
if ($is_allowed_to_edit) {
$action = '';
if ($qualification_exists) {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=edit&item_id='.$work->id.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&amp;parent_id='.$work->parent_id.'" title="'.get_lang('Modify').'" >'.
Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=edit&item_id='.$work->id.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&amp;parent_id='.$work->parent_id.'" title="'.get_lang('Modify').'" >'.
Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).'</a>';
}
if ($work->contains_file) {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=move&item_id='.$work->id.'" title="'.get_lang('Move').'">'.Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
}
if ($work->accepted == '1') {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=make_invisible&item_id='.$work->id.'&amp;'.$sort_params.'" title="'.get_lang('Invisible').'" >'.Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=make_visible&item_id='.$work->id.'&amp;'.$sort_params.'" title="'.get_lang('Visible').'" >'.Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
}
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=delete&amp;item_id='.$work->id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('WorkDelete').'" >'.Display::return_icon('delete.png', get_lang('WorkDelete'),'',ICON_SIZE_SMALL).'</a>';
$row[] = $action;
// the user that is not course admin can only edit/delete own document
} elseif ($is_author && empty($work->qualificator_id)) {
if (!$table_has_actions_column) {
$table_header[] = array(get_lang('Actions'), false, 'style="width:90px"');
$table_has_actions_column = true;
}
$action = '';
if (api_is_allowed_to_session_edit(false, true)) {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&amp;origin='.$origin.'&gradebook='.$gradebook.'&amp;action=edit&item_id='.$work->id.'" title="'.get_lang('Modify').'" >'.Display::return_icon('edit.png', get_lang('Modify'),array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
}
if (api_get_course_setting('student_delete_own_publication') == 1) {
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$my_folder_data['id'].'&origin='.$origin.'&gradebook='.$gradebook.'&amp;action=delete&amp;item_id='.$work->id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('WorkDelete').'" >'.Display::return_icon('delete.png',get_lang('WorkDelete'),'',ICON_SIZE_SMALL).'</a>';
}
$row[] = $action;
} else {
$row[] = ' ';
}
$row[] = $work_sent_date_local;
$table_data[] = $row;
}
}
}
$sorting_options = array();
$sorting_options['column'] = 1;
@ -995,11 +859,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$my_params['origin'] = $origin;
Display::display_sortable_config_table('work', $table_header, $table_data, $sorting_options, $paging_options, $my_params, $column_show, $column_order);
}
function get_work_list() {
}
/**
* Returns a list of subdirectories found in the given directory.
*
@ -1606,113 +1465,248 @@ function get_work_id($path) {
}
}
/**
* Get list of users who have not given the task
* @param int
* @return array
* @author cvargas
* @author Julio Montoya <gugli100@gmail.com> Fixing query
*/
function get_list_users_without_publication($task_id) {
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
function get_count_work($work_id) {
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
//condition for the session
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$condition_session = api_get_session_condition($session_id);
$task_id = intval($task_id);
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$group_id = api_get_group_id();
$course_info = api_get_course_info();
$work_id = intval($work_id);
if (!empty($group_id)) {
$extra_conditions = " work.post_group_id = '".intval($group_id)."' "; // set to select only messages posted by the user's group
} else {
$extra_conditions = " work.post_group_id = '0' ";
}
if ($session_id == 0) {
$sql = "SELECT user_id as id FROM $work_table WHERE c_id = $course_id AND parent_id='$task_id'";
} else {
$sql = "SELECT user_id as id FROM $work_table WHERE c_id = $course_id AND parent_id='$task_id' and session_id='".$session_id."'";
}
$result = Database::query($sql);
$users_with_tasks = array();
while($row = Database::fetch_array($result)) {
$users_with_tasks[] = $row['id'];
}
if ($is_allowed_to_edit) {
$extra_conditions .= ' AND work.active IN (0, 1) ';
} else {
$extra_conditions .= ' AND work.active IN (1) ';
if (isset($course_info['show_score']) && $course_info['show_score'] == 1) {
$extra_conditions = " AND user_id = ".api_get_user_id()." ";
} else {
$extra_conditions .= '';
}
}
$extra_conditions .= " AND parent_id = ".$work_id." ";
if ($session_id == 0){
$sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email FROM $table_course_user AS cu, $table_user AS u
WHERE u.status!=1 and cu.course_code='".api_get_course_id()."' AND u.user_id=cu.user_id";
} else {
$sql_users = "SELECT cu.id_user, u.lastname, u.firstname, u.email FROM $session_course_rel_user AS cu, $table_user AS u
WHERE u.status!=1 and cu.course_code='".api_get_course_id()."' AND u.user_id=cu.id_user and cu.id_session='".$session_id."'";
}
$sql = "SELECT count(*) as count
FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id AND prop.c_id = $course_id AND work.c_id = $course_id )
INNER JOIN $user_table u ON (work.user_id = u.user_id)
WHERE $extra_conditions $where_condition $condition_session ";
$result = Database::query($sql);
$group_id = api_get_group_id();
$users_with_work = 0;
if (Database::num_rows($result)) {
$result = Database::fetch_array($result);
$users_with_work = $result['count'];
}
return $users_with_work;
}
$new_group_user_list = array();
function get_work_user_list($start, $limit, $column, $direction, $work_id, $where_condition) {
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
if ($group_id) {
$group_user_list = GroupManager::get_subscribed_users($group_id);
if (!empty($group_user_list)) {
foreach($group_user_list as $group_user) {
$new_group_user_list[] = $group_user['user_id'];
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$session_course_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$group_id = api_get_group_id();
$course_info = api_get_course_info();
$work_id = intval($work_id);
$column = empty($column) ? : Database::escape_string($column);
$start = intval($start);
$limit = intval($limit);
if (!in_array($direction, array('asc','desc'))) {
$direction = 'desc';
}
$work_data = get_work_data_by_id($work_id);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$condition_session = api_get_session_condition($session_id);
if (!empty($work_data)) {
if (!empty($group_id)) {
$extra_conditions = " work.post_group_id = '".intval($group_id)."' "; // set to select only messages posted by the user's group
} else {
$extra_conditions = " work.post_group_id = '0' ";
}
if ($is_allowed_to_edit) {
$extra_conditions .= ' AND work.active IN (0, 1) ';
} else {
$extra_conditions .= ' AND work.active IN (1) ';
if (isset($course_info['show_score']) && $course_info['show_score'] == 1) {
$extra_conditions .= " AND u.user_id = ".api_get_user_id()." ";
} else {
$extra_conditions .= '';
}
}
}
$extra_conditions .= " AND parent_id = ".$work_id." ";
$result_users = Database::query($sql_users);
$users_without_tasks = array();
while ($row_users = Database::fetch_row($result_users)) {
if (empty($session_id)) {
$course_conditions = " INNER JOIN $course_user_table cu ON (cu.user_id = u.user_id AND cu.course_code = '".$course_info['code']."' ) ";
}
if (in_array($row_users[0], $users_with_tasks)) continue;
if ($group_id && !in_array($row_users[0], $new_group_user_list)) {
continue;
if ($show_user_no_work) {
$select = 'DISTINCT u.firstname, u.lastname, u.username';
$user_condition = " INNER JOIN $user_table u ON (work.user_id != u.user_id) ";
$work_condition = " $work_table work ";
$work_where = " AND (work.c_id = $course_id ) ";
} else {
$select = 'DISTINCT work.id as id, title as file, url, sent_date, contains_file, has_properties, view_properties,
qualification, weight, allow_text_assignment, u.firstname, u.lastname, u.username, parent_id, accepted, qualificator_id';
$user_condition = "INNER JOIN $user_table u ON (work.user_id = u.user_id) ";
$work_condition = "$iprop_table prop INNER JOIN $work_table work ON (prop.ref = work.id AND prop.c_id = $course_id AND work.c_id = $course_id ) ";
$work_where = '';
}
//$user_id = array_shift($row_users);
$row_users[0] = $row_users[1];
$row_users[1] = $row_users[2];
$row_users[2] = Display::encrypted_mailto_link($row_users[3]);
$users_without_tasks[] = $row_users;
}
return $users_without_tasks;
}
$work_assignment = get_work_assignment_by_id($work_id);
/**
* Display list of users who have not given the task
*
* @param int task id
* @return array
* @author cvargas carlos.vargas@beeznest.com cfasanando, christian.fasanado@beeznest.com
* @author Julio Montoya <gugli100@gmail.com> Fixes
*/
function display_list_users_without_publication($task_id) {
global $origin;
$table_header[] = array(get_lang('LastName'), true);
$table_header[] = array(get_lang('FirstName'), true);
$table_header[] = array(get_lang('Email'), true);
// table_data
$table_data = get_list_users_without_publication($task_id);
$sql = "SELECT $select
FROM $work_condition $user_condition $course_conditions
WHERE $extra_conditions $work_where $where_condition $condition_session ";
$sql .= " ORDER BY $column $direction ";
$sql .= " LIMIT $start, $limit";
$sorting_options = array();
$sorting_options['column'] = 1;
$paging_options = array();
$my_params = array();
$result = Database::query($sql);
$works = array();
if (isset($_GET['curdirpath'])) {
$my_params['curdirpath'] = Security::remove_XSS($_GET['curdirpath']);
}
if (isset($_GET['edit_dir'])) {
$my_params['edit_dir'] = Security::remove_XSS($_GET['edit_dir']);
}
if (isset($_GET['list'])) {
$my_params['list'] = Security::remove_XSS($_GET['list']);
}
$my_params['origin'] = $origin;
while ($work = Database::fetch_array($result, 'ASSOC')) {
//var_dump($work);
$item_id = $work['id'];
//$column_show
$column_show[] = 1;
$column_show[] = 1;
$column_show[] = 1;
Display::display_sortable_config_table('work', $table_header, $table_data, $sorting_options, $paging_options, $my_params, $column_show);
//Get the author ID for that document from the item_property table
$is_author = false;
$can_read = false;
$item_property_data = api_get_item_property_info(api_get_course_int_id(), 'work', $item_id, api_get_session_id());
if (!$is_allowed_to_edit && $item_property_data['insert_user_id'] == api_get_user_id()) {
$is_author = true;
}
if ($course_info['show_score'] == 0 ) {
$can_read = true;
}
if ($work['accepted'] == '0') {
$class = 'invisible';
} else {
$class = '';
}
$qualification_exists = false;
if (!empty($work_data['qualification']) && intval($work_data['qualification']) > 0) {
$qualification_exists = true;
}
$qualification_string = '';
if ($qualification_exists) {
if ($work['qualification'] == '') {
$qualification_string = Display::label('-');
} else {
$qualification_string = Display::label($work['qualification'], 'info');
}
}
$add_string = '';
$time_expires = api_strtotime($work['expires_on'], 'UTC');
if (!empty($work_assignment['expires_on']) && $work_assignment['expires_on'] != '0000-00-00 00:00:00' && $time_expires && ($time_expires < api_strtotime($work['sent_date'], 'UTC'))) {
$add_string = Display::label(get_lang('Expired'),'important');
}
if (($can_read && $work['accepted'] == '1') || ($is_author && $work['accepted'] == '1') || $is_allowed_to_edit) {
//Firstname, lastname, username
$work['firstname'] = Display::div($work['firstname'], array('class' => $class));
$work['lastname'] = Display::div($work['lastname'], array('class' => $class));
$work['username'] = Display::div($work['username'], array('class' => $class));
//Type
$work['type'] = build_document_icon_tag('file', $work['file']);
//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
$work_date = api_convert_and_format_date($work['sent_date']);
$work['sent_date'] = date_to_str_ago(api_get_local_time($work['sent_date'])).' '.$add_string.'<br />'.$work_date;
//Actions
$url = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&id='.$work_id.'&origin='.$origin.'&gradebook='.Security::remove_XSS($_GET['gradebook']);
$action = '';
if ($is_allowed_to_edit) {
if ($qualification_exists) {
$action .= '<a href="'.$url.'&amp;action=edit&item_id='.$item_id.'&amp;parent_id='.$work['parent_id'].'" title="'.get_lang('Modify').'" >'.
Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.$url.'&amp;action=edit&item_id='.$item_id.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&amp;parent_id='.$work['parent_id'].'" title="'.get_lang('Modify').'" >'.
Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).'</a>';
}
if ($work['contains_file']) {
$action .= '<a href="'.$url.'&amp;action=move&item_id='.$item_id.'" title="'.get_lang('Move').'">'.Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
}
if ($work['accepted'] == '1') {
$action .= '<a href="'.$url.'&amp;action=make_invisible&item_id='.$item_id.'&amp;'.$sort_params.'" title="'.get_lang('Invisible').'" >'.Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.$url.'&amp;action=make_visible&item_id='.$item_id.'&amp;'.$sort_params.'" title="'.get_lang('Visible').'" >'.Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
}
$action .= '<a href="'.$url.'&amp;action=delete&amp;item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
} elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
if (api_is_allowed_to_session_edit(false, true)) {
$action .= '<a href="'.$url.'&amp;action=edit&item_id='.$item_id.'" title="'.get_lang('Modify').'" >'.Display::return_icon('edit.png', get_lang('Modify'),array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
}
if (api_get_course_setting('student_delete_own_publication') == 1) {
$action .= '<a href="'.$url.'&amp;action=delete&amp;item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
}
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
}
//Status
if (empty($work['qualificator_id'])) {
$qualificator_id = Display::label(get_lang('NotRevised'), 'warning');
} else {
$qualificator_id = Display::label(get_lang('Revised'), 'success');
}
$work['qualificator_id'] = $qualificator_id;
$work['actions'] = $link_to_download.$action;
$works[] = $work;
}
}
return $works;
}
}
/**
@ -1862,3 +1856,113 @@ function user_is_author($item_id, $user_id = null) {
}
return $is_author;
}
/**
* Get list of users who have not given the task
* @param int
* @return array
* @author cvargas
* @author Julio Montoya <gugli100@gmail.com> Fixing query
*/
function get_list_users_without_publication($task_id) {
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
//condition for the session
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$task_id = intval($task_id);
if ($session_id == 0) {
$sql = "SELECT user_id as id FROM $work_table WHERE c_id = $course_id AND parent_id='$task_id'";
} else {
$sql = "SELECT user_id as id FROM $work_table WHERE c_id = $course_id AND parent_id='$task_id' and session_id='".$session_id."'";
}
$result = Database::query($sql);
$users_with_tasks = array();
while($row = Database::fetch_array($result)) {
$users_with_tasks[] = $row['id'];
}
if ($session_id == 0){
$sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email FROM $table_course_user AS cu, $table_user AS u
WHERE u.status!=1 and cu.course_code='".api_get_course_id()."' AND u.user_id=cu.user_id";
} else {
$sql_users = "SELECT cu.id_user, u.lastname, u.firstname, u.email FROM $session_course_rel_user AS cu, $table_user AS u
WHERE u.status!=1 and cu.course_code='".api_get_course_id()."' AND u.user_id=cu.id_user and cu.id_session='".$session_id."'";
}
$group_id = api_get_group_id();
$new_group_user_list = array();
if ($group_id) {
$group_user_list = GroupManager::get_subscribed_users($group_id);
if (!empty($group_user_list)) {
foreach($group_user_list as $group_user) {
$new_group_user_list[] = $group_user['user_id'];
}
}
}
$result_users = Database::query($sql_users);
$users_without_tasks = array();
while ($row_users = Database::fetch_row($result_users)) {
if (in_array($row_users[0], $users_with_tasks)) continue;
if ($group_id && !in_array($row_users[0], $new_group_user_list)) {
continue;
}
//$user_id = array_shift($row_users);
$row_users[0] = $row_users[1];
$row_users[1] = $row_users[2];
$row_users[2] = Display::encrypted_mailto_link($row_users[3]);
$users_without_tasks[] = $row_users;
}
return $users_without_tasks;
}
/**
* Display list of users who have not given the task
*
* @param int task id
* @return array
* @author cvargas carlos.vargas@beeznest.com cfasanando, christian.fasanado@beeznest.com
* @author Julio Montoya <gugli100@gmail.com> Fixes
*/
function display_list_users_without_publication($task_id) {
global $origin;
$table_header[] = array(get_lang('LastName'), true);
$table_header[] = array(get_lang('FirstName'), true);
$table_header[] = array(get_lang('Email'), true);
// table_data
$table_data = get_list_users_without_publication($task_id);
$sorting_options = array();
$sorting_options['column'] = 1;
$paging_options = array();
$my_params = array();
if (isset($_GET['curdirpath'])) {
$my_params['curdirpath'] = Security::remove_XSS($_GET['curdirpath']);
}
if (isset($_GET['edit_dir'])) {
$my_params['edit_dir'] = Security::remove_XSS($_GET['edit_dir']);
}
if (isset($_GET['list'])) {
$my_params['list'] = Security::remove_XSS($_GET['list']);
}
$my_params['origin'] = $origin;
//$column_show
$column_show[] = 1;
$column_show[] = 1;
$column_show[] = 1;
Display::display_sortable_config_table('work', $table_header, $table_data, $sorting_options, $paging_options, $my_params, $column_show);
}

@ -75,6 +75,8 @@ if (!empty($my_folder_data)) {
}
}
}
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = to_javascript_work();
$htmlHeadXtra[] = '<script type="text/javascript">
@ -89,7 +91,7 @@ $(document).ready(function () {
// Table definitions
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$iprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
//$iprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$TSTDPUBASG = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -279,6 +281,7 @@ if (!in_array($action, array('send_mail','add','create_dir','upload'))) {
$show_tool_options = (in_array($action, array('list', 'add'))) ? true : false;
$display_upload_link = $action == 'upload_form' ? false : true;
if ($is_special) {
$homework = get_work_assignment_by_id($my_folder_data['id']);
@ -373,11 +376,11 @@ switch ($action) {
// form title
if ($item_id) {
$form_title = get_lang('EditMedia');
$form_title = get_lang('Edit');
} else {
$form_title = get_lang('UploadADocument');
}
$form->addElement('header', '', $form_title);
$form->addElement('header', $form_title);
if (!empty ($error_message)) {
Display :: display_error_message($error_message);
@ -461,10 +464,17 @@ switch ($action) {
$form->add_real_progress_bar('uploadWork', 'file');
}
$form->setDefaults($defaults);
//fixes bug when showing modification form
//fixes bug when showing modification form
if (!empty($work_id)) {
if ( $is_allowed_to_edit or $is_author) {
if ( $is_allowed_to_edit) {
$form->display();
} elseif ($is_author) {
if (empty($work_item['qualificator_id']) || $work_item['qualificator_id'] == 0) {
$form->display();
} else {
Display::display_error_message(get_lang('ActionNotAllowed'));
}
} elseif ($student_can_edit_in_session && $has_ended == false) {
$form->display();
} else {
@ -680,7 +690,7 @@ switch ($action) {
$emailbody_user .= get_lang('FileName')." : ".$title."\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');;
//Mail to user
var_dump($currentUserEmail, $emailsubject, $emailbody_user, $sender_name, $email_admin);
//var_dump($currentUserEmail, $emailsubject, $emailbody_user, $sender_name, $email_admin);
@api_mail('', $currentUserEmail, $emailsubject, $emailbody_user, $sender_name, $email_admin);
}
@ -1100,14 +1110,13 @@ switch ($action) {
}
/* Display list of student publications */
if ($curdirpath == '/') {
$my_cur_dir_path = '';
} else {
$my_cur_dir_path = $curdirpath;
}
$add_query = '';
/*$add_query = '';
//Getting if I'm a teacher
$sql = "SELECT user.firstname, user.lastname FROM $table_user user, $table_course_user course_user
WHERE course_user.user_id=user.user_id AND course_user.course_code='".api_get_course_id()."' AND course_user.status='1'";
@ -1120,9 +1129,9 @@ switch ($action) {
//If I'm student & I'm in a special work and check the work setting: "New documents are visible for all users"
if (!$is_allowed_to_edit && $is_special && $uploadvisibledisabled == 1) {
$add_query = ' AND author IN('.$admin_course.'\''.api_get_person_name($_user['firstName'], $_user['lastName']).'\')';
}
}*/
if ($is_allowed_to_edit && $is_special) {
/*if ($is_allowed_to_edit && $is_special) {
if (!empty($_REQUEST['filter'])) {
switch($_REQUEST['filter']) {
case 1:
@ -1148,19 +1157,61 @@ switch ($action) {
$form_filter .= '<button type="submit" class="save" value="'.get_lang('FilterAssignments').'">'.get_lang('FilterAssignments').'</button></form>';
echo $form_filter;
}
}
}*/
if (!empty($my_folder_data['description'])) {
echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description'], STUDENT).'</p></div></p>';
}
if ($display_list_users_without_publication) {
display_list_users_without_publication($my_folder_data['id']);
} else {
display_student_publications_list($work_id, $link_target_parameter, $dateFormatLong, $origin, $add_query);
}
//User works
if (isset($work_id) && !empty($work_id) && (isset($_GET['list']) && $_GET['list'] == 'with')) {
$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')
);
$extra_params = array();
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//$extra_params['excel'] = 'excel';
//$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;
?>
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
});
</script>
<?php
echo Display::grid_html('results');
} elseif (isset($_GET['list']) && $_GET['list'] == 'without') {
//User with no works
display_list_users_without_publication($work_id);
} else {
//Work list
display_student_publications_list($work_id, $link_target_parameter, $dateFormatLong, $origin, $add_query);
}
break;
}
if ($origin != 'learnpath') {
//we are not in the learning path tool
Display :: display_footer();

Loading…
Cancel
Save