see #5034 allow to disable gradebook

skala
Laurent Opprecht 13 years ago
parent 91a850bdda
commit 27dcba7d9c
  1. 15
      main/forum/forumfunction.inc.php
  2. 31
      main/inc/lib/gradebook.lib.php
  3. 5
      main/work/work.lib.php
  4. 8
      main/work/work.php

@ -2081,7 +2081,11 @@ function show_add_post_form($action = '', $id = '', $form_values = '') {
// Thread qualify
$form->applyFilter('numeric_calification', 'html_filter');
if(Gradebook::is_active()){
$form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript:if(this.checked==true){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
}else{
$form->addElement('hidden', 'thread_qualify_gradebook', false);
}
$form -> addElement('html', '<div id="options_field" style="display:none">');
$form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'),'Style="width:40px"');
@ -2508,12 +2512,20 @@ function show_edit_post_form($current_post, $current_thread, $current_forum, $fo
if (!isset($_GET['edit'])) {
$form->addElement('label', '<strong>'.get_lang('AlterQualifyThread').'</strong>');
$form->applyFilter('numeric_calification', 'html_filter');
if(Gradebook::is_active()){
$form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id());
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id());
if (!empty($link_info)) {
$defaults['thread_qualify_gradebook'] = true;
$defaults['category_id'] = $link_info['category_id'];
}else{
$defaults['thread_qualify_gradebook'] = false;
$defaults['category_id'] = '';
}
}else{
$form->addElement('hidden', 'thread_qualify_gradebook', false);
$defaults['thread_qualify_gradebook'] = false;
}
if (!empty($defaults['thread_qualify_gradebook'])) {
@ -2661,6 +2673,7 @@ function store_edit_post($values) {
$link_id = $link_info['id'];
$thread_qualify_gradebook = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null;
if ($thread_qualify_gradebook != 1) {
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_id);

@ -10,6 +10,37 @@
*/
class Gradebook extends Model {
/**
* Returns true if the gradebook is active and visible in a course, false
* otherwise.
*
* @param int $c_id Course integer id, defaults to the current course
* @return boolean
*/
public static function is_active($c_id = null)
{
$name = 'gradebook';
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * from $table WHERE variable='course_hide_tools' AND subkey='$name'";
$setting = ResultSet::create($sql)->first();
$setting = $setting ? $setting : array();
$inactive = isset($setting['selected_value']) && $setting['selected_value'] == 'true';
if($inactive){
return false;
}
$c_id = $c_id ? $c_id : api_get_course_int_id();
$table = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT * from $table WHERE c_id = $c_id and name='$name'";
$item = ResultSet::create($sql)->first();
if(empty($item)){
return true;
}
return $item['visibility'] == '1';
}
var $columns = array('id', 'name', 'description', 'course_code', 'parent_id', 'grade_model_id', 'session_id', 'weight', 'user_id');
public function __construct() {

@ -503,6 +503,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
list($d_hour, $d_minute) = explode(':', $parts[1]);
if(Gradebook::is_active()){
$qualification_input[] = FormValidator :: createElement('text', 'qualification');
$form_folder -> addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric'));
@ -529,6 +530,10 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $id2);
$defaults['category_id'] = $link_info['category_id'];
}else{
$defaults['category_id'] = '';
}
if ($homework['expires_on'] != '0000-00-00 00:00:00') {
$homework['expires_on'] = api_get_local_time($homework['expires_on']);

@ -766,10 +766,16 @@ switch ($action) {
$form->addElement('html', '<div id="options" style="display: none;">');
if(Gradebook::is_active()){
//QualificationOfAssignment
$form->addElement('text', 'qualification_value', get_lang('QualificationNumeric'));
$form->addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), array('id' =>'make_calification_id', 'onclick' => "javascript: if(this.checked){document.getElementById('option1').style.display='block';}else{document.getElementById('option1').style.display='none';}"));
}else{
//QualificationOfAssignment
$form->addElement('hidden', 'qualification_value',0);
$form->addElement('hidden', 'make_calification', false);
}
$form->addElement('html', '<div id="option1" style="display: none;">');

Loading…
Cancel
Save