Minor adding gradebook_locking_enabled validations (not finished yet) see BT#4080

skala
Julio Montoya 13 years ago
parent 1255905b5a
commit e5f9680ac8
  1. 15
      main/gradebook/gradebook_add_cat.php
  2. 5
      main/gradebook/lib/gradebook_functions.inc.php
  3. 22
      main/inc/lib/events.lib.inc.php
  4. 68
      main/inc/lib/main_api.lib.php

@ -97,21 +97,6 @@ if ($_in_course) {
}
$catadd->set_course_code(api_get_course_id());
/*
$models = api_get_settings_options('grading_model');
$course_grading_model_id = api_get_course_setting('course_grading_model');
$grading_model = '';
if (!empty($course_grading_model_id)) {
foreach($models as $option) {
if (intval($option['id']) == $course_grading_model_id) {
$grading_model = $option['value'];
}
}
}
$grading_contents = api_grading_model_functions($grading_model, 'to_array');
*/
$form = new CatForm(CatForm :: TYPE_ADD, $catadd, 'add_cat_form', null, api_get_self() . '?selectcat='.$get_select_cat);

@ -209,6 +209,11 @@ function build_edit_icons_cat($cat, $selectcat) {
if (api_is_allowed_to_edit(null, true)) {
//Locking button
if (api_get_setting('gradebook_locking_enabled') == 'true') {
//$modify_icons .= '&nbsp;<a class="view_children" data-cat-id="'.$cat->get_id().'" href="javascript:void(0);">'.Display::return_icon('lock.png', get_lang('Lock'),'',ICON_SIZE_SMALL).'</a>';
}
//PDF
$modify_icons .= '&nbsp;<a href="gradebook_flat_view.php?export_pdf=category&selectcat=' . $cat->get_id() . '" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_SMALL).'</a>';

@ -549,6 +549,22 @@ function exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $
return $result = Database::query($sql);
}
/**
*
* @param type $status LOG_GRADEBOOK_LOCKED - LOG_GRADEBOOK_UNLOCKED
* @param type $course_id
* @param type $session_id
* @param type $item_id
* @param type $tool_id
* @return boolean
*/
function event_change_gradebook_lock_status($status, $course_code, $gradebook_id) {
if (api_get_setting('gradebook_locking_enabled') == 'true') {
event_system($status, LOG_GRADEBOOK_ID, $gradebook_id, null, null, $course_code);
}
return false;
}
/**
* @author Yannick Warnier <yannick.warnier@dokeos.com>
* @desc Record information for common (or admin) events (in the track_e_default table)
@ -580,9 +596,7 @@ function event_system($event_type, $event_value_type, $event_value, $datetime =
}
}
$event_value = Database::escape_string($event_value);
$user_id = Database::escape_string($user_id);
$event_value = Database::escape_string($event_value);
$course_info = api_get_course_info($course_code);
if (!empty($course_info)) {
@ -605,6 +619,8 @@ function event_system($event_type, $event_value_type, $event_value, $datetime =
$user_id = api_get_user_id();
}
$user_id = intval($user_id);
$sql = "INSERT INTO $TABLETRACK_DEFAULT
(default_user_id,
default_cours_code,

@ -155,6 +155,11 @@ define('LOG_CONFIGURATION_SETTINGS_VARIABLE', 'settings_variable');
define('LOG_CAREER_ID', 'career_id');
define('LOG_PROMOTION_ID', 'promotion_id');
define('LOG_GRADEBOOK_LOCKED', 'gradebook_locked');
define('LOG_GRADEBOOK_UNLOCKED', 'gradebook_unlocked');
define('LOG_GRADEBOOK_ID', 'gradebook_id');
// Specification for usernames:
// 1. ASCII-letters, digits, "." (dot), "_" (underscore) are acceptable, 40 characters maximum length.
// 2. Empty username is formally valid, but it is reserved for the anonymous user.
@ -4235,7 +4240,7 @@ function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $u
$sql .= " ORDER BY 1,2 ASC";
}
$result = Database::store_result(Database::query($sql));
return $result;
return $result;
}
/**
@ -5637,7 +5642,6 @@ function api_get_jquery_libraries_js($libraries) {
return $js;
}
/**
* Returns the course's URL
*
@ -5647,7 +5651,6 @@ function api_get_jquery_libraries_js($libraries) {
* @return mixed The URL of the course or null if something does not work
* @author Julio Montoya <gugli100@gmail.com>
*/
function api_get_course_url($course_code = null, $session_id = null) {
$session_url = '';
if (empty($course_code)) {
@ -5707,7 +5710,6 @@ function api_get_home_path() {
return $home;
}
function api_get_course_table_condition($and = true) {
$course_id = api_get_course_int_id();
$condition = '';
@ -5718,48 +5720,16 @@ function api_get_course_table_condition($and = true) {
return $condition;
}
function api_grading_model_functions($grading_model, $action = 'to_array') {
$return = null;
if (empty($grading_model)) {
return null;
}
$elements = array('A','B','C','D','E','F','G','H','I','J','K','L','M');
if (in_array($action, array('to_array', 'decorate'))) {
$parts = explode('/', $grading_model);
$return['denominator'] = $parts[1];
$sums = explode('+', $parts[0]);
$j = 0;
foreach($sums as $item) {
$item = explode('*', $item);
$per = 0;
if (!empty($return['denominator'])) {
$per = $item[0]/$return['denominator']*100;
}
$return['items'][] =array( 'letter' => $elements[$j],
'value' => $item[0],
'percentage'=> $per.'%');
$j++;
}
if ($action == 'decorate') {
$return_value = '';
$items = $return['items'];
$j = 1;
foreach ($items as $item) {
$letter = $item['letter'];
$value = $item['value'];
$sum = '+';
if (count($items) == $j){
$sum = '';
}
$return_value = $return_value.' '.$value.'*'.$letter." $sum ";
$j++;
}
$return = ' ('.$return_value.') / '.$return['denominator'];
}
}
return $return;
}
/**
*
* @param int Course id
* @param int tool id: TOOL_QUIZ, TOOL_FORUM, TOOL_STUDENTPUBLICATION, TOOL_LEARNPATH
* @param int the item id (tool id, exercise id, lp id)
*
*/
function api_course_item_is_blocked_by_gradebook($course_id, $tool_id, $item_id) {
if (api_get_setting('gradebook_locking_enabled') == 'true') {
//$course_id
}
return false;
}
Loading…
Cancel
Save