From bd08d27809a74760965c701fcd7fa6dceb8336db Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 29 Mar 2012 14:52:34 +0200 Subject: [PATCH] Using jqgrid in work see BT#4131 partial --- main/img/icons/22/default.png | Bin 0 -> 1152 bytes main/inc/ajax/model.ajax.php | 40 ++- main/inc/ajax/work.ajax.php | 22 ++ main/inc/lib/document.lib.php | 410 ++++++++++++------------ main/work/work.lib.php | 582 ++++++++++++++++++++-------------- main/work/work.php | 91 ++++-- 6 files changed, 666 insertions(+), 479 deletions(-) create mode 100644 main/img/icons/22/default.png create mode 100644 main/inc/ajax/work.ajax.php diff --git a/main/img/icons/22/default.png b/main/img/icons/22/default.png new file mode 100644 index 0000000000000000000000000000000000000000..ddea8c74275e968581f37b0eaf6e1723b3c2054e GIT binary patch literal 1152 zcmV-`1b_R9P)Px%7Enx7MTLiiK|(-%e|&?5f`*8Nh>C}ai-?Pjij0nnjgO3ukd2R#j*ya%k&}>; zl#!E_l9ZN{mY9{8nwOfJn4F%QpPiwdpPZhcot&YgpP`fq4p*4N?L*W2XL=h)ce;L!Qo z*xcvO?c&nz+1cdW+1}{T?$_Mk<Bd-`Csg+S}#W-QeWZ@a)j_+uY{g+~L{X z?cCkx>(ueu-tOJr=-c4q;NIfw)$-oo>EYkw?bh?$;^f@m@ZaF-;^5@n-5$2 zKbx<>>U+{o~{A=Huw{+W6q)^x@{|=j7?(<@My{@8aj`=;i9- z=Jw_0@Z;#~;OX({=IiF?@#N|3``r8I=Fwj}^ycjD>FV_C>h9|7 z>E!M8=k4$6>-O#I@9XaB>F)6H?CS6A@#^pL@a^*J@bm8Q?eXsO?D6#P@$T~P^!4xV z?eg{T^6&2R_VM%Z_wn%b^7iud@$dEb`tbJk^Y`=h^6>Wf^!M}f_xbwu^Y-}k_xbkt z`uF+!`1<_${rms>{rdd>`~Us_{{Q?WgGY4$0004WQchCDiV~>t>#9v-gCQ&w!8Oc%kSQ1vk4_3K7Sfr#%CY^6t-TyF@NZ-R&{f;uC1JlNt`(7ll1PXN)+usw&i;HmqGS`I7>lt{hM_~oN!ZuznY(pamh-uE zN?79Kg5e z=X-m*(XfsZ?SNj-)Px7ZN$8q9OLht#p#U&054%R8YkUlzh7dZ($DE_yFaH2K^{M|@ ShQHSU0000delete($_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_exercise_results': - $course = api_get_course_info(); - $is_allowedToEdit = api_is_allowed_to_edit(null,true); - $is_tutor = api_is_allowed_to_edit(true); + 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(); //used inside get_exam_results_data() - $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; - + $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'] = ''.$item['name'].''; } @@ -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 of the jqgrid - ref #4235 if ($row['id'] == "") { @@ -285,14 +295,14 @@ if (in_array($action, array('get_careers', 'get_promotions', 'get_usergroups', ' } else { $response->rows[$i]['id']=$row['id']; } - $array = array(); - foreach($columns as $col) { + $array = array(); + foreach ($columns as $col) { $array[] = $row[$col]; } $response->rows[$i]['cell']=$array; $i++; } - } + } echo json_encode($response); } exit; \ No newline at end of file diff --git a/main/inc/ajax/work.ajax.php b/main/inc/ajax/work.ajax.php new file mode 100644 index 0000000000..c8ed111c68 --- /dev/null +++ b/main/inc/ajax/work.ajax.php @@ -0,0 +1,22 @@ + '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'; } /** diff --git a/main/work/work.lib.php b/main/work/work.lib.php index 6c2406be2b..5a43025e31 100644 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -405,31 +405,7 @@ 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'] : ''; @@ -461,8 +437,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $group_id = api_get_group_id(); - if (is_array($work_parents)) { - + 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 ) @@ -569,8 +544,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $form_folder -> addElement('html', ''); - } - + } if ($homework['ends_on'] != '0000-00-00 00:00:00') { $homework['ends_on'] = api_get_local_time($homework['ends_on']); @@ -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; - + $cant_files = 0; $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); @@ -838,111 +807,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $table_data[] = $row; } } - - //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 = ' - '; - } else { - $qualification_string = ''.$work->qualification.''; - } - } - - $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 = ' '.get_lang('Expired').''; - } - - $row[] = ''.build_document_icon_tag('file', substr(basename($work->url), 13)).''; - if ($work->contains_file) { - $row[] = ''.Display::return_icon('save.png', get_lang('Save'),array('style' => 'float:right;'), ICON_SIZE_SMALL).' '.$work->title.'
'.$work->description; - } else { - $row[] = ''.$work->title.'
'.$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.'
'.api_format_date($work_sent_date_local).''; - - if ($is_allowed_to_edit) { - $action = ''; - if ($qualification_exists) { - $action .= ''. - Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL).''; - } else { - $action .= ''. - Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).''; - } - if ($work->contains_file) { - $action .= ''.Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).''; - } - if ($work->accepted == '1') { - $action .= ''.Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).''; - } else { - $action .= ''.Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).' '; - } - $action .= ''.Display::return_icon('delete.png', get_lang('WorkDelete'),'',ICON_SIZE_SMALL).''; - $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 .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), ICON_SIZE_SMALL).''; - } 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 .= ''.Display::return_icon('delete.png',get_lang('WorkDelete'),'',ICON_SIZE_SMALL).''; - } - $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 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(); +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); + + $is_allowed_to_edit = api_is_allowed_to_edit(null, true); + $condition_session = api_get_session_condition($session_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' "; + } - $task_id = intval($task_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." "; + + $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); + + $users_with_work = 0; + if (Database::num_rows($result)) { + $result = Database::fetch_array($result); + $users_with_work = $result['count']; + } + return $users_with_work; +} - 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']; - } +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); + + $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 ($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."'"; - } + if (!in_array($direction, array('asc','desc'))) { + $direction = 'desc'; + } - $group_id = api_get_group_id(); + $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)) { - $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']; + 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." "; + + 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']."' ) "; } - } - - $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; + 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; -} - -/** - * 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 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); - + $work_assignment = get_work_assignment_by_id($work_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"; + + $result = Database::query($sql); + $works = array(); + + while ($work = Database::fetch_array($result, 'ASSOC')) { + //var_dump($work); + $item_id = $work['id']; + + //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 = ''.Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).' '; + } else { + $link_to_download = ''.Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).' '; + } + $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.'
'.$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 .= ''. + Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL).''; + } else { + $action .= ''. + Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).''; + } - $sorting_options = array(); - $sorting_options['column'] = 1; - $paging_options = array(); - $my_params = array(); + if ($work['contains_file']) { + $action .= ''.Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).''; + } + if ($work['accepted'] == '1') { + $action .= ''.Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).''; + } else { + $action .= ''.Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).' '; + } + $action .= ''.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).''; + } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) { + if (api_is_allowed_to_session_edit(false, true)) { + $action .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), ICON_SIZE_SMALL).''; + } 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 .= ''.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).''; + } + } else { + $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL); + } - 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; + //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; - //$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); + $work['actions'] = $link_to_download.$action; + + + + + $works[] = $work; + } + } + return $works; + + } } /** @@ -1861,4 +1855,114 @@ function user_is_author($item_id, $user_id = null) { api_not_allowed(); } return $is_author; +} + + +/** + * Get list of users who have not given the task + * @param int + * @return array + * @author cvargas + * @author Julio Montoya 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 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); } \ No newline at end of file diff --git a/main/work/work.php b/main/work/work.php index d241ecf84f..8672caac2a 100644 --- a/main/work/work.php +++ b/main/work/work.php @@ -75,6 +75,8 @@ if (!empty($my_folder_data)) { } } } +$htmlHeadXtra[] = api_get_jqgrid_js(); + $htmlHeadXtra[] = to_javascript_work(); $htmlHeadXtra[] = ' +