Merge branch '7525' of https://github.com/AngelFQC/chamilo-lms into AngelFQC-7525

1.10.x
Yannick Warnier 10 years ago
commit 2cb5fc023f
  1. 1
      main/gradebook/gradebook_add_cat.php
  2. 1
      main/gradebook/gradebook_edit_cat.php
  3. 36
      main/gradebook/lib/be/category.class.php
  4. 15
      main/gradebook/lib/fe/catform.class.php
  5. 17
      main/gradebook/lib/fe/displaygradebook.php
  6. 1
      main/install/db_main.sql
  7. 2
      main/install/migrate-db-1.9.0-1.10.0-pre.sql

@ -128,6 +128,7 @@ if ($form->validate()) {
$cat->set_user_id($values['hid_user_id']);
$cat->set_parent_id($values['hid_parent_id']);
$cat->set_weight($values['weight']);
$cat->setGenerateCertificates($values['generate_certificates']);
if (empty ($values['visible'])) {
$visible = 0;

@ -106,6 +106,7 @@ if ($form->validate()) {
$cat->set_user_id($values['hid_user_id']);
$cat->set_parent_id($values['hid_parent_id']);
$cat->set_weight($values['weight']);
$cat->setGenerateCertificates($values['generate_certificates']);
if ($values['hid_parent_id'] == 0 ) {
$cat->set_certificate_min_score($values['certif_min_score']);

@ -20,6 +20,7 @@ class Category implements GradebookItem
private $session_id;
private $skills = array();
private $grade_model_id;
private $generateCertificates;
public function __construct()
{
@ -182,6 +183,24 @@ class Category implements GradebookItem
return $skill_select;
}
/**
* Set the generate_certificates value
* @param int $generateCertificates
*/
public function setGenerateCertificates($generateCertificates)
{
$this->generateCertificates = $generateCertificates;
}
/**
* Get the generate_certificates value
* @return int
*/
public function getGenerateCetificates()
{
return $this->generateCertificates;
}
/**
* @param int $id
* @param int $session_id
@ -346,6 +365,7 @@ class Category implements GradebookItem
$cat->set_parent_id(null);
$cat->set_weight(0);
$cat->set_visible(1);
$cat->setGenerateCertificates(false);
return $cat;
}
@ -371,6 +391,7 @@ class Category implements GradebookItem
$cat->set_certificate_min_score($data['certif_min_score']);
$cat->set_grade_model_id($data['grade_model_id']);
$cat->set_locked($data['locked']);
$cat->setGenerateCertificates($data['generate_certificates']);
$allcat[] = $cat;
}
@ -409,6 +430,10 @@ class Category implements GradebookItem
$sql .= ', certif_min_score ';
}
if (isset($this->generateCertificates)) {
$sql .= ', generate_certificates ';
}
/*
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visible = 1;
@ -442,6 +467,9 @@ class Category implements GradebookItem
if (isset($this->certificate_min_score) && !empty($this->certificate_min_score)) {
$sql .= ', '.intval($this->get_certificate_min_score());
}
if (isset($this->generateCertificates)) {
$sql .= ', ' . intval($this->generateCertificates);
}
$sql .= ')';
Database::query($sql);
$id = Database::insert_id();
@ -524,6 +552,7 @@ class Category implements GradebookItem
}
$sql .= ', weight = "'.Database::escape_string($this->get_weight())
.'", visible = '.intval($this->is_visible())
. ', generate_certificates = ' . intval($this->generateCertificates)
.' WHERE id = '.intval($this->id);
Database::query($sql);
@ -639,7 +668,7 @@ class Category implements GradebookItem
return null;
} else {
$tbl_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql='SELECT name,description,user_id,course_code,parent_id,weight,visible,certif_min_score,session_id FROM '.$tbl_category.' c WHERE c.id='.intval($selectcat);
$sql='SELECT name,description,user_id,course_code,parent_id,weight,visible,certif_min_score,session_id, generate_certificates FROM '.$tbl_category.' c WHERE c.id='.intval($selectcat);
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
@ -1588,6 +1617,11 @@ class Category implements GradebookItem
);
/** @var Category $category */
$category = $cats_course[0];
if (!$category->getGenerateCetificates()) {
return false;
}
$alleval_course = $category->get_evaluations($user_id, true);
$alllink_course = $category->get_links($user_id, true);
$evals_links = array_merge($alleval_course, $alllink_course);

@ -176,6 +176,7 @@ class CatForm extends FormValidator
'weight' => $this->category_object->get_weight(),
'visible' => $this->category_object->is_visible(),
'certif_min_score' => $this->category_object->get_certificate_min_score(),
'generate_certificates' => $this->category_object->getGenerateCetificates()
)
);
$this->addElement('hidden', 'hid_id', $this->category_object->get_id());
@ -347,6 +348,20 @@ class CatForm extends FormValidator
$this->freeze('grade_model_id');
}
}
$generateCertificatesParams = array();
if ($this->category_object->getGenerateCetificates()) {
$generateCertificatesParams['checked'] = 'checked';
}
$this->addElement(
'checkbox',
'generate_certificates',
null,
get_lang('GenerateCertificates'),
$generateCertificatesParams
);
}
if ($this->form_type == self :: TYPE_ADD) {

@ -555,8 +555,21 @@ class DisplayGradebook
if (!$message_resource) {
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</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('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';
if ($my_category['generate_certificates'] == 1) {
$header .= "<td style=\"vertical-align: top;\">"
. Display::url(
Display::return_icon(
'certificate_list.png',
get_lang('GradebookSeeListOfStudentsCertificates'),
'',
ICON_SIZE_MEDIUM
),
"gradebook_display_certificate.php?$my_api_cidreq&amp;cat_id=" . intval($_GET['selectcat'])
)
. "</td>";
}
// Right icons
$modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' .
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';

@ -1370,6 +1370,7 @@ CREATE TABLE IF NOT EXISTS gradebook_category (
document_id int unsigned DEFAULT NULL,
locked int NOT NULL DEFAULT 0,
default_lowest_eval_exclude TINYINT default null,
generate_certificates TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
DROP TABLE IF EXISTS gradebook_evaluation;

@ -34,6 +34,8 @@ CREATE TABLE session_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
ALTER TABLE skill ADD COLUMN criteria text DEFAULT '';
ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0;
-- Do not move this query
UPDATE settings_current SET selected_value = '1.10.0.7' WHERE variable = 'chamilo_database_version';

Loading…
Cancel
Save