Certificates added to Chamilo see CT#751 (requires testing)

skala
Julio Montoya 15 years ago
parent f09249a979
commit 52f94f0001
  1. 15
      main/gradebook/gradebook_add_user.php
  2. 45
      main/gradebook/gradebook_display_certificate.php
  3. 25
      main/gradebook/gradebook_edit_all.php
  4. 2
      main/gradebook/gradebook_flatview.php
  5. 12
      main/gradebook/index.php
  6. 5
      main/gradebook/lib/be/category.class.php
  7. 24
      main/gradebook/lib/be/evallink.class.php
  8. 24
      main/gradebook/lib/be/evaluation.class.php
  9. 2
      main/gradebook/lib/be/linkfactory.class.php
  10. 2
      main/gradebook/lib/fe/dataform.class.php
  11. 2
      main/gradebook/lib/fe/flatviewtable.class.php
  12. 48
      main/gradebook/lib/fe/gradebooktable.class.php
  13. 24
      main/gradebook/lib/flatview_data_generator.class.php
  14. 33
      main/gradebook/lib/gradebook_functions.inc.php
  15. 1
      main/gradebook/lib/scoredisplay.class.php

@ -1,13 +1,16 @@
<?php //$Id: gradebook_add_user.php 21153 2009-06-01 01:51:43Z yannoo $
/* For licensing terms, see /dokeos_license.txt */
/* For licensing terms, see /license.txt */
$language_file = 'gradebook';
require_once '../inc/global.inc.php';
$this_section = SECTION_MYGRADEBOOK;
require_once ('lib/be.inc.php');
require_once ('lib/fe/displaygradebook.php');
require_once ('lib/gradebook_functions.inc.php');
require_once ('lib/fe/evalform.class.php');
require_once ('lib/scoredisplay.class.php');
require_once 'lib/be.inc.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users();
block_students();

