Skip to content
Permalink
Browse files

Add new setting "NumberOfGradeBookToValidateInDependence" BT#13319

The setting will check the number of gradebooks to validate depending
the "DependsOnGradebook" list.
  • Loading branch information...
jmontoyaa committed Sep 7, 2017
1 parent a5bcac2 commit 4b9479c30fa0321e99b1f4398950b5dc10b2c4a9
@@ -27,7 +27,6 @@
$categoryObj = Category::load($categoryId);
/** @var Category $categoryObj */
$categoryObj = $categoryObj[0];
$dependencies = $categoryObj->getCourseListDependency();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
@@ -62,6 +61,7 @@
}
$totalDependencies = count($dependencies);
$min = $categoryObj->getMinimumToValidate();
$gradeBooksToValidateInDependence = $categoryObj->getGradeBooksToValidateInDependence();
$userResult = [];
$dependencyList = [];
@@ -114,7 +114,6 @@
} else {
$courseUserLoaded[$userId][$myCourseId] = true;
}
//var_dump($myCourseCode);
$courseCategory = Category::load(
null,
@@ -166,9 +165,6 @@
}
}
}
//$courseInfo['users'] = $users;
//$courseInfo['is_mandatory'] = in_array($courseCode, $mandatoryList);
$courseList[] = $courseInfo;
}
@@ -180,7 +176,8 @@
$userData['course_list_passed_out_dependency_count'] = count($userData['result_out_dependencies']);
// Min req must apply + mandatory should be 20
//$userData['final_result'] = $total >= $min && $userData['result_mandatory_20'] == 20;
$userData['final_result'] = $total >= $min && $courseListPassedDependency == $totalDependencies;
//$userData['final_result'] = $total >= $min && $courseListPassedDependency == $totalDependencies;
$userData['final_result'] = $total >= $min && $courseListPassedDependency >= $gradeBooksToValidateInDependence;
}
$tpl->assign('current_url', $currentUrl);
@@ -93,6 +93,11 @@
]
);
$form->addText(
'gradebooks_to_validate_in_dependence',
get_lang('NumberOfGradebookToValidateInDependence')
);
$form->addText(
'minimum',
get_lang('MinimumGradebookToValidate'),
@@ -136,6 +141,11 @@
if (!empty($values['minimum'])) {
$params['minimum_to_validate'] = (int) $values['minimum'];
}
if (!empty($values['gradebooks_to_validate_in_dependence'])) {
$params['gradebooks_to_validate_in_dependence'] = (int) $values['gradebooks_to_validate_in_dependence'];
}
if (!empty($params)) {
Database::update(
$table,
@@ -169,7 +179,10 @@
$form->addText('weight', get_lang('Weight'));
$form->addLabel(get_lang('Course'), $category->getCourseCode());
$sql = "SELECT depends, minimum_to_validate
$sql = "SELECT
depends,
minimum_to_validate,
gradebooks_to_validate_in_dependence
FROM $table WHERE id = ".$categoryId;
$result = Database::query($sql);
$categoryData = Database::fetch_array($result, 'ASSOC');
@@ -193,6 +206,11 @@
]
);
$form->addText(
'gradebooks_to_validate_in_dependence',
get_lang('NumberOfGradebookToValidateInDependence')
);
$form->addText(
'minimum',
get_lang('MinimumGradebookToValidate'),
@@ -203,6 +221,7 @@
$defaults = [
'name' => $category->getName(),
'weight' => $category->getWeight(),
'gradebooks_to_validate_in_dependence' => $categoryData['gradebooks_to_validate_in_dependence'],
'depends' => array_keys($options),
'minimum' => $categoryData['minimum_to_validate']
];
@@ -225,6 +244,11 @@
if (!empty($values['minimum'])) {
$params['minimum_to_validate'] = (int) $values['minimum'];
}
if (!empty($values['gradebooks_to_validate_in_dependence'])) {
$params['gradebooks_to_validate_in_dependence'] = (int) $values['gradebooks_to_validate_in_dependence'];
}
if (!empty($params)) {
Database::update(
$table,
@@ -27,7 +27,8 @@ class Category implements GradebookItem
private $isRequirement;
private $courseDependency;
private $minimumToValidate;
/** @var int */
private $gradeBooksToValidateInDependence;
public $studentList;
public $evaluations;
public $links;
@@ -563,6 +564,7 @@ private static function create_category_objects_from_sql_result($result)
$cat->setIsRequirement($data['is_requirement']);
$cat->setCourseListDependency(isset($data['depends']) ? $data['depends'] : []);
$cat->setMinimumToValidate(isset($data['minimum_to_validate']) ? $data['minimum_to_validate'] : null);
$cat->setGradeBooksToValidateInDependence(isset($data['gradebooks_to_validate_in_dependence']) ? $data['gradebooks_to_validate_in_dependence'] : null);
$categories[] = $cat;
}
@@ -2597,4 +2599,23 @@ public static function setUrl($url)
}
Session::write('gradebook_dest', $url);
}
/**
* @return int
*/
public function getGradeBooksToValidateInDependence()
{
return $this->gradeBooksToValidateInDependence;
}
/**
* @param int $value
* @return Category
*/
public function setGradeBooksToValidateInDependence($value)
{
$this->gradeBooksToValidateInDependence = $value;
return $this;
}
}
@@ -595,6 +595,7 @@
// Additional gradebook dependencies BT#13099
// ALTER TABLE gradebook_category ADD COLUMN depends TEXT DEFAULT NULL;
// ALTER TABLE gradebook_category ADD COLUMN minimum_to_validate INT DEFAULT NULL;
// ALTER TABLE gradebook_category ADD COLUMN gradebooks_to_validate_in_dependence INT DEFAULT NULL;
// $_configuration['gradebook_dependency'] = false;
// Courses id list to check in the gradebook sidebar see BT#13099
/*$_configuration['gradebook_dependency_mandatory_courses'] = [
@@ -368,6 +368,7 @@ function changeMyCoursesView(inView) {
if (!empty($category)) {
$minToValidate = $category->getMinimumToValidate();
$dependencies = $category->getCourseListDependency();
$gradeBooksToValidateInDependence = $category->getGradeBooksToValidateInDependence();
$countDependenciesPassed = 0;
foreach ($dependencies as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
@@ -386,9 +387,14 @@ function changeMyCoursesView(inView) {
}
}
$userFinished =
/*$userFinished =
$countDependenciesPassed == count($dependencies) &&
$countCoursesPassedNoDependency >= $minToValidate
;*/
$userFinished =
$countDependenciesPassed >= $gradeBooksToValidateInDependence &&
$countCoursesPassedNoDependency >= $minToValidate
;
if ($userFinished) {

0 comments on commit 4b9479c

Please sign in to comment.
You can’t perform that action at this time.