Use api_float_val

pull/2487/head
jmontoyaa 9 years ago
parent 8cfbfedbbc
commit 378c57dffb
  1. 2
      main/attendance/attendance_edit.php
  2. 8
      main/forum/forumfunction.inc.php
  3. 13
      main/gradebook/gradebook_add_link.php
  4. 13
      main/gradebook/gradebook_edit_link.php
  5. 6
      main/gradebook/index.php
  6. 6
      main/gradebook/lib/GradebookUtils.php
  7. 4
      main/gradebook/lib/be/forumthreadlink.class.php
  8. 7
      main/inc/lib/attendance.lib.php

@ -19,7 +19,7 @@ if (!isset($error)) {
$token = Security::get_token(); $token = Security::get_token();
} }
$attendance_weight = floatval($attendance_weight); $attendance_weight = api_float_val($attendance_weight);
// display form // display form
$form = new FormValidator( $form = new FormValidator(
'attendance_edit', 'attendance_edit',

@ -2412,8 +2412,8 @@ function updateThread($values)
'thread_title' => $values['thread_title'], 'thread_title' => $values['thread_title'],
'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null, 'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null,
'thread_title_qualify' => $values['calification_notebook_title'], 'thread_title_qualify' => $values['calification_notebook_title'],
'thread_qualify_max' => $values['numeric_calification'], 'thread_qualify_max' => api_float_val($values['numeric_calification']),
'thread_weight' => $values['weight_calification'], 'thread_weight' => api_float_val($values['weight_calification']),
'thread_peer_qualify' => $values['thread_peer_qualify'], 'thread_peer_qualify' => $values['thread_peer_qualify'],
]; ];
$where = ['c_id = ? AND thread_id = ?' => [$courseId, $values['thread_id']]]; $where = ['c_id = ? AND thread_id = ?' => [$courseId, $values['thread_id']]];
@ -3796,8 +3796,8 @@ function store_edit_post($forumInfo, $values)
'thread_title' => $values['post_title'], 'thread_title' => $values['post_title'],
'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null, 'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null,
'thread_title_qualify' => $values['calification_notebook_title'], 'thread_title_qualify' => $values['calification_notebook_title'],
'thread_qualify_max' => $values['numeric_calification'], 'thread_qualify_max' => api_float_val($values['numeric_calification']),
'thread_weight' => $values['weight_calification'], 'thread_weight' => api_float_val($values['weight_calification']),
'thread_peer_qualify' => $values['thread_peer_qualify'], 'thread_peer_qualify' => $values['thread_peer_qualify'],
]; ];
$where = ['c_id = ? AND thread_id = ?' => [$course_id, $values['thread_id']]]; $where = ['c_id = ? AND thread_id = ?' => [$course_id, $values['thread_id']]];