@ -31,43 +31,46 @@ 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'));
if($_GET['action'] == 'delete') {
$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>
<h3 class="actions" ><?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;">
<table class="data_table" border="0" width="100%" >
<?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) {
$cat_id=isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null;
$certificate_list = get_list_users_certificates($cat_id);
if (count($certificate_list)==0) {
echo get_lang('NoResultsAvailable');
} else {
foreach (get_list_users_certificates($cat_id) as $index=>$value) {
foreach ($certificate_list 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 width="100%" class="actions"><?php echo get_lang('Student').' : '. $value['firstname'].' '.$value['lastname'] ?>
</td>
</tr>
<tr>
<td>
<table width="100%" >
<table class="data_table" width="100%" >
<?php
$list_certificate=get_list_gradebook_certificates_by_user_id ($value['user_id'],$cat_id);
$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
?>
<tr >
<td width="50%"><?php echo get_lang('Score').' : '.$value_certificate['score_certificate'] ?></td>
<td width="30%"><?php echo get_lang('Date').' : '.$value_certificate['date_certificate'] ?></td>
<td width="20%"><a onclick="return confirmation();" href="gradebook_display_certificate.php?action=delete&<?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>

@ -1,29 +1,9 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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".
/* For licensing terms, see /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
==============================================================================
*/
$language_file= 'gradebook';
$cidReset= true;
require_once ('../inc/global.inc.php');
require_once '../inc/global.inc.php';
$this_section = SECTION_MYGRADEBOOK;
require_once ('lib/be.inc.php');
require_once ('lib/scoredisplay.class.php');
@ -154,7 +134,6 @@ $result = Database::query($sql);
$tempsql = Database::query('SELECT * FROM '.get_table_type_course($row['type'],$row['course_code']).' WHERE '.$table_evaluated[$row['type']][2].' = '.$row['ref_id']);
$resource_name = Database ::fetch_array($tempsql);
//var_dump($resource_name['lp_type']);
if (isset($resource_name['lp_type'])) {
$resource_name=$resource_name[2];
} else {

@ -226,7 +226,7 @@ if (isset ($_GET['exportpdf'])) {
$pdf =& new Cezpdf('a4',$format); //format is 'portrait' or 'landscape'
$clear_printable_data=array();
$clear_send_printable_data=array();
//var_dump(count($printable_data[1]));
for ($i=0;$i<count($printable_data[1]);$i++) {
for ($k=0;$k<count($printable_data[1][$i]);$k++) {
$clear_printable_data[]=strip_tags($printable_data[1][$i][$k]);

@ -859,16 +859,14 @@ if ($category != '0') {
$cattotal = Category :: load($category_id);
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal)? round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)': '-');
$my_score_in_gradebook = round($scoretotal[0],2);
//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_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;
echo '</div>';
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.Security::remove_XSS($_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;
echo '</div>';
}
} //end hack

@ -110,6 +110,11 @@ class Category implements GradebookItem
public function set_visible ($visible) {
$this->visible = $visible;
}
public function get_type()
{
return 'category';
}
// CRUD FUNCTIONS

@ -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 to be used as basis for links referring to Evaluation objects.
* @author Bert Steppé

@ -62,6 +62,10 @@ class Evaluation implements GradebookItem
public function get_max() {
return $this->eval_max;
}
public function get_type() {
return $this->type;
}
public function is_visible() {
return $this->visible;
@ -106,8 +110,12 @@ class Evaluation implements GradebookItem
public function set_visible ($visible) {
$this->visible = $visible;
}
public function set_type ($type) {
$this->type = $type;
}
// CRUD FUNCTIONS
/**
@ -121,7 +129,7 @@ class Evaluation implements GradebookItem
public function load ($id = null, $user_id = null, $course_code = null, $category_id = null, $visible = null)
{
$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql='SELECT id,name,description,user_id,course_code,category_id,date,weight,max,visible FROM '.$tbl_grade_evaluations;
$sql='SELECT id,name,description,user_id,course_code,category_id,date,weight,max,visible,type FROM '.$tbl_grade_evaluations;
$paramcount = 0;
if (isset ($id)) {
$sql.= ' WHERE id = '.$id;
@ -172,6 +180,8 @@ class Evaluation implements GradebookItem
$eval->set_weight($data['weight']);
$eval->set_max($data['max']);
$eval->set_visible($data['visible']);
$eval->set_type($data['type']);
$alleval[]=$eval;
}
return $alleval;
@ -199,6 +209,8 @@ class Evaluation implements GradebookItem
if (isset($this->eval_date)) {
$sql .= ',date';
}
$sql .= ',type';
$sql .= ") VALUES ('".Database::escape_string(Security::remove_XSS($this->get_name()))."'"
.','.$this->get_user_id()
.','.$this->get_weight()
@ -216,6 +228,12 @@ class Evaluation implements GradebookItem
//if (isset($this->eval_date)) {
$sql .= ','.strtotime(date('Y-m-d H:i:s',time()));
//}
if (empty($this->type))
{
$this->type = 'evaluation';
}
$sql .= ',\''.$this->type.'\'';
$sql .= ")";
Database::query($sql);
$this->set_id(Database::insert_id());

@ -6,7 +6,7 @@
// - add include
// - change create() and get_all_types()
// Please do not change existing values, they are used in the database !
define('LINK_EXERCISE',1);
define('LINK_EXERCISE', 1);
define('LINK_DROPBOX',2);
define('LINK_STUDENTPUBLICATION',3);
define('LINK_LEARNPATH',4);

@ -71,7 +71,7 @@ class DataForm extends FormValidator {
$this->addElement('static','label','',get_lang('ChooseOrientation'));
$this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait');
$this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape');
$this->addElement('submit', 'submit', get_lang('Ok'));
$this->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
$this->setDefaults(array (
'orientation' => 'portrait'
));

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see license.txt */
/* 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);

@ -117,15 +117,15 @@ class GradebookTable extends SortableTable
$course_code=api_get_course_id();
$status_user=api_get_status_of_user_in_course ($user_id,$course_code);
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
//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'])) {
if (empty($_GET['selectcat']) ) {
$certificate_min_score = $this->build_certificate_min_score($item);
}
//if the item is invisible, wrap it in a span with class invisible
@ -166,6 +166,7 @@ class GradebookTable extends SortableTable
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal)? round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)': '-');
$row[] = $item_value;
} else {
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
}
@ -179,23 +180,19 @@ class GradebookTable extends SortableTable
if ($show_message===false) {
$row[] = $this->build_edit_column ($item);
}
} else {
//students get the results and certificates columns
} else {
//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;
}
}
//@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) {
//variables load in index.php
global $my_score_in_gradebook, $certificate_min_score, $item_value, $certificate_min_score;
if (empty($_GET['selectcat'])) {
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.'" target="_blank">
<img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display;
@ -207,15 +204,22 @@ class GradebookTable extends SortableTable
} 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;
//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;
} elseif ($_GET['selectcat'] == 1) {
if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
//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);
}
}
}
$sortable_data[] = $row;

@ -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 to select, sort and transform object data into array data,
* used for the teacher's flat view

@ -420,17 +420,15 @@ function parse_xml_data($file) {
* @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) {
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.'" ';
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.'")';
echo $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__);
}
@ -457,7 +455,7 @@ function parse_xml_data($file) {
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
$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);
@ -472,7 +470,7 @@ function parse_xml_data($file) {
}
/**
*Get list of certificates by user id
*Gets the certificate list by user id
*@param int The user id
*@param int The category id
*@retun array
@ -480,11 +478,11 @@ function parse_xml_data($file) {
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).'" ';
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__);
$rs = Database::query($sql,__FILE__,__LINE__);
$list_certificate=array();
while ($row=Database::fetch_array($rs)) {
$list_certificate[]=$row;
@ -492,10 +490,10 @@ function parse_xml_data($file) {
return $list_certificate;
}
/**
*Allow remove certificate
*@param int The category id
*@param int The user id
*@return boolean
* Deletes a certificate
* @param int The category id
* @param int The user id
* @return boolean
*/
function delete_certificate ($cat_id,$user_id) {
@ -508,7 +506,7 @@ function parse_xml_data($file) {
$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);
@unlink($path_directory_user_certificate);
if (is_file($path_directory_user_certificate)===false) {
$delete_db=true;
} else {
@ -522,5 +520,10 @@ function parse_xml_data($file) {
} else {
return false;
}
} else {
//path is not generate delete only the DB record
$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;
}
}

@ -339,7 +339,6 @@ class ScoreDisplay
private function get_custom_displays() {
$tbl_display = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY);
$sql = 'SELECT * FROM '.$tbl_display.' ORDER BY score';
//echo $sql;
$result = Database::query($sql);
return Database::store_result($result);
}

Loading…
Cancel
Save