Minor - format

pull/2487/head
jmontoyaa 9 years ago
parent 6edc892129
commit ffbf8c0af1
  1. 74
      main/gradebook/lib/be/category.class.php
  2. 6
      main/gradebook/lib/be/studentpublicationlink.class.php
  3. 4
      main/inc/lib/pear/HTML/QuickForm/Rule/Regex.php
  4. 8
      main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php
  5. 4
      main/inc/lib/pear/HTML/QuickForm/input.php
  6. 2
      main/inc/lib/pear/HTML/QuickForm/text.php

@ -330,8 +330,8 @@ class Category implements GradebookItem
return $cats; return $cats;
} }
$courseCode = api_get_course_info_by_id(api_get_course_int_id()); $courseInfo = api_get_course_info_by_id(api_get_course_int_id());
$courseCode = $courseCode['code']; $courseCode = $courseInfo['code'];
$session_id = intval($session_id); $session_id = intval($session_id);
if (!empty($session_id)) { if (!empty($session_id)) {
@ -357,13 +357,13 @@ class Category implements GradebookItem
/** /**
* Retrieve categories and return them as an array of Category objects * Retrieve categories and return them as an array of Category objects
* @param int $id category id * @param int $id category id
* @param int $user_id (category owner) * @param int $user_id (category owner)
* @param string $course_code * @param string $course_code
* @param int $parent_id parent category * @param int $parent_id parent category
* @param bool $visible * @param bool $visible
* @param int $session_id (in case we are in a session) * @param int $session_id (in case we are in a session)
* @param bool $order_by Whether to show all "session" * @param bool $order_by Whether to show all "session"
* categories (true) or hide them (false) in case there is no session id * categories (true) or hide them (false) in case there is no session id
*/ */
public static function load( public static function load(
@ -582,7 +582,6 @@ class Category implements GradebookItem
$this->set_id($id); $this->set_id($id);
if (!empty($id)) { if (!empty($id)) {
$parent_id = $this->get_parent_id(); $parent_id = $this->get_parent_id();
$grade_model_id = $this->get_grade_model_id(); $grade_model_id = $this->get_grade_model_id();
if ($parent_id == 0) { if ($parent_id == 0) {
@ -614,7 +613,10 @@ class Category implements GradebookItem
} }
$gradebook= new Gradebook(); $gradebook= new Gradebook();
$gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false)); $gradebook->update_skills_to_gradebook(
$this->id,
$this->get_skills(false)
);
return $id; return $id;
} }
@ -657,7 +659,6 @@ class Category implements GradebookItem
$parent_id = $this->get_parent_id(); $parent_id = $this->get_parent_id();
$grade_model_id = $this->get_grade_model_id(); $grade_model_id = $this->get_grade_model_id();
if ($parent_id == 0) { if ($parent_id == 0) {
if (isset($grade_model_id) && !empty($grade_model_id) && $grade_model_id != '-1') { if (isset($grade_model_id) && !empty($grade_model_id) && $grade_model_id != '-1') {
$obj = new GradeModel(); $obj = new GradeModel();
$components = $obj->get_components($grade_model_id); $components = $obj->get_components($grade_model_id);
@ -673,15 +674,13 @@ class Category implements GradebookItem
foreach ($components as $component) { foreach ($components as $component) {
$gradebook = new Gradebook(); $gradebook = new Gradebook();
$params = array(); $params = array();
$params['name'] = $component['acronym'];
$params['name'] = $component['acronym']; $params['description'] = $component['title'];
$params['description'] = $component['title']; $params['user_id'] = api_get_user_id();
$params['user_id'] = api_get_user_id(); $params['parent_id'] = $this->id;
$params['parent_id'] = $this->id; $params['weight'] = $component['percentage'] / 100 * $default_weight;
$params['weight'] = $component['percentage']/100*$default_weight; $params['session_id'] = api_get_session_id();
$params['session_id'] = api_get_session_id(); $params['course_code'] = $this->get_course_code();
$params['course_code'] = $this->get_course_code();
$gradebook->save($params); $gradebook->save($params);
} }
} }
@ -732,7 +731,8 @@ class Category implements GradebookItem
public function update_category_delete($course_id) public function update_category_delete($course_id)
{ {
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'UPDATE '.$tbl_grade_categories.' SET visible=3 $sql = 'UPDATE '.$tbl_grade_categories.' SET
visible = 3
WHERE course_code ="'.Database::escape_string($course_id).'"'; WHERE course_code ="'.Database::escape_string($course_id).'"';
Database::query($sql); Database::query($sql);
} }
@ -743,13 +743,14 @@ class Category implements GradebookItem
public function show_message_resource_delete($course_id) public function show_message_resource_delete($course_id)
{ {
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT count(*) AS num from '.$tbl_grade_categories.' $sql = 'SELECT count(*) AS num
FROM '.$tbl_grade_categories.'
WHERE WHERE
course_code = "'.Database::escape_string($course_id).'" AND course_code = "'.Database::escape_string($course_id).'" AND
visible=3'; visible = 3';
$res = Database::query($sql); $res = Database::query($sql);
$option = Database::fetch_array($res, 'ASSOC'); $option = Database::fetch_array($res, 'ASSOC');
if ($option['num']>=1) { if ($option['num'] >= 1) {
return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>'; return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>';
} else { } else {
return false; return false;
@ -782,7 +783,7 @@ class Category implements GradebookItem
*/ */
public function does_name_exist($name, $parent) public function does_name_exist($name, $parent)
{ {
if (!isset ($name)) { if (!isset($name)) {
$name = $this->name; $name = $this->name;
$parent = $this->parent; $parent = $this->parent;
} }
@ -805,11 +806,11 @@ class Category implements GradebookItem
} else { } else {
$sql .= ' AND user_id = '.api_get_user_id(); $sql .= ' AND user_id = '.api_get_user_id();
} }
} else { } else {
$sql .= ' AND user_id = '.api_get_user_id(); $sql .= ' AND user_id = '.api_get_user_id();
} }
if (!isset ($parent)) {
if (!isset($parent)) {
$sql.= ' AND parent_id is null'; $sql.= ' AND parent_id is null';
} else { } else {
$sql.= ' AND parent_id = '.intval($parent); $sql.= ' AND parent_id = '.intval($parent);
@ -1183,7 +1184,7 @@ class Category implements GradebookItem
cu.status = '.COURSEMANAGER.' cu.status = '.COURSEMANAGER.'
)'; )';
} }
}elseif (api_is_platform_admin()) { } elseif (api_is_platform_admin()) {
if (isset($session_id) && $session_id!=0) { if (isset($session_id) && $session_id!=0) {
$sql.=' AND session_id='.intval($session_id); $sql.=' AND session_id='.intval($session_id);
} else { } else {
@ -1195,7 +1196,11 @@ class Category implements GradebookItem
// course independent categories // course independent categories
if (empty($course_code)) { if (empty($course_code)) {
$cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats); $cats = Category::get_independent_categories_with_result_for_student(
0,
$stud_id,
$cats
);
} }
return $cats; return $cats;
@ -1241,7 +1246,14 @@ class Category implements GradebookItem
$cats = Category::create_category_objects_from_sql_result($result); $cats = Category::create_category_objects_from_sql_result($result);
// course independent categories // course independent categories
if (isset($course_code)) { if (isset($course_code)) {
$indcats = Category::load(null,$user_id,$course_code,0,null,$session_id); $indcats = Category::load(
null,
$user_id,
$course_code,
0,
null,
$session_id
);
$cats = array_merge($cats, $indcats); $cats = array_merge($cats, $indcats);
} }

@ -433,10 +433,12 @@ class StudentPublicationLink extends AbstractLink
} }
} }
/**
* @return string
*/
public function delete_linked_data() public function delete_linked_data()
{ {
$data = $this->get_exercise_data(); $data = $this->get_exercise_data();
if (empty($data)) { if (empty($data)) {
return ''; return '';
} }
@ -444,7 +446,7 @@ class StudentPublicationLink extends AbstractLink
if (!empty($id)) { if (!empty($id)) {
//Cleans works //Cleans works
$sql = 'UPDATE '.$this->get_studpub_table().' $sql = 'UPDATE '.$this->get_studpub_table().'
SET weight=0 SET weight = 0
WHERE c_id = '.$this->course_id.' AND id ='.$id; WHERE c_id = '.$this->course_id.' AND id ='.$id;
Database::query($sql); Database::query($sql);
} }

@ -84,7 +84,6 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
$this->_data[$name] = $pattern; $this->_data[$name] = $pattern;
} // end func addData } // end func addData
function getValidationScript($options = null) function getValidationScript($options = null)
{ {
$regex = isset($this->_data[$this->name]) ? $this->_data[$this->name] : $options; $regex = isset($this->_data[$this->name]) ? $this->_data[$this->name] : $options;
@ -96,6 +95,5 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
} }
return array(" var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})"); return array(" var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");
} // end func getValidationScript }
} }