@ -102,19 +102,24 @@ if (isset($typeSelected) && $typeSelected != '0') {
(isset($addvalues['select_link']) && $addvalues['select_link'] <> "") (isset($addvalues['select_link']) && $addvalues['select_link'] <> "")
) { ) {
$sql1 = 'SELECT thread_title from '.$tbl_forum_thread.' $sql1 = 'SELECT thread_title from '.$tbl_forum_thread.'
WHERE c_id = '.$course_info['real_id'].' AND thread_id='.$addvalues['select_link']; WHERE
c_id = '.$course_info['real_id'].' AND
thread_id = '.$addvalues['select_link'];
$res1 = Database::query($sql1); $res1 = Database::query($sql1);
$rowtit = Database::fetch_row($res1); $rowtit = Database::fetch_row($res1);
$course_id = api_get_course_id(); $course_id = api_get_course_id();
$sql_l = 'SELECT count(*) FROM '.$tbl_link.' $sql_l = 'SELECT count(*) FROM '.$tbl_link.'
WHERE ref_id='.$addvalues['select_link'].' and course_code="'.$course_id.'" and type=5;'; WHERE
ref_id='.$addvalues['select_link'].' AND
course_code="'.$course_id.'" AND
type = 5;';
$res_l = Database::query($sql_l); $res_l = Database::query($sql_l);
$row = Database::fetch_row($res_l); $row = Database::fetch_row($res_l);
if ($row[0] == 0) { if ($row[0] == 0) {
$link->add(); $link->add();
$sql = 'UPDATE '.$tbl_forum_thread.' SET $sql = 'UPDATE '.$tbl_forum_thread.' SET
thread_qualify_max= "'.$addvalues['weight'].'", thread_qualify_max= "'.api_float_val($addvalues['weight']).'",
thread_weight= "'.$addvalues['weight'].'", thread_weight= "'.api_float_val($addvalues['weight']).'",
thread_title_qualify = "'.$rowtit[0].'" thread_title_qualify = "'.$rowtit[0].'"
WHERE WHERE
thread_id='.$addvalues['select_link'].' AND thread_id='.$addvalues['select_link'].' AND

@ -76,12 +76,15 @@ if ($form->validate()) {
} }
//Update weight into forum thread //Update weight into forum thread
$sql_t = 'UPDATE '.$tbl_forum_thread.' SET thread_weight='.$final_weight.' $sql = 'UPDATE '.$tbl_forum_thread.' SET
WHERE c_id = '.$course_id.' AND thread_id=( thread_weight = '.api_float_val($final_weight).'
WHERE
c_id = '.$course_id.' AND
thread_id = (
SELECT ref_id FROM '.$tbl_grade_links.' SELECT ref_id FROM '.$tbl_grade_links.'
WHERE id='.intval($_GET['editlink']).' and type=5 WHERE id='.intval($_GET['editlink']).' AND type = 5
) '; )';
Database::query($sql_t); Database::query($sql);
//Update weight into student publication(work) //Update weight into student publication(work)
$em $em

@ -388,9 +388,9 @@ if (isset($_GET['deletelink'])) {
if ($link[0] != null) { if ($link[0] != null) {
// Clean forum qualify // Clean forum qualify
$sql = 'UPDATE '.$tbl_forum_thread.' SET $sql = 'UPDATE '.$tbl_forum_thread.' SET
thread_qualify_max=0, thread_qualify_max = 0,
thread_weight=0, thread_weight = 0,
thread_title_qualify="" thread_title_qualify = ""
WHERE c_id = '.$course_id.' AND thread_id = ( WHERE c_id = '.$course_id.' AND thread_id = (
SELECT ref_id FROM '.$tbl_grade_links.' SELECT ref_id FROM '.$tbl_grade_links.'
WHERE id='.$get_delete_link.' AND type = '.LINK_FORUM_THREAD.' WHERE id='.$get_delete_link.' AND type = '.LINK_FORUM_THREAD.'

@ -1174,12 +1174,14 @@ class GradebookUtils
$rs_attendance = Database::query($sql); $rs_attendance = Database::query($sql);
if (Database::num_rows($rs_attendance) > 0) { if (Database::num_rows($rs_attendance) > 0) {
$row_attendance = Database::fetch_array($rs_attendance); $row_attendance = Database::fetch_array($rs_attendance);
$sql = 'UPDATE '.$tbl_attendance.' SET attendance_weight ='.$weight.' $sql = 'UPDATE '.$tbl_attendance.' SET
attendance_weight ='.api_float_val($weight).'
WHERE c_id = '.$course_id.' AND id = '.intval($row_attendance['ref_id']); WHERE c_id = '.$course_id.' AND id = '.intval($row_attendance['ref_id']);
Database::query($sql); Database::query($sql);
} }
// Update weight into forum thread // Update weight into forum thread
$sql = 'UPDATE '.$tbl_forum_thread.' SET thread_weight='.$weight.' $sql = 'UPDATE '.$tbl_forum_thread.' SET
thread_weight = '.api_float_val($weight).'
WHERE WHERE
c_id = '.$course_id.' AND c_id = '.$course_id.' AND
thread_id = ( thread_id = (

@ -357,12 +357,12 @@ class ForumThreadLink extends AbstractLink
function save_linked_data() function save_linked_data()
{ {
$weight = api_float_val($this->get_weight()); $weight = $this->get_weight();
$ref_id = $this->get_ref_id(); $ref_id = $this->get_ref_id();
if (!empty($ref_id)) { if (!empty($ref_id)) {
$sql = 'UPDATE '.$this->get_forum_thread_table().' SET $sql = 'UPDATE '.$this->get_forum_thread_table().' SET
thread_weight='.$weight.' thread_weight='.api_float_val($weight).'
WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
Database::query($sql); Database::query($sql);
} }

@ -290,7 +290,7 @@ class Attendance
$course_id = $_course['real_id']; $course_id = $_course['real_id'];
$title_gradebook= $this->attendance_qualify_title; $title_gradebook= $this->attendance_qualify_title;
$value_calification = 0; $value_calification = 0;
$weight_calification = floatval($this->attendance_weight); $weight_calification = api_float_val($this->attendance_weight);
$params = [ $params = [
'c_id' => $course_id, 'c_id' => $course_id,
@ -369,10 +369,9 @@ class Attendance
$course_id = $_course['real_id']; $course_id = $_course['real_id'];
$title_gradebook = $this->attendance_qualify_title; $title_gradebook = $this->attendance_qualify_title;
$value_calification = 0; $value_calification = 0;
$weight_calification = floatval($this->attendance_weight); $weight_calification = api_float_val($this->attendance_weight);
if (!empty($attendance_id)) { if (!empty($attendance_id)) {
$params = [ $params = [
'name' => $this->name, 'name' => $this->name,
'description' => $this->description, 'description' => $this->description,
@ -906,7 +905,7 @@ class Attendance
$count_done_calendar = self::get_done_attendance_calendar($attendance_id); $count_done_calendar = self::get_done_attendance_calendar($attendance_id);
$sql = "UPDATE $tbl_attendance SET $sql = "UPDATE $tbl_attendance SET
attendance_qualify_max = '$count_done_calendar' attendance_qualify_max = '$count_done_calendar'
WHERE c_id = $course_id AND id = '$attendance_id'"; WHERE c_id = $course_id AND id = '$attendance_id'";
Database::query($sql); Database::query($sql);
} }

Loading…
Cancel
Save