Change table to show total result see BT#13099

pull/2487/head
jmontoyaa 8 years ago
parent 26e53437c2
commit 07b0dc8dcd
  1. 19
      main/admin/gradebook_dependency.php
  2. 57
      main/template/default/admin/gradebook_dependency.tpl

@ -57,7 +57,8 @@ $courseList = [];
/*$mandatoryList = api_get_configuration_value('gradebook_dependency_mandatory_courses'); /*$mandatoryList = api_get_configuration_value('gradebook_dependency_mandatory_courses');
$mandatoryList = isset($mandatoryList['courses']) ? $mandatoryList['courses'] : [];*/ $mandatoryList = isset($mandatoryList['courses']) ? $mandatoryList['courses'] : [];*/
$userResult = [];
$totalDependencies = count($dependencies);
foreach ($dependencies as $courseId) { foreach ($dependencies as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId); $courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo['code']; $courseCode = $courseInfo['code'];
@ -70,16 +71,23 @@ foreach ($dependencies as $courseId) {
$userList = CourseManager::get_student_list_from_course_code($courseCode); $userList = CourseManager::get_student_list_from_course_code($courseCode);
$users = []; $users = [];
foreach ($userList as $user) { foreach ($userList as $user) {
$userInfo = api_get_user_info($user['user_id']); $userId = $user['user_id'];
$userInfo = api_get_user_info($userId);
$result = Category::userFinishedCourse( $result = Category::userFinishedCourse(
$user['user_id'], $userId,
$subCategory, $subCategory,
true true
); );
$userInfo['result'] = $result; $userInfo['result'] = $result;
$users[] = $userInfo; //$users[] = $userInfo;
$userResult[$userId]['result'][$courseCode] = $result;
$userResult[$userId]['user_info'] = $userInfo;
}
foreach ($userResult as $userId => &$userData) {
$userData['final_result'] = count(array_filter($userData['result'])) == $totalDependencies;
} }
$courseInfo['users'] = $users; //$courseInfo['users'] = $users;
//$courseInfo['is_mandatory'] = in_array($courseCode, $mandatoryList); //$courseInfo['is_mandatory'] = in_array($courseCode, $mandatoryList);
$courseList[] = $courseInfo; $courseList[] = $courseInfo;
} }
@ -96,5 +104,6 @@ $tpl->assign(
$tpl->assign('gradebook_category', $category); $tpl->assign('gradebook_category', $category);
$tpl->assign('courses', $courseList); $tpl->assign('courses', $courseList);
$tpl->assign('users', $userResult);
$layout = $tpl->get_template('admin/gradebook_dependency.tpl'); $layout = $tpl->get_template('admin/gradebook_dependency.tpl');
$tpl->display($layout); $tpl->display($layout);

@ -2,37 +2,44 @@
{% block content %} {% block content %}
<h3> <h3>
{{ gradebook_category.name }} {{ gradebook_category.name }}
{% if gradebook_category.courseCode is not empty %} {% if gradebook_category.courseCode is not empty %}
({{ gradebook_category.courseCode }}) ({{ gradebook_category.courseCode }})
{% endif %} {% endif %}
</h3> </h3>
<hr> <hr>
{% for course in courses %} <table class="table">
<h4> <thead class="title">
{{ course.title }} ({{ course.code }}) <tr>
</h4> <th>{{ 'Users' | get_lang }}</th>
{% for course in courses %}
<th>
{{ course.title }} ({{ course.code }})
</th>
{% endfor %}
<th>{{ 'Total' | get_lang }}</th>
</tr>
</thead>
{% for user in users %}
<tr>
<td>{{ user.user_info.complete_name }}</td>
{% if course.users %} {% for course in courses %}
<table class="table"> <td>
<thead class="title"> {% if user.result[course.code] %}
<tr> <img src="{{ 'check-circle.png'|icon(22) }}" />
<th>{{ 'Users' | get_lang }}</th> {% endif %}
<th>{{ 'Result' | get_lang }}</th> </td>
</tr>
</thead>
{% for user in course.users %}
<tr>
<td>{{ user.complete_name }}</td>
<td>
{% if user.result %}
<img src="{{ 'check-circle.png'|icon(22) }}" />
{% else %}
{% endif %}
</td>
</tr>
{% endfor %} {% endfor %}
</table>
{% endif %} <td>
{% if user.final_result %}
<img src="{{ 'check-circle.png'|icon(22) }}" />
{% else %}
<img src="{{ 'warning.png'|icon(22) }}" />
{% endif %}
</td>
</tr>
{% endfor %} {% endfor %}
</table>
{% endblock %} {% endblock %}

Loading…
Cancel
Save