@ -43,7 +43,6 @@ class HTML_QuickForm_RuleRegistry
*/ */
var $_rules = array(); var $_rules = array();
/** /**
* Returns a singleton of HTML_QuickForm_RuleRegistry * Returns a singleton of HTML_QuickForm_RuleRegistry
* *
@ -84,7 +83,7 @@ class HTML_QuickForm_RuleRegistry
* @access public * @access public
* @return void * @return void
*/ */
function registerRule($ruleName, $type, $data1, $data2 = null) public function registerRule($ruleName, $type, $data1, $data2 = null)
{ {
$type = strtolower($type); $type = strtolower($type);
if ($type == 'regex') { if ($type == 'regex') {
@ -109,7 +108,7 @@ class HTML_QuickForm_RuleRegistry
* @access public * @access public
* @return HTML_QuickForm_Rule * @return HTML_QuickForm_Rule
*/ */
function getRule($ruleName) public function getRule($ruleName)
{ {
if (empty($ruleName)) { if (empty($ruleName)) {
return false; return false;
@ -383,5 +382,4 @@ class HTML_QuickForm_RuleRegistry
} }
return array($value, $tmp_reset); return array($value, $tmp_reset);
} }
} // end class HTML_QuickForm_RuleRegistry }
?>

@ -111,7 +111,7 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
* @access public * @access public
* @return void * @return void
*/ */
function setValue($value) public function setValue($value)
{ {
$this->updateAttributes(array('value'=>$value)); $this->updateAttributes(array('value'=>$value));
} // end func setValue } // end func setValue
@ -126,7 +126,7 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
* @access public * @access public
* @return string * @return string
*/ */
function getValue() public function getValue()
{ {
return $this->getAttribute('value'); return $this->getAttribute('value');
} // end func getValue } // end func getValue

@ -72,7 +72,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
parent::__construct($elementName, $elementLabel, $attributes); parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true; $this->_persistantFreeze = true;
$this->setType('text'); $this->setType('text');
} }
@ -124,7 +123,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
} }
} }
switch ($layout) { switch ($layout) {
case FormValidator::LAYOUT_INLINE: case FormValidator::LAYOUT_INLINE:
return ' return '

Loading…
Cancel
Save