see #5034 allow to disable gradebook

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

@ -222,7 +222,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
if ($key == 'search_field' or $key == 'submit_fixed_in_bottom') { continue; }
$key = Database::escape_string($key);
$sql = "UPDATE $table_settings_current SET selected_value = 'false' WHERE variable = '".$key."' AND access_url = ".intval($url_id)." AND type IN ('checkbox', 'radio') ";
$res = Database::query($sql);
$res = Database::query($sql);
}
/*foreach($settings_to_avoid as $key => $value) {

@ -2081,7 +2081,11 @@ function show_add_post_form($action = '', $id = '', $form_values = '') {
// Thread qualify
$form->applyFilter('numeric_calification', 'html_filter');
$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\';}"');
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');
$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());
if (!empty($link_info)) {
$defaults['thread_qualify_gradebook'] = true;
$defaults['category_id'] = $link_info['category_id'];
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());
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,32 +503,37 @@ 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]);
$qualification_input[] = FormValidator :: createElement('text', 'qualification');
$form_folder -> addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric'));
if ((int)$row['weight'] == 0) {
$form_folder -> addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
$form_folder -> addElement('html', '<div id=\'option3\' style="display:none">');
if(Gradebook::is_active()){
$qualification_input[] = FormValidator :: createElement('text', 'qualification');
$form_folder -> addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric'));
if ((int)$row['weight'] == 0) {
//Loading gradebook select
load_gradebook_select_in_tool($form_folder);
$form_folder -> addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
$weight_input2[] = FormValidator :: createElement('text', 'weight');
$form_folder -> addGroup($weight_input2, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
$form_folder -> addElement('html', '<div id=\'option3\' style="display:none">');
$form_folder -> addElement('html', '</div>');
} else {
$weight_input[] = FormValidator :: createElement('text', 'weight');
//Loading gradebook select
load_gradebook_select_in_tool($form_folder);
$form_folder -> addGroup($weight_input, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
}
$link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $id2);
//Loading gradebook select
load_gradebook_select_in_tool($form_folder);
$weight_input2[] = FormValidator :: createElement('text', 'weight');
$form_folder -> addGroup($weight_input2, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
$form_folder -> addElement('html', '</div>');
} else {
$weight_input[] = FormValidator :: createElement('text', 'weight');
//Loading gradebook select
load_gradebook_select_in_tool($form_folder);
$form_folder -> addGroup($weight_input, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
}
$link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $id2);
$defaults['category_id'] = $link_info['category_id'];
$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;">');
//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';}"));
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