Improving results page. (Work in progress) see BT#6397

skala
Julio Montoya 12 years ago
parent b654167a3d
commit dd68842c37
  1. 63
      main/template/minedu/tool/curriculum/user/get_user_items.tpl
  2. 27
      main/template/minedu/tool/curriculum/user/list.tpl
  3. 1
      main/template/minedu/tool/curriculum/user/read.tpl
  4. 32
      src/ChamiloLMS/Controller/Tool/Curriculum/CurriculumUserController.php

@ -19,51 +19,73 @@
$(function() {
});
</script>
<style>
.no_border {
border-top : none !important;
}
.center_text {
vertical-align: middle !important;
text-align: center !important;
}
</style>
<div class="row">
<div class="span10">
<div class="span12">
<div class="actions">
<a href="{{ url('curriculum_user.controller:indexAction',
{ 'userId': userResultId, 'course' : course.code, 'id_session' : course_session.id }) }}">
{{ 'Edit' | trans }}
</a>
</div>
<h2>Trayectoria</h2>
<p>Resultados</p>
<div id="list" class="trajectory">
<table class="data_table">
<tr>
<th>
<th class="center_text">
Rubro
</th>
<th>
<th class="center_text">
Criterios
</th>
<th>
<th class="center_text">
Puntaje
</th>
<th>
Numero máximo de evidencias por criterio
<th class="center_text" style="width:110px">
máximo de evidencias por criterio
</th>
<th>
<th class="center_text" style="width:110px">
Puntaje máximo por rubro
</th>
</tr>
{% for subcategory in categories %}
{% if subcategory.lvl == 0 %}
{% elseif subcategory.lvl == 1 %}
<tr>
<td rowspan="{{ category_counter[subcategory.id] | length + 2 }}">
<td class="center_text" rowspan="{{ category_counter[subcategory.id] | length + 3 }}">
<h3> {{ subcategory.title }} </h3>
</td>
<td colspan="3">
</td>
<td class="center_text" rowspan="{{ category_counter[subcategory.id] | length + 3 }}">
<h4>{{ category_score[subcategory.id]}} </h4>
</td>
</tr>
{% else %}
<td>
<tr>
<td class="no_border">
<h4>
{{ subcategory.title }}
{% if category_score[subcategory.id] %}
(Total <div class="label label-success">{{ category_score[subcategory.id] }}</div>)
(Sub total <div class="label label-success">{{ category_score[subcategory.id] }}</div>)
{% endif %}
</h4>
</td>
<td>
<td class="no_border">
</td>
<td>
</td>
<td>
<td class="no_border">
</td>
</tr>
{% endif %}
@ -74,6 +96,7 @@ $(function() {
<td>
{# Items #}
{{ item.title }}
{% if 0 %}
{{ form_start(form_list[item.id]) }}
<div id="items_{{ item.id }}" class="items span8" data-max="{{ item.maxRepeat }}" data-prototype="{{ form_widget(form_list[item.id].userItems.vars.prototype)|e }}" >
@ -85,7 +108,6 @@ $(function() {
</div>
{{ form_end(form_list[item.id]) }}
{% endif %}
</td>
<td>
{{ item.score }}
@ -93,19 +115,14 @@ $(function() {
<td>
{{ item.maxRepeat }}
</td>
<td>
{{ category_score[subcategory.parentId]}}
</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</table>
</div>
</div>
</div>
{% endblock %}

@ -37,7 +37,6 @@ $(function() {
$(".items").each(function(index, value) {
var itemId = $(this).attr('id');
var lastInput = $(this).find("input:text").last();
console.log(lastInput.attr('id'));
var addButton = $('<a class="btn-add btn btn-primary" data-target="'+itemId+'"><i class="icon-plus-sign icon-large"></i></a>');
//lastInput.parent().append(addButton );
});
@ -83,8 +82,12 @@ function addTagFormDeleteLink($tagFormLi) {
function save(itemId) {
var form = $("#"+itemId).parent();
var serializedForm = form.serialize();
$.post('{{ url('curriculum_user.controller:saveUserItemAction', {'course' : course.code }) }}', serializedForm);
return false;
$.ajax({
//async: false,
type: "POST",
url: '{{ url('curriculum_user.controller:saveUserItemAction', {'course' : course.code }) }}',
data: serializedForm
});
}
function saveAll() {
@ -93,10 +96,25 @@ function saveAll() {
var itemId = $(this).attr('id')
save(itemId);
});
$('#myModal').modal('show');
}
</script>
<div class="row">
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"></h3>
</div>
<div class="modal-body">
<p>Datos registrados.</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<div class="span10">
{% if is_granted('ROLE_ADMIN') %}
<div class="actions">
@ -107,7 +125,6 @@ function saveAll() {
{{ "Results" | trans }}
</a>
</div>
{% endif %}
<h2>Trayectoria</h2>
@ -156,7 +173,7 @@ function saveAll() {
<div class="span2">
<div id="saveQuestionBar" data-spy="affix" data-offset-top="500">
<a class="btn btn-success btn-large btn-block" onclick="saveAll();">{{ 'Save all' | get_lang }}</a>
<a data-loading-text="Cargando ..." class="btn btn-success btn-large btn-block" onclick="saveAll();">{{ 'Save all' | get_lang }}</a>
</div>
</div>
</div>

@ -11,5 +11,4 @@
</li>
{% endfor %}
</ul>
{% endblock %}

@ -289,32 +289,50 @@ class CurriculumUserController extends CommonController
/** @var \Entity\CurriculumCategory $category */
$categoryCounter = array();
$categoryScore = array();
$scorePerSubcategory = 0;
foreach ($categories as $category) {
/** @var \Entity\CurriculumItem $item */
$score = 0;
//$scorePerCategory = 0;
foreach ($category->getItems() as $item) {
$formType = new CurriculumItemRelUserCollectionType($item->getId());
$form = $this->get('form.factory')->create($formType, $item, array('disabled' => true));
$formList[$item->getId()] = $form->createView();
$scorePerSubcategory = 0;
/** @var \Entity\CurriculumItemRelUser $userItem */
foreach ($item->getUserItems() as $userItem) {
$score += $item->getScore();
if ($userItem->getId()) {
/** @var \Entity\CurriculumItem $myItem */
$myItem = $userItem->getItem();
if (!isset($categoryScore[$myItem->getCategoryId()])) {
$categoryScore[$myItem->getCategoryId()] = 0;
}
$categoryScore[$myItem->getCategoryId()] += $myItem->getScore();
if (!isset($categoryScore[$myItem->getCategory()->getParentId()])) {
$categoryScore[$myItem->getCategory()->getParentId()] = 0;
}
$categoryScore[$myItem->getCategory()->getParentId()] += $myItem->getScore();
}
}
$categoryCounter[$category->getParentId()][] = $item->getId();
$categoryScore[$item->getCategoryId()] = $score;
if (!isset($categoryScore[$category->getParentId()])) {
$categoryScore[$category->getParentId()] = 0;
if (!isset($categoryScore[$item->getCategoryId()])) {
//$categoryScore[$item->getCategoryId()] = 0;
} else {
//$categoryScore[$item->getCategoryId()] = $scorePerSubcategory;
}
$categoryScore[$category->getParentId()] += $score;
}
}
var_dump($categoryScore);
$this->get('template')->assign('category_counter', $categoryCounter);
$this->get('template')->assign('categories', $categories);
$this->get('template')->assign('userResultId', $userId);
$this->get('template')->assign('category_score', $categoryScore);
$this->get('template')->assign('form_list', $formList);
$this->get('template')->assign('isAllowed', api_is_allowed_to_edit(true, true, true));

Loading…
Cancel
Save