Certificates added to Chamilo see CT#751 (partial)

skala
Julio Montoya 15 years ago
parent f725c3c074
commit 57658eaa37
  1. 121
      main/document/create_document.php
  2. 72
      main/document/document.inc.php
  3. 163
      main/document/document.php
  4. 46
      main/document/edit_document.php
  5. 33
      main/document/upload.php
  6. 45
      main/gradebook/gradebook.php
  7. 83
      main/gradebook/gradebook_display_certificate.php
  8. 130
      main/gradebook/index.php
  9. 27
      main/gradebook/lib/fe/displaygradebook.php
  10. 24
      main/gradebook/lib/fe/flatviewtable.class.php
  11. 171
      main/gradebook/lib/fe/gradebooktable.class.php
  12. 152
      main/gradebook/lib/gradebook_functions.inc.php
  13. BIN
      main/img/certificate.png
  14. BIN
      main/img/nocertificate.png
  15. 2
      main/inc/lib/database.lib.php
  16. 202
      main/inc/lib/document.lib.php
  17. 120
      main/inc/lib/usermanager.lib.php

@ -1,44 +1,13 @@
<?php // $Id: create_document.php 22259 2009-07-20 18:56:45Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Olivier Brouckaert
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* See license terms in /license.txt */
/**
==============================================================================
* This file allows creating new html documents with an online WYSIWYG html380
* editor.
*
* @package dokeos.document
==============================================================================
* @package chamilo.document
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* INIT SECTION */
// name of the language file that needs to be included
$language_file = 'document';
@ -196,7 +165,12 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
$nameTools = get_lang('CreateDocument');
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
if (isset($_REQUEST['certificate'])) {
$nameTools = get_lang('CreateCertificate');
} else {
$nameTools = get_lang('CreateDocument');
}
/*
@ -280,23 +254,31 @@ if (!is_dir($filepath)) {
}
//------------
//I'm in the certification module?
$is_certificate_mode = false;
$is_certificate_array = explode('/',$_GET['dir']);
array_shift($is_certificate_array);
if ($is_certificate_array[0]=='certificates') {
$is_certificate_mode = true;
}
/**************************************************/
$to_group_id = 0;
if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
$interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
$noPHP_SELF = true;
$to_group_id = $_SESSION['_gid'];
$group = GroupManager :: get_group_properties($to_group_id);
$path = explode('/', $dir);
if ('/'.$path[1] != $group['directory']) {
api_not_allowed(true);
if (!$is_certificate_mode) {
if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
$interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
$noPHP_SELF = true;
$to_group_id = $_SESSION['_gid'];
$group = GroupManager :: get_group_properties($to_group_id);
$path = explode('/', $dir);
if ('/'.$path[1] != $group['directory']) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($_GET['dir']).$req_gid, "name" => get_lang('Documents'));
} else {
$interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
}
$interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($_GET['dir']).$req_gid, "name" => get_lang('Documents'));
if (!$is_allowed_in_course)
api_not_allowed(true);
@ -320,11 +302,16 @@ if (isset ($group)) {
}
// Create a new form
$form = new FormValidator('create_document');
$form = new FormValidator('create_document','post',api_get_self().'?dir='.Security::remove_XSS(urlencode($_GET['dir'])).'&selectcat='.Security::remove_XSS($_GET['selectcat']));
// form title
$form->addElement('header', '', $nameTools);
if (isset($_REQUEST['certificate'])) {//added condition for certicate in gradebook
$form->addElement('hidden','certificate','true',array('id'=>'certificate'));
if (isset($_GET['selectcat']))
$form->addElement('hidden','selectcat',intval($_GET['selectcat']));
}
$renderer = & $form->defaultRenderer();
// Hidden element with current directory
@ -387,7 +374,12 @@ if(!empty($_SESSION['_gid'])) {
$group[]= $form->createElement('checkbox','readonly','',get_lang('ReadOnly'));
}
// add group to the form
$form->addGroup($group, 'filename_group', api_get_setting('use_document_title') == 'true' ? get_lang('Title') : get_lang('FileName') ,'&nbsp;&nbsp;&nbsp;', false);
if ($is_certificate_mode)
$form->addGroup($group, 'filename_group', get_lang('CertificateName') ,'&nbsp;&nbsp;&nbsp;', false);
else
$form->addGroup($group, 'filename_group', api_get_setting('use_document_title') == 'true' ? get_lang('Title') : get_lang('FileName') ,'&nbsp;&nbsp;&nbsp;', false);
$form->addRule('filename_group', get_lang('ThisFieldIsRequired'), 'required');
if (api_get_setting('use_document_title') == 'true') {
@ -416,7 +408,11 @@ $form->add_html_editor('content','', false, false, $html_editor_config);
// Comment-field
//$form->addElement('textarea', 'comment', get_lang('Comment'), array ('rows' => 5, 'cols' => 50));
$form->addElement('style_submit_button', 'submit', get_lang('langCreateDoc'), 'class="save"');
if ($is_certificate_mode)
$form->addElement('style_submit_button', 'submit', get_lang('CreateCertificate'), 'class="save"');
else
$form->addElement('style_submit_button', 'submit', get_lang('langCreateDoc'), 'class="save"');
$form->setDefaults($default);
// HTML
@ -503,7 +499,10 @@ if ($form->validate()) {
Database::query("UPDATE $TABLE_DOCUMENT SET".substr($ct, 1)." WHERE id = '$document_id'");
}
$dir= substr($dir,0,-1);
header('Location: document.php?curdirpath='.urlencode($dir));
$selectcat = '';
if (isset($_REQUEST['selectcat']))
$selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']);
header('Location: document.php?curdirpath='.urlencode($dir).$selectcat);
exit ();
} else {
Display :: display_header($nameTools, "Doc");
@ -520,11 +519,23 @@ if ($form->validate()) {
Display :: display_header($nameTools, "Doc");
//api_display_tool_title($nameTools);
// actions
if (isset($_REQUEST['certificate'])) {
$all_information_by_create_certificate=DocumentManager::get_all_info_to_certificate();
$str_info='';
foreach ($all_information_by_create_certificate[0] as $info_value) {
$str_info.=$info_value.'<br/>';
}
$create_certificate=get_lang('CreateCertificateWithTags');
Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
}
echo '<div class="actions">';
// link back to the documents overview
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
if ($is_certificate_mode)
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
else
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
echo '</div>';
$form->display();
Display :: display_footer();
}
?>
?>

@ -345,7 +345,7 @@ function build_edit_icons($curdirpath,$type,$path,$visibility,$id,$is_template,$
$visibility_icon = ($visibility==0)?'invisible':'visible';
$visibility_command = ($visibility==0)?'set_visible':'set_invisible';
$curdirpath = urlencode($curdirpath);
$is_certificate_mode = DocumentManager::is_certificate_mode($path);
$modify_icons = '';
$cur_ses = api_get_session_id();
// if document is read only *or* we're in a session and the document
@ -356,24 +356,66 @@ function build_edit_icons($curdirpath,$type,$path,$visibility,$id,$is_template,$
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif', get_lang('Delete'));
$modify_icons .= '&nbsp;'.Display::return_icon('deplacer_fichier_na.gif', get_lang('Move'));
$modify_icons .= '&nbsp;'.Display::return_icon($visibility_icon.'_na.gif', get_lang('VisibilityCannotBeChanged'));
}
else
{
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
if (strcmp($path,'/audio')===0 or strcmp($path,'/flash')===0 or strcmp($path,'/images')===0 or strcmp($path,'/shared_folder')===0 or strcmp($path,'/video')===0 or strcmp($path,'/chat_files')===0) {
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif',get_lang('ThisFolderCannotBeDeleted'));
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
}
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
}
} else {
if ($is_certificate_mode) {
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'&selectcat='.$gradebook_category.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
} else {
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
}
if (strcmp($path,'/audio')===0 or strcmp($path,'/flash')===0 or strcmp($path,'/images')===0 or strcmp($path,'/shared_folder')===0 or strcmp($path,'/video')===0) {
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif',get_lang('ThisFolderCannotBeDeleted'));
} else {
if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && DocumentManager::get_default_certificate_id(api_get_course_id())==$id) {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'delete_certificate_id='.$id.'&selectcat='.$gradebook_category.' " onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
} else {
if ($is_certificate_mode) {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'&selectcat='.$gradebook_category.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
}
}
}
if ($is_certificate_mode) {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'&selectcat='.$gradebook_category.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'&selectcat='.$gradebook_category.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
}
}
if($type == 'file' && pathinfo($path,PATHINFO_EXTENSION)=='html')
{
if($is_template==0)
{
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;add_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_small.gif" border="0" title="'.get_lang('AddAsTemplate').'" alt="'.get_lang('AddAsTemplate').'" /></a>';
if ((isset($_GET['curdirpath']) && $_GET['curdirpath']<>'/certificates') || !isset($_GET['curdirpath'])) {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;add_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_small.gif" border="0" title="'.get_lang('AddAsTemplate').'" alt="'.get_lang('AddAsTemplate').'" /></a>';
}
if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates') {//allow attach certificate to course
$visibility_icon_certificate='nocertificate';
if (DocumentManager::get_default_certificate_id(api_get_course_id())==$id) {
$visibility_icon_certificate='certificate';
$certificate=get_lang('DefaultCertificate');
$preview=get_lang('PreviewCertificate');
$is_preview=true;
} else {
$is_preview=false;
$certificate=get_lang('NoDefaultCertificate');
}
if (isset($_GET['selectcat'])) {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;selectcat='.Security::remove_XSS($_GET['selectcat']).'&amp;set_certificate='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon_certificate.'.png" border="0" title="'.$certificate.'" alt="" /></a>';
if ($is_preview) {
$modify_icons .= '&nbsp;<a target="_blank" href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;set_preview='.$id.$req_gid.'&amp;'.$sort_params.'" ><img src="../img/search.gif" border="0" title="'.$preview.'" alt="" width="16" height="16"/></a>';
}
}
}
}
else{
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;remove_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_gray_small.gif" border="0" title="'.get_lang('RemoveAsTemplate').'" alt=""'.get_lang('RemoveAsTemplate').'" /></a>';

@ -1,29 +1,6 @@
<?php // $Id: document.php 22201 2009-07-17 19:57:03Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
==============================================================================
* Main script for the documents tool
*
* This script allows the user to manage files and directories on a remote http server.
@ -52,19 +29,15 @@
* @todo eliminate code duplication between
* document/document.php, scormdocument.php
*
* @package dokeos.document
==============================================================================
* @package chamilo.document
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* INIT SECTION */
// name of the language file that needs to be included
$language_file[] = 'document';
$language_file[] = 'slideshow';
$language_file[] = 'gradebook';
require_once "../inc/global.inc.php";
$this_section=SECTION_COURSES;
@ -73,9 +46,12 @@ require_once 'document.inc.php';
require_once '../inc/lib/usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
api_protect_course_script(true);
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js"></script>';
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
for (i=0;i<$(".actions").length;i++) {
@ -90,6 +66,41 @@ if(isset($_GET['id_session'])) {
$_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']);
}
//create directory certificates
$course_id=api_get_course_id();
DocumentManager::create_directory_certificate_in_course($course_id);
//show preview
if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && isset($_GET['set_preview']) && $_GET['set_preview']==strval(intval($_GET['set_preview']))) {
if (isset($_GET['set_preview'])) {
//generate document HTML
$course_id=api_get_course_id();
$content_html=DocumentManager::replace_user_info_into_html($course_id);
$new_content_html=$content_html;
$path_image=api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/gallery';
$new_content_html=str_replace('../images/gallery',$path_image,$new_content_html);
$path_image_in_default_course=api_get_path(WEB_CODE_PATH).'default_course_document';
$new_content_html=str_replace('/main/default_course_document',$path_image_in_default_course,$new_content_html);
$path_image_in_dokeos_main=api_get_path(WEB_IMG_PATH);
$new_content_html=str_replace('/main/img/',$path_image_in_dokeos_main,$new_content_html);
echo '
<style media="print" type="text/css">
#imprimir {
visibility:hidden;
}
</style>';
echo '<a href="javascript:window.print();" style="float:right; padding:4px;" id="imprimir"><img src="../img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
print_r($new_content_html);
exit;
}
}
// Is the document tool visible?
// Check whether the tool is actually visible
$table_course_tool = Database::get_course_table(TABLE_TOOL_LIST, $_course['dbName']);
@ -131,6 +142,9 @@ if(isset($_GET['curdirpath']) && $_GET['curdirpath']!='') {
}
$curdirpathurl = urlencode($curdirpath);
//I'm in the certification module?
$is_certificate_mode = DocumentManager::is_certificate_mode($curdirpath);
$course_dir = $_course['path']."/document";
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path.$course_dir;
@ -313,20 +327,25 @@ $image_files_only='';
Header
-----------------------------------------------------------
*/
$interbreadcrumb[]= array ('url'=>'', 'name'=> get_lang('Document'));
if ($is_certificate_mode) {
$interbreadcrumb[]= array ( 'url' => '../gradebook/index.php', 'name' => get_lang('Gradebook'));
} else {
$interbreadcrumb[]= array ('url'=>'', 'name'=> get_lang('Document'));
}
//------interbreadcrumb for the current directory root path
$dir_array=explode("/",$curdirpath);
$array_len=count($dir_array);
if ($array_len >1)
{
if(empty($_SESSION['_gid']))
if (!$is_certificate_mode) {
if ($array_len >1)
{
$url_dir='document.php?&curdirpath=/';
$interbreadcrumb[]= array ('url'=>$url_dir, 'name'=> get_lang('HomeDirectory'));
if(empty($_SESSION['_gid']))
{
$url_dir='document.php?&curdirpath=/';
$interbreadcrumb[]= array ('url'=>$url_dir, 'name'=> get_lang('HomeDirectory'));
}
}
}
@ -344,7 +363,11 @@ for ($i=0; $i<$array_len;$i++)
}
$url_dir='document.php?&curdirpath='.$dir_acum.$dir_array[$i];
$interbreadcrumb[]= array ('url'=>$url_dir, 'name'=> $dir_array[$i]);
if ($is_certificate_mode) {
$interbreadcrumb[]= array ('url'=>$url_dir.'&selectcat='.Security::remove_XSS($_GET['selectcat']), 'name'=> $dir_array[$i]);
} else {
$interbreadcrumb[]= array ('url'=>$url_dir, 'name'=> $dir_array[$i]);
}
$dir_acum.=$dir_array[$i].'/';
}
@ -467,6 +490,11 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
if(DocumentManager::delete_document($_course,$_GET['delete'],$base_work_dir))
{
if ( isset($_GET['delete_certificate_id']) && $_GET['delete_certificate_id']==strval(intval($_GET['delete_certificate_id'])) ) {
$course_id=api_get_course_id();
$default_certificate_id=$_GET['delete_certificate_id'];
DocumentManager::remove_attach_certificate ($course_id,$default_certificate_id);
}
Display::display_confirmation_message(get_lang('DocDeleted'));
}
else
@ -696,6 +724,16 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
}
} // END is allowed to edit
//attach certificate in the gradebook
if (isset($_GET['curdirpath']) && $_GET['curdirpath']=='/certificates' && isset($_GET['set_certificate']) && $_GET['set_certificate']==strval(intval($_GET['set_certificate']))) {
if (isset($_GET['cidReq'])) {
$course_id=Security::remove_XSS($_GET['cidReq']);//course id
$document_id=Security::remove_XSS($_GET['set_certificate']);//document id
DocumentManager::attach_gradebook_certificate ($course_id,$document_id) ;
Display::display_normal_message(get_lang('IsDefaultCertificate'));
}
}
/*
-----------------------------------------------------------
GET ALL DOCUMENT DATA FOR CURDIRPATH
@ -720,18 +758,24 @@ if($folders===false)
/* GO TO PARENT DIRECTORY */
if ($curdirpath!= '/'&& $curdirpath!=$group_properties['directory'])
{
if ($curdirpath!= '/' && $curdirpath!=$group_properties['directory']&& !$is_certificate_mode) {
?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo urlencode((dirname($curdirpath)=='\\')?'/':dirname($curdirpath)).$req_gid ?>">
<img src="../img/folder_up.gif" border="0" title="<?php echo get_lang('Up'); ?>" alt="" />
<?php echo get_lang('Up'); ?></a>&nbsp;
<?php
<?php
}
if(isset($docs_and_folders) && is_array($docs_and_folders))
{
if ($is_certificate_mode & $curdirpath!= '/certificates') {
?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo urlencode((dirname($curdirpath)=='\\')?'/':dirname($curdirpath)).$req_gid ?>">
<img src="../img/folder_up.gif" border="0" title="<?php echo get_lang('Up'); ?>" alt="" />
<?php echo get_lang('Up'); ?></a>&nbsp;
<?php
}
if(isset($docs_and_folders) && is_array($docs_and_folders)) {
//echo('<pre>');
//print_r($docs_and_folders);
//echo('</pre>');
@ -843,17 +887,29 @@ $column_show=array();
/* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
?>
<!-- create new document or directory -->
<?php if (!is_my_shared_folder($_user['user_id'],$curdirpath))
<?php if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'],$curdirpath))
{?>
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateDoc'); ?>" /></a>
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang("CreateDoc"); ?></a>&nbsp;&nbsp;
<?php }?>
<?php }?>
<!--create new certificate -->
<?php if ($is_certificate_mode) { ?>
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>&certificate=true&<?php echo 'selectcat=' . Security::remove_XSS($_GET['selectcat']); ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateCertificate'); ?>" /></a>
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>&certificate=true&<?php echo 'selectcat=' . Security::remove_XSS($_GET['selectcat']); ?>"><?php echo get_lang("CreateCertificate"); ?></a>&nbsp;&nbsp;
<?php }?>
<!-- file upload link -->
<?php
$upload_name = get_lang('UplUploadDocument');
if ($is_certificate_mode) {
$upload_name = get_lang('UploadCertificate');
}?>
<a href="upload.php?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/submit_file.gif" border="0" title="<?php echo get_lang('UplUploadDocument'); ?>" alt="" /></a>
<a href="upload.php?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang('UplUploadDocument'); ?></a>&nbsp;
<!-- create directory -->
<?php if (!is_my_shared_folder($_user['user_id'],$curdirpath))
<?php if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'],$curdirpath))
{?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><img src="../img/folder_new.gif" border="0" title="<?php echo get_lang('CreateDir'); ?>" alt ="" /></a>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><?php echo get_lang("CreateDir"); ?></a>&nbsp;
@ -863,7 +919,7 @@ $column_show=array();
}
if ($docs_and_folders!=null) {
global $total_size;
if ($total_size!=0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())){ ?>
if (!$is_certificate_mode && $total_size!=0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())){ ?>
<!-- download zipped folder -->
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&action=downloadfolder"><img src="../img/zip_save.gif" border="0" title="<?php echo get_lang("Save"); ?> (ZIP)" alt="" /></a>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&action=downloadfolder"><?php echo get_lang("Save"); ?> (ZIP)</a>&nbsp;
@ -877,7 +933,8 @@ $column_show=array();
echo "<a href=\"slideshow.php?".api_get_cidreq()."&curdirpath=".$curdirpathurl."\"><img src=\"../img/images_gallery.gif\" border=\"0\" title=\"".get_lang('ViewSlideshow')."\"/>&nbsp;". get_lang('ViewSlideshow') . "</a>";
}
echo "</div>";
echo(build_directory_selector($folders,$curdirpath,(isset($group_properties['directory'])?$group_properties['directory']:array()),true));
if (!$is_certificate_mode)
echo(build_directory_selector($folders,$curdirpath,(isset($group_properties['directory'])?$group_properties['directory']:array()),true));
//==============================================================================
@ -963,4 +1020,4 @@ if(!empty($table_footer))
// footer
Display::display_footer();
?>
?>

@ -116,6 +116,7 @@ require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
/*
@ -134,6 +135,11 @@ $file = $_GET['file'];
$doc=basename($file);
//echo('doc: '.$doc.'<br>');
$dir=Security::remove_XSS($_GET['curdirpath']);
//I'm in the certification module?
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
//echo('dir: '.$dir.'<br>');
$file_name = $doc;
//echo('file_name: '.$file_name.'<br>');
@ -222,7 +228,11 @@ if(!empty($_SESSION['_gid']))
$noPHP_SELF=true;
}
$my_cur_dir_path=Security::remove_XSS($_GET['curdirpath']);
$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
if (!$is_certificate_mode)
$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
else
$interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
$is_allowedToEdit = is_allowed_to_edit() || $_SESSION['group_member_with_upload_rights'];
@ -691,7 +701,14 @@ if ($owner_id == $_user['user_id'] || api_is_platform_admin() || $is_allowed_to_
$checked->setChecked(true);
}
}
$form->addElement('style_submit_button','submit',get_lang('SaveDocument'), 'class="save"');
if ($is_certificate_mode)
$form->addElement('style_submit_button', 'submit', get_lang('SaveCertificate'), 'class="save"');
else
$form->addElement('style_submit_button','submit',get_lang('SaveDocument'), 'class="save"');
$defaults['filename'] = $filename;
$defaults['extension'] = $extension;
@ -707,12 +724,25 @@ if ($owner_id == $_user['user_id'] || api_is_platform_admin() || $is_allowed_to_
/*
$form->addElement('html','<div id="frmModel" style="display:block; height:525px; width:240px; position:absolute; top:115px; left:1px;"></div>');
*/
$origin=Security::remove_XSS($_GET['origin']);
if ($origin=='slideshow') {
$slide_id=$_GET['origin_opt'];
nav_to_slideshow($slide_id);
if (isset($_REQUEST['curdirpath']) && $_GET['curdirpath']=='/certificates') {
$all_information_by_create_certificate=DocumentManager::get_all_info_to_certificate();
$str_info='';
foreach ($all_information_by_create_certificate[0] as $info_value) {
$str_info.=$info_value.'<br/>';
}
$create_certificate=get_lang('CreateCertificateWithTags');
Display::display_normal_message($create_certificate.': <br /><br />'.$str_info,false);
}
if ($is_certificate_mode) {
echo '<div class="actions">';
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['curdirpath']).'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
echo '</div>';
} else {
$origin=Security::remove_XSS($_GET['origin']);
if ($origin=='slideshow') {
$slide_id=$_GET['origin_opt'];
nav_to_slideshow($slide_id);
}
}
$form->display();

@ -229,6 +229,14 @@ if($to_group_id!=0 && $path=='/')
$path = $group_properties['directory'];
}
//I'm in the certification module?
$is_certificate_mode = false;
$is_certificate_array = explode('/',$path);
array_shift($is_certificate_array);
if ($is_certificate_array[0]=='certificates') {
$is_certificate_mode = true;
}
//if we want to unzip a file, we need the library
if (isset($_POST['unzip']) && $_POST['unzip'] == 1) {
require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
@ -242,10 +250,20 @@ if($to_group_id !=0) //add group name after for group documents
{
$add_group_to_title = ' ('.$group_properties['name'].')';
}
$nameTools = get_lang('UplUploadDocument').$add_group_to_title;
if (isset($_REQUEST['certificate'])) {
$nameTools = get_lang('UploadCertificate').$add_group_to_title;
} else {
$nameTools = get_lang('UplUploadDocument').$add_group_to_title;
}
// breadcrumbs
$interbreadcrumb[] = array('url' =>'./document.php?curdirpath='.urlencode($path).$req_gid, 'name'=> get_lang('Documents'));
if ($is_certificate_mode)
$interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
else
$interbreadcrumb[] = array('url' =>'./document.php?curdirpath='.urlencode($path).$req_gid, 'name'=> get_lang('Documents'));
// display the header
Display::display_header($nameTools, 'Doc');
@ -504,10 +522,13 @@ if(isset($_GET['createdir']))
echo '<div class="actions">';
// link back to the documents overview
echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
if ($is_certificate_mode)
echo '<a href="document.php?curdirpath='.$path.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview')).get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview').'</a>';
else
echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
// link to create a folder
if(!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path))
if(!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path) && !$is_certificate_mode)
{
echo '<a href="'.api_get_self().'?path='.$path.'&amp;createdir=1">'.Display::return_icon('folder_new.gif', get_lang('CreateDir')).get_lang('CreateDir').'</a>';
}
@ -515,8 +536,8 @@ echo '</div>';
//form to select directory
$folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit);
echo(build_directory_selector($folders,$path,$group_properties['directory']));
if (!$is_certificate_mode)
echo(build_directory_selector($folders,$path,$group_properties['directory']));
?>

@ -29,8 +29,14 @@ $cidReset= true;
$_in_course = false;
//make sure the destination for scripts is index.php instead of gradebook.php
require_once '../inc/global.inc.php';
$_SESSION['gradebook_dest'] = 'gradebook.php';
$this_section = SECTION_MYGRADEBOOK;
if (!empty($_GET['course'])) {
$_SESSION['gradebook_dest'] = 'index.php';
$this_section = SECTION_COURSES;
} else {
$_SESSION['gradebook_dest'] = 'gradebook.php';
$this_section = SECTION_MYGRADEBOOK;
unset($_GET['course']);
}
require_once 'lib/be.inc.php';
require_once 'lib/scoredisplay.class.php';
require_once 'lib/gradebook_functions.inc.php';
@ -41,6 +47,8 @@ require_once 'lib/gradebook_data_generator.class.php';
require_once 'lib/fe/gradebooktable.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/fe/userform.class.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript">
@ -423,18 +431,37 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
'name' => get_lang('Gradebook')
);
Display :: display_header(get_lang('SearchResults'));
} else {
$interbreadcrumb[]= array (
'url' => $_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook')
);
} else {
if ($_SESSION['gradebook_dest'] == 'index.php') {
$gradebook_dest = $_SESSION['gradebook_dest'].'?cidReq='.Security::remove_XSS($_GET['course']).'&amp;';
} else {
$gradebook_dest = $_SESSION['gradebook_dest'];
}
$interbreadcrumb[]= array (
'url' => $gradebook_dest,
'name' => get_lang('Gradebook')
);
if ((isset($_GET['selectcat']) && $_GET['selectcat']>0)) {
$interbreadcrumb[]= array (
if (!empty($_GET['course'])) {
$interbreadcrumb[]= array (
'url' => $gradebook_dest.'selectcat='.Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('Details')
);
} else {
$interbreadcrumb[]= array (
'url' => $_SESSION['gradebook_dest'].'?selectcat=0',
'name' => get_lang('Details')
);
);
}
}
Display :: display_header('');
}
}

@ -0,0 +1,83 @@
<?php
/* For licensing terms, see /license.txt */
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
//extra javascript functions for in html head:
$htmlHeadXtra[] =
"<script language='javascript' type='text/javascript'>
function confirmation()
{
if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." ?\"))
{return true;}
else
{return false;}
}
</script>";
api_block_anonymous_users();
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?', 'name' => get_lang('Gradebook'));
$interbreadcrumb[] = array ('url' => $_SESSION['gradebook_dest'].'?selectcat='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('Details'));
$interbreadcrumb[] = array ('url' => 'gradebook_display_certificate.php?cat_id='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('GradebookListOfStudentsCertificates'));
Display::display_header('');
?>
<?php
if (isset($_GET['user_id']) && $_GET['user_id']==strval(intval($_GET['user_id'])) && isset($_GET['cat_id']) && $_GET['cat_id']==strval(intval($_GET['cat_id']))) {
$info=delete_certificate ($_GET['cat_id'],$_GET['user_id']);
if ($info===true) {
Display::display_confirmation_message(get_lang('CertificateRemoved'));
} else {
Display::display_error_message(get_lang('CertificateNotRemoved'));
}
}
?>
<h3 class="actions" style="border-top:1px #999999 solid;border-bottom:1px #999999 solid;border-left:1px #999999 solid;border-right:1px #999999 solid;"><?php echo get_lang('GradebookListOfStudentsCertificates'); ?></h3>
<table border="0" width="100%" style="border-top:1px #999999 solid;border-bottom:1px #999999 solid;border-left:1px #999999 solid;border-right:1px #999999 solid;">
<?php
$cat_id=isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null;
var_dump(get_list_users_certificates($cat_id));
if (count(get_list_users_certificates($cat_id))==0) {
echo get_lang('NoResultsAvailable');
} else {
foreach (get_list_users_certificates($cat_id) as $index=>$value) {
?>
<tr>
<td width="100%" class="actions" style="border-top:1px #999999 solid;border-bottom:1px #999999 solid;border-left:1px #999999 solid;border-right:1px #999999 solid;"><?php echo get_lang('Student').' : '. $value['firstname'].' '.$value['lastname'] ?>
</td>
</tr>
<tr>
<td>
<table width="100%" >
<?php
$list_certificate=get_list_gradebook_certificates_by_user_id ($value['user_id'],$cat_id);
foreach ($list_certificate as $index_certificate=>$value_certificate) {
?>
<tr >
<td width="50%" style="border-top:1px #999999 solid;border-bottom:1px #999999 solid;border-left:1px #999999 solid;border-right:1px #999999 solid;"><?php echo get_lang('Score').' : '.$value_certificate['score_certificate'] ?></td>
<td width="30%" style="border-top:1px #999999 solid;border-bottom:1px #999999 solid;border-left:1px #999999 solid;border-right:1px #999999 solid;"><?php echo get_lang('Date').' : '.$value_certificate['date_certificate'] ?></td>
<td width="20%" style="border-top:1px #999999 solid;border-bottom:1px #999999 solid;border-left:1px #999999 solid;border-right:1px #999999 solid;"><a onclick="return confirmation();" href="gradebook_display_certificate.php?<?php echo 'user_id='.$value_certificate['user_id'].'&amp;cat_id='.$value_certificate['cat_id'] ?>"><?php echo Display::return_icon('delete.gif',get_lang('Delete')); ?></a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<?php
}
}
?>
</table>
<?php
Display::display_footer();
?>

@ -1,27 +1,5 @@
<?php // $Id: $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos Latinoamerica SAC
Copyright (c) 2006-2008 Dokeos SPRL
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
$language_file= 'gradebook';
// $cidReset : This is the main difference with gradebook.php, here we say,
// basically, that we are inside a course, and many things depend from that
@ -49,6 +27,9 @@ require_once 'lib/fe/gradebooktable.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/fe/userform.class.php';
require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
@ -138,10 +119,7 @@ if ( (isset($_GET['selectcat']) && $_GET['selectcat']>0) && (isset($_SESSION['st
}
}
// --------------------------------------------------------------------------------
// - ACTIONS -
// --------------------------------------------------------------------------------
// ACTIONS
//this is called when there is no data for the course admin
if (isset ($_GET['createallcategories'])) {
block_students();
@ -470,11 +448,9 @@ if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
}
// --------------------------------------------------------------------------------
// - DISPLAY HEADERS AND MESSAGES -
// --------------------------------------------------------------------------------
// DISPLAY HEADERS AND MESSAGES
if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
if (isset ($_GET['studentoverview'])) {
$interbreadcrumb[]= array (
'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
@ -492,6 +468,13 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
'url' => $_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook')
);
if (!isset($_GET['gradebooklist_direction'])) {
$interbreadcrumb[]= array (
'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('Details')
);
}
Display :: display_header('');
} else {
@ -552,9 +535,7 @@ if (isset ($move_form)){
Display :: display_normal_message($move_form->toHtml(),false);
}
// --------------------------------------------------------------------------------
// - LOAD DATA & DISPLAY TABLE -
// --------------------------------------------------------------------------------
// LOAD DATA & DISPLAY TABLE
$is_platform_admin= api_is_platform_admin();
$is_course_admin= api_is_allowed_to_create_course();
@ -633,6 +614,7 @@ if (isset ($_GET['studentoverview'])) {
$scoretotal= $cattotal[0]->calc_score($user_id);
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
global $charset;
//prepare all necessary variables:
$organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName');
@ -642,7 +624,79 @@ if (isset ($_GET['studentoverview'])) {
$certif_text = str_replace("\\n","\n",$certif_text);
$date = date('d/m/Y',time());
$pdf= new Cezpdf('a4','landscape');
$path_info= UserManager::get_user_picture_path_by_id($user_id,'system',true);
$path_directory_user_certificate=$path_info['dir'].'certificate/';
if (!is_dir($path_info['dir'])) {
mkdir($path_info['dir'],0777);
}
if (!is_dir($path_directory_user_certificate)) {
mkdir($path_directory_user_certificate,0777);
}
if (is_dir($path_directory_user_certificate)) {
$user_id=api_get_user_id();
$cat_id=$_GET['cat_id'];
$name=md5($user_id.$cat_id);
//generate document HTML
$course_id=api_get_course_id();
$content_html=DocumentManager::replace_user_info_into_html($course_id);
$new_content=explode('</head>',$content_html);
if ($new_content[0]!='') {
$new_content_html=$new_content[1];
$my_path_certificate=$path_directory_user_certificate.$name.'.html';
$path_image=api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/gallery';
$new_content_html=str_replace('../images/gallery',$path_image,$new_content_html);
$path_image_in_default_course=api_get_path(WEB_CODE_PATH).'default_course_document';
$new_content_html=str_replace('/main/default_course_document',$path_image_in_default_course,$new_content_html);
$path_image_in_dokeos_main=api_get_path(WEB_IMG_PATH);
$new_content_html=str_replace('/main/img/',$path_image_in_dokeos_main,$new_content_html);
//add print header
$print= '
<style media="print" type="text/css">
#imprimir {
visibility:hidden;
}
</style>';
$print ='<a href="javascript:window.print();" style="float:right; padding:4px;" id="imprimir"><img src="'.api_get_path(WEB_CODE_PATH).'img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
//add header
$new_content_html=$new_content[0].$print.'</head>'.$new_content_html;
if ($cat_id=strval(intval($cat_id))) {
if (UserManager::is_user_certified($cat_id,$user_id)===true){
header('Content-Type: text/html; charset='. $charset);
echo $new_content_html;
exit;
} else {
$my_new_content_html=$new_content_html;
$my_new_content_html=mb_convert_encoding($my_new_content_html,'UTF-8',$charset);
file_put_contents($my_path_certificate,$my_new_content_html);
header('Content-Type: text/html; charset='. $charset);
echo $new_content_html;
}
$path_certificate='/'.$name.'.html';
update_user_info_about_certificate($cat_id,$user_id,$path_certificate);
exit;
}
} else {
Display :: display_reduced_header();
Display :: display_warning_message(get_lang('NoCertificateAvailable'));
}
}
/*$pdf= new Cezpdf('a4','landscape');
$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
$pdf->ezSetMargins(30, 30, 50, 50);
//line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom)
@ -659,7 +713,7 @@ if (isset ($_GET['studentoverview'])) {
$pdf->ezText($organization_name,22,array('justification'=>'left'));
$pdf->ezSetY(580);
$pdf->ezText($portal_name,22,array('justification'=>'right'));
$pdf->ezStream();
$pdf->ezStream();*/
}
exit;
} else { //in any other case (no search, no pdf), print the available gradebooks
@ -808,8 +862,8 @@ if ($category != '0') {
//show certificate
$certificate_min_score=$cats[0]->get_certificate_min_score();
if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$cats[0]->get_course_code().'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" />'.get_lang('Certificates').'</a>&nbsp;'.get_lang('langTotal').': '.$scoretotal_display;
if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$cats[0]->get_id().'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" />'.get_lang('Certificates').'</a>&nbsp;'.get_lang('langTotal').': '.$scoretotal_display;
echo '<div class="actions" align="right">';
echo $certificates;

@ -1,27 +1,5 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos Latinoamerica SAC
Copyright (c) 2006 Dokeos SPRL
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
class DisplayGradebook
{
/**
@ -327,6 +305,9 @@ class DisplayGradebook
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats_access.gif', get_lang('FlatView')).' ' . get_lang('FlatView') . '</a>';
if (/*($is_course_admin && $message_resource===false && $status_user==1) ||*/ api_is_platform_admin()) {
$header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() .'">'.Display::return_icon('acces_tool.gif', get_lang('ScoreEdit')).' ' . get_lang('ScoreEdit') . '</a>';
$header .= '<td style="vertical-align: top;"><a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('acces_tool.gif', get_lang('AttachCertificate')).' ' . get_lang('AttachCertificate') . '</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?'.$my_api_cidreq.'&amp;cat_id='.(int)$_GET['selectcat'].'">'.Display::return_icon('acces_tool.gif', get_lang('Certificate')).' ' . get_lang('GradebookSeeListOfStudentsCertificates') . '</a>';
}
}
}

@ -1,27 +1,5 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2009 Dokeos Latinoamerica SAC
Copyright (c) 2006 Dokeos SPRL
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see license.txt */
require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
require_once (dirname(__FILE__).'/../be.inc.php');
set_time_limit(0);

@ -1,25 +1,5 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see license.txt */
require_once (dirname(__FILE__).'/../../../inc/global.inc.php');
require_once (dirname(__FILE__).'/../be.inc.php');
@ -28,7 +8,7 @@ require_once (dirname(__FILE__).'/../be.inc.php');
* Table to display categories, evaluations and links
* @author Stijn Konings
* @author Bert Steppé (refactored, optimised)
* @author Isaac flores (refactored, optimised)
*
*/
class GradebookTable extends SortableTable
{
@ -140,12 +120,13 @@ class GradebookTable extends SortableTable
//error_log(print_r($data_array,true));
// generate the data to display
$sortable_data = array();
$weight_total_links = 0;
foreach ($data_array as $data) {
$row = array ();
$item = $data[0];
$id = $item->get_id();
if (empty($_GET['selectcat'])) {
$certificate_min_score = $this->build_certificate_min_score($item);
$certificate_min_score = $this->build_certificate_min_score($item);
}
//if the item is invisible, wrap it in a span with class invisible
$invisibility_span_open = (api_is_allowed_to_create_course() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
@ -155,12 +136,12 @@ class GradebookTable extends SortableTable
$row[] = $this->build_id_column ($item);
}
//$row[] = $this->build_id_column ($item);
$row[] = $this->build_type_column ($item);
$row[] = $invisibility_span_open . $this->build_name_link ($item) . $invisibility_span_close;
$row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
if (($status_user==1 || is_null($status_user)) && api_is_allowed_to_create_course()) {
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
$weight_total_links += intval($data[3]);
} else {
if (empty($_GET['selectcat'])) {
@ -190,34 +171,123 @@ class GradebookTable extends SortableTable
}
}
$row[] = $invisibility_span_open . str_replace(' ','&nbsp;',$data[4]) . $invisibility_span_close;
//admins get an edit column
if (($status_user==1 || is_null($status_user)) && api_is_allowed_to_create_course() && ($_SESSION['studentview']<>'studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false'))) {
$cat=new Category();
$show_message=$cat->show_message_resource_delete($item->get_course_code());
$show_message=$cat->show_message_resource_delete($item->get_course_code());
if ($show_message===false) {
$row[] = $this->build_edit_column ($item);
}
} else {
//students get the results and certificates columns
//students get the results and certificates columns
if (count($this->evals_links)>0 && $status_user!=1 ) {
$value_data=isset($data[5]) ? $data[5] : null;
if (!is_null($value_data)) {
$row[] = $value_data;
}
}
if (empty($_GET['selectcat'])) {
//@todo Fix this harcode value
//by default we load the first category 1
if (empty($_GET['selectcat']) || $_GET['selectcat'] == 1) {
if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$id.'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display;
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$id.'" target="_blank">
<img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display;
//register gradebook certificate
$current_user_id=api_get_user_id();
$date_certificate=date('Y-m-d H:i:s',time());
register_user_info_about_certificate($id,$current_user_id,$my_score_in_gradebook,$date_certificate);
} else {
$certificates = '-';
}
//show certificate date
$get_date=get_certificate_date_by_user_id($id,$current_user_id);
if ($get_date=='' || is_null($get_date)) {
$row[4]='-';
} else {
$row[4] = date('d/m/y H:i:s',strtotime($get_date));
}
$row[] = $certificates;
}
}
$sortable_data[] = $row;
}
// warning messages
if (api_is_allowed_to_edit()) {
if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $_GET['view'] <> 'presence') {
$id_cat = intval($_GET['selectcat']);
$category = Category :: load($id_cat);
$weight_category = intval($this->build_weight($category[0]));
$course_code = $this->build_course_code($category[0]);
if ($weight_total_links > $weight_category) {
$warning_message = get_lang('TotalWeightMustNotBeMoreThan').'&nbsp;'.$weight_category;
Display::display_warning_message($warning_message,false);
}
$content_html=DocumentManager::replace_user_info_into_html($course_code);
$new_content=explode('</head>',$content_html);
if (empty($new_content[0])) {
$warning_message = get_lang('ThereIsNotACertificateAvailableByDefault');
Display::display_warning_message($warning_message);
}
}
if (empty($_GET['selectcat'])) {
$categories = Category :: load();
$weight_categories = $certificate_min_scores = $course_codes = array();
foreach ($categories as $category) {
$course_code_category = $this->build_course_code($category);
if (!empty($course_code)) {
if ($course_code_category == $course_code) {
$weight_categories[] = intval($this->build_weight($category));
$certificate_min_scores[] = intval($this->build_certificate_min_score($category));
$course_codes[] = $course_code;
break;
}
} else {
$weight_categories[] = intval($this->build_weight($category));
$certificate_min_scores[] = intval($this->build_certificate_min_score($category));
$course_codes[] = $course_code_category;
}
}
if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) {
$warning_message = '';
for ($x = 0; $x<count($weight_categories);$x++) {
$weight_category = intval($weight_categories[$x]);
$certificate_min_score = intval($certificate_min_scores[$x]);
$course_code = $course_codes[$x];
if (empty($certificate_min_score) || ($certificate_min_score > $weight_category)) {
$warning_message .= $course_code .'&nbsp;-&nbsp;'.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').'&nbsp;'.$weight_category.'<br />';
}
}
if (!empty($warning_message)) {
Display::display_warning_message($warning_message,false);
}
}
}
}
return $sortable_data;
@ -229,6 +299,14 @@ private function build_certificate_min_score ($item) {
return $item->get_certificate_min_score();
}
private function build_weight ($item) {
return $item->get_weight();
}
private function build_course_code ($item) {
return $item->get_course_code();
}
private function build_id_column ($item) {
switch ($item->get_item_type()) {
// category
@ -252,7 +330,8 @@ private function build_id_column ($item) {
switch ($item->get_item_type()) {
// category
case 'C' :
$prms_uri='?selectcat=' . $item->get_id();
$prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.Security::remove_XSS($_GET['view']);
if (isset($_GET['isStudentView'])) {
if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) {
$prms_uri=$prms_uri.'&amp;isStudentView='.Security::remove_XSS($_GET['isStudentView']);
@ -276,12 +355,30 @@ private function build_id_column ($item) {
$show_message=$cat->show_message_resource_delete($course_id);
// course/platform admin can go to the view_results page
if (api_is_allowed_to_create_course() && $show_message===false) {
return '&nbsp;'
. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>&nbsp;['.get_lang('Evaluation').']';
if (api_is_allowed_to_create_course() && $show_message===false) {
if ($item->get_type() == 'presence')
{
return '&nbsp;'
. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>';
/*return '&nbsp;'
. '<a href="gradebook_add_result.php?selectcat'.Security::remove_XSS($_GET['selectcat']).'&amp;selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>';
*/
}
else
{
return '&nbsp;'
. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>&nbsp;['.get_lang('Evaluation').']';
}
} elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) {
// students can go to the statistics page (if custom display enabled)
return '&nbsp;'

@ -1,24 +1,5 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
/*
* These are functions used in gradebook
*
@ -413,4 +394,133 @@ function parse_xml_data($file) {
xml_parse($parser, file_get_contents($file));
xml_parser_free($parser);
return $users;
}
}
/**
* update user info about certificate
* @param int The category id
* @param int The user id
* @param string the path name of the certificate
* @return void()
*/
function update_user_info_about_certificate ($cat_id,$user_id,$path_certificate) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
if (!UserManager::is_user_certified($cat_id,$user_id)) {
$sql='UPDATE '.$table_certificate.' SET path_certificate="'.$path_certificate.'"
WHERE cat_id="'.$cat_id.'" AND user_id="'.$user_id.'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
}
}
/**
* register user info about certificate
* @param int The category id
* @param int The user id
* @param float The score obtained for certified
* @param Datetime The date when you obtained the certificate
* @return void()
*/
function register_user_info_about_certificate ($cat_id,$user_id,$score_certificate,
$date_certificate) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql_exist='SELECT COUNT(*) as count FROM '.$table_certificate.' gc
WHERE gc.cat_id="'.$cat_id.'" AND user_id="'.$user_id.'" ';
$rs_exist=Database::query($sql_exist,__FILE__,__LINE__);
$row=Database::fetch_array($rs_exist);
if ($row['count']==0) {
$sql='INSERT INTO '.$table_certificate.'
(cat_id,user_id,score_certificate,date_certificate)
VALUES("'.$cat_id.'","'.$user_id.'","'.$score_certificate.'","'.$date_certificate.'")';
$rs=Database::query($sql,__FILE__,__LINE__);
}
}
/**
* Get date of user certificate
* @param int The category id
* @param int The user id
* @return Datetime The date when you obtained the certificate
*/
function get_certificate_date_by_user_id ($cat_id,$user_id) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql_get_date='SELECT date_certificate FROM '.$table_certificate.' WHERE cat_id="'.$cat_id.'" AND user_id="'.$user_id.'"';
$rs_get_date=Database::query($sql_get_date,__FILE__,__LINE__);
$row_get_date=Database::fetch_array($rs_get_date,'ASSOC');
return $row_get_date['date_certificate'];
}
/**
* Get list of users certificates
* @param int The category id
* @return array
*/
function get_list_users_certificates ($cat_id=null) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
echo $sql='SELECT DISTINCT u.user_id,u.lastname,u.firstname,u.username FROM '.$table_user.' u INNER JOIN '.$table_certificate.' gc
ON u.user_id=gc.user_id ';
if (!is_null($cat_id) && $cat_id>0) {
$sql.=' WHERE cat_id='.Database::escape_string($cat_id);
}
$sql.=' ORDER BY u.firstname';
$rs=Database::query($sql,__FILE__,__LINE__);
$list_users=array();
while ($row=Database::fetch_array($rs)) {
$list_users[]=$row;
}
return $list_users;
}
/**
*Get list of certificates by user id
*@param int The user id
*@param int The category id
*@retun array
*/
function get_list_gradebook_certificates_by_user_id ($user_id,$cat_id=null) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql='SELECT gc.score_certificate,gc.date_certificate,gc.path_certificate,gc.cat_id,gc.user_id FROM '.$table_certificate.' gc
WHERE gc.user_id="'.Database::escape_string($user_id).'" ';
if (!is_null($cat_id) && $cat_id>0) {
$sql.=' AND cat_id='.Database::escape_string($cat_id);
}
$rs=Database::query($sql,__FILE__,__LINE__);
$list_certificate=array();
while ($row=Database::fetch_array($rs)) {
$list_certificate[]=$row;
}
return $list_certificate;
}
/**
*Allow remove certificate
*@param int The category id
*@param int The user id
*@return boolean
*/
function delete_certificate ($cat_id,$user_id) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql_verified='SELECT count(*) AS count,path_certificate as path,user_id FROM '.$table_certificate.' gc WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" GROUP BY user_id,cat_id';
$rs_verified=Database::query($sql_verified,__FILE__,__LINE__);
$path=Database::result($rs_verified,0,'path');
$user_id=Database::result($rs_verified,0,'user_id');
if (!is_null($path) || $path!='' || strlen($path)) {
$path_info= UserManager::get_user_picture_path_by_id($user_id,'system',true);
$path_directory_user_certificate=$path_info['dir'].'certificate'.$path;
if (is_file($path_directory_user_certificate)) {
unlink($path_directory_user_certificate);
if (is_file($path_directory_user_certificate)===false) {
$delete_db=true;
} else {
$delete_db=false;
}
}
if (Database::result($rs_verified,0,'count')==1 && $delete_db===true) {
$sql_delete='DELETE FROM '.$table_certificate.' WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" ';
$rs_delete=Database::query($sql_delete,__FILE__,__LINE__);
return true;
} else {
return false;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

@ -50,7 +50,7 @@ define('TABLE_MAIN_GRADEBOOK_RESULT', 'gradebook_result');
define('TABLE_MAIN_GRADEBOOK_RESULT_LOG', 'gradebook_result_log');
define('TABLE_MAIN_GRADEBOOK_LINK', 'gradebook_link');
define('TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY','gradebook_score_display');
define('TABLE_MAIN_GRADEBOOK_CERTIFICATE', 'gradebook_certificate');
//Profiling
define('TABLE_MAIN_USER_FIELD', 'user_field');

@ -967,7 +967,209 @@ class DocumentManager {
return $_SESSION ['is_allowed_in_course'] || api_is_platform_admin();
}
/**
* Allow attach certificate to course
* @param string The course id
* @param int The document id
* @return void()
*/
function attach_gradebook_certificate ($course_id,$document_id) {
$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id=api_get_session_id();
if ($session_id==0 || is_null($session_id)) {
$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
} elseif ($session_id>0) {
$sql_session='AND session_id='.Database::escape_string($session_id);
} else {
$sql_session='';
}
$sql='UPDATE '.$tbl_category.' SET document_id="'.Database::escape_string($document_id).'"
WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session;
$rs=Database::query($sql,__FILE__,__LINE__);
}
/**
* get the document id of default certificate
* @param string The course id
* @return int The default certificate id
*/
function get_default_certificate_id ($course_id) {
$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id=api_get_session_id();
if ($session_id==0 || is_null($session_id)) {
$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
} elseif ($session_id>0) {
$sql_session='AND session_id='.Database::escape_string($session_id);
} else {
$sql_session='';
}
$sql='SELECT document_id FROM '.$tbl_category.'
WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session;
$rs=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($rs);
return $row['document_id'];
}
/**
* allow replace user info in file html
* @param string The course id
* @return string The html content of the certificate
*/
function replace_user_info_into_html($course_id) {
global $_course;
$course_info = api_get_course_info($course_id);
$tbl_document=Database::get_course_table(TABLE_DOCUMENT,$course_info['dbName']);
$document_id=self::get_default_certificate_id($course_id);
$sql='SELECT path FROM '.$tbl_document.' WHERE id="'.Database::escape_string($document_id).'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
$new_content = '';
if (Database::num_rows($rs)) {
$row=Database::fetch_array($rs);
$filepath = api_get_path('SYS_COURSE_PATH').$course_info['path'].'/document'.$row['path'];
if (is_file($filepath)) {
$my_content_html=file_get_contents($filepath);
}
$all_user_info=self::get_all_info_to_certificate();
$info_to_be_replaced_in_content_html=$all_user_info[0];
$info_to_replace_in_content_html=$all_user_info[1];
$new_content=str_replace($info_to_be_replaced_in_content_html,$info_to_replace_in_content_html,$my_content_html);
}
return $new_content;
}
/**
* return all content to replace and all content to be replace
*/
function get_all_info_to_certificate () {
global $charset,$dateFormatLong;
$info_list = array();
$user_id = api_get_user_id();
$course_id = api_get_course_id();
//info portal
$organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName');
//info extra user data
$extra_user_info_data=UserManager::get_extra_user_data($user_id,false,false);
//info student
$user_info=api_get_user_info($user_id);
$first_name=($user_info['firstName']);
$last_name=($user_info['lastName']);
$official_code=($user_info['official_code']);
//info teacher
$info_teacher_id=UserManager::get_user_id_of_course_admin_or_session_admin($course_id);
$teacher_info=api_get_user_info($info_teacher_id);
$teacher_first_name=($teacher_info['firstName']);
$teacher_last_name=($teacher_info['lastName']);
// info gradebook certificate
$info_grade_certificate = UserManager::get_info_gradebook_certificate($course_id,$user_id);
$date_certificate = $info_grade_certificate['date_certificate'];
$date_long_certificate = '';
if (!empty($date_certificate)) {
$date_long_certificate = api_ucfirst(format_locale_date($dateFormatLong,convert_mysql_date($date_certificate)));
}
//replace content
$info_to_replace_in_content_html=array($first_name,$last_name,$organization_name,$portal_name,$teacher_first_name,$teacher_last_name, $official_code, $date_long_certificate);
$info_to_be_replaced_in_content_html=array('((user_firstname))','((user_lastname))','((gradebook_institution))',
'((gradebook_sitename))','((teacher_firstname))','((teacher_lastname))','((official_code))','((date_certificate))');
foreach ($extra_user_info_data as $key_extra=>$value_extra) {
$info_to_be_replaced_in_content_html[]='(('.strtolower($key_extra).'))';
$info_to_replace_in_content_html[]=$value_extra;
}
$info_list[]=$info_to_be_replaced_in_content_html;
$info_list[]=$info_to_replace_in_content_html;
return $info_list;
}
/**
* Remove default certificate
* @param string The course id
* @param int The document id of the default certificate
* @return void()
*/
function remove_attach_certificate ($course_id,$default_certificate_id) {
$default_certificate=self::get_default_certificate_id($course_id);
if ((int)$default_certificate==(int)$default_certificate_id) {
$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id=api_get_session_id();
if ($session_id==0 || is_null($session_id)) {
$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
} elseif ($session_id>0) {
$sql_session='AND session_id='.Database::escape_string($session_id);
} else {
$sql_session='';
}
$sql='UPDATE '.$tbl_category.' SET document_id=null
WHERE course_code="'.Database::escape_string($course_id).'" AND document_id="'.$default_certificate_id.'" '.$sql_session;
$rs=Database::query($sql,__FILE__,__LINE__);
}
}
/**
* Create directory certificate
* @param string The course id
* @return void()
*/
function create_directory_certificate_in_course ($course_id) {
global $_course;
global $_user;
$to_group_id=0;
$to_user_id=null;
$course_dir = $_course['path']."/document/";
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir=$sys_course_path.$course_dir;
$base_work_dir_test=$base_work_dir.'certificates';
$dir_name='/certificates';
$post_dir_name='certificates';
$visibility_command='invisible';
if (!is_dir($base_work_dir_test)) {
$created_dir = create_unexisting_directory($_course,$_user['user_id'],$to_group_id,$to_user_id,$base_work_dir,$dir_name,$post_dir_name);
$update_id=DocumentManager::get_document_id_of_directory_certificate();
api_item_property_update($_course, TOOL_DOCUMENT, $update_id, $visibility_command, $_user['user_id']);
}
}
/**
* Get the document id of the directory certificate
* @param string The course id
* @return int The document id of the directory certificate
*/
function get_document_id_of_directory_certificate () {
global $_course;
$tbl_document=Database::get_course_table(TABLE_DOCUMENT);
$sql='SELECT id FROM '.$tbl_document.' WHERE path="/certificates" ';
$rs=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($rs);
return $row['id'];
}
/**
* Check if a directory given is for certificate
* @param string path of directory
* @return bool true if is a certificate or false otherwise
*/
function is_certificate_mode($dir) {
//I'm in the certification module?
$is_certificate_mode = false;
$is_certificate_array = explode('/',$dir);
array_shift($is_certificate_array);
if ($is_certificate_array[0]=='certificates') {
$is_certificate_mode = true;
}
return $is_certificate_mode;
}
/**
* Gets the list of included resources as a list of absolute or relative paths from a html file or string html
* This allows for a better SCORM export or replace urls inside content html from copy course

@ -9,17 +9,17 @@
*/
// Constants for user extra field types.
define('USER_FIELD_TYPE_TEXT', 1);
define('USER_FIELD_TYPE_TEXTAREA', 2);
define('USER_FIELD_TYPE_RADIO',3);
define('USER_FIELD_TYPE_SELECT',4);
define('USER_FIELD_TYPE_SELECT_MULTIPLE', 5);
define('USER_FIELD_TYPE_DATE', 6);
define('USER_FIELD_TYPE_DATETIME', 7);
define('USER_FIELD_TYPE_DOUBLE_SELECT', 8);
define('USER_FIELD_TYPE_DIVIDER', 9);
define('USER_FIELD_TYPE_TAG', 10);
define('USER_FIELD_TYPE_TIMEZONE', 11);
define('USER_FIELD_TYPE_TEXT', 1);
define('USER_FIELD_TYPE_TEXTAREA', 2);
define('USER_FIELD_TYPE_RADIO', 3);
define('USER_FIELD_TYPE_SELECT', 4);
define('USER_FIELD_TYPE_SELECT_MULTIPLE', 5);
define('USER_FIELD_TYPE_DATE', 6);
define('USER_FIELD_TYPE_DATETIME', 7);
define('USER_FIELD_TYPE_DOUBLE_SELECT', 8);
define('USER_FIELD_TYPE_DIVIDER', 9);
define('USER_FIELD_TYPE_TAG', 10);
define('USER_FIELD_TYPE_TIMEZONE', 11);
//User image sizes
define('USER_IMAGE_SIZE_ORIGINAL', 1);
@ -2995,6 +2995,104 @@ class UserManager
return $result;
}
/**
* get user id of teacher or session administrator
* @param string The course id
* @return int The user id
*/
function get_user_id_of_course_admin_or_session_admin ($course_id) {
$session=api_get_session_id();
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
if ($session==0 || is_null($session)) {
$sql='SELECT u.user_id FROM '.$table_user.' u
INNER JOIN '.$table_course_user.' ru ON ru.user_id=u.user_id
WHERE ru.status=1 AND ru.course_code="'.Database::escape_string($course_id).'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
$num_rows=Database::num_rows($rs);
if ($num_rows==1) {
$row=Database::fetch_array($rs);
return $row['user_id'];
} else {
$my_num_rows=$num_rows;
$my_user_id=Database::result($rs,$my_num_rows-1,'user_id');
return $my_user_id;
}
} elseif ($session>0) {
$sql='SELECT u.user_id FROM '.$table_user.' u
INNER JOIN '.$table_session_user.' sru
ON sru.id_coach=u.user_id WHERE sru.course_code="'.Database::escape_string($course_id).'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($rs);
return $row['user_id'];
}
}
/**
* Determines if a user is certified
* @param int The category id of gradebook
* @param int The user id
* @return boolean
*/
function is_user_certified($cat_id,$user_id) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql='SELECT path_certificate FROM '.$table_certificate.' WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($rs);
if ($row['path_certificate']=='' || is_null($row['path_certificate'])) {
return false;
} else {
return true;
}
}
/**
* Gets the info about a gradebook certificate for a user by course
* @param string The course code
* @param int The user id
* @return array if there is not information return false
*/
function get_info_gradebook_certificate($course_code,$user_id) {
$tbl_grade_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$tbl_grade_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql='SELECT * FROM '.$tbl_grade_certificate.' WHERE cat_id= (SELECT id FROM '.$tbl_grade_category.' WHERE course_code = "'.Database::escape_string($course_code).'" ) AND user_id="'.Database::escape_string($user_id).'" ';
$rs = Database::query($sql,__FILE__,__LINE__);
$row= Database::fetch_array($rs);
if (Database::num_rows($rs) > 0)
return $row;
else
return false;
}
/**
* Gets the user path of user certificated
* @param int The user id
* @return array containing path_certificate and cat_id
*/
function get_user_path_certificate($user_id) {
$my_certificate = array();
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$table_gradebook_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id = api_get_session_id();
$user_id = intval($user_id);
if ($session_id==0 || is_null($session_id)) {
$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
} elseif ($session_id>0) {
$sql_session='AND session_id='.Database::escape_string($session_id);
} else {
$sql_session='';
}
$sql= "SELECT tc.path_certificate,tc.cat_id,tgc.course_code,tgc.name FROM $table_certificate tc, $table_gradebook_category tgc
WHERE tgc.id = tc.cat_id AND tc.user_id='$user_id' ORDER BY tc.date_certificate DESC limit 5";
$rs=Database::query($sql,__FILE__,__LINE__);
while ($row=Database::fetch_array($rs)) {
$my_certificate[]=$row;
}
return $my_certificate;
}
}

Loading…
Cancel
Save