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

skala
Julio Montoya 12 years ago
parent b654167a3d
commit dd68842c37
  1. 145
      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. 2
      src/ChamiloLMS/Controller/Tool/Curriculum/CurriculumCategoryController.php
  5. 32
      src/ChamiloLMS/Controller/Tool/Curriculum/CurriculumUserController.php

@ -19,93 +19,110 @@
$(function() { $(function() {
}); });
</script> </script>
<style>
.no_border {
border-top : none !important;
}
.center_text {
vertical-align: middle !important;
text-align: center !important;
}
</style>
<div class="row"> <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> <h2>Trayectoria</h2>
<p>Resultados</p> <p>Resultados</p>
<div id="list" class="trajectory"> <table class="data_table">
<table class="data_table"> <tr>
<tr> <th class="center_text">
<th> Rubro
Rubro </th>
</th> <th class="center_text">
<th> Criterios
Criterios </th>
</th> <th class="center_text">
<th> Puntaje
Puntaje </th>
</th> <th class="center_text" style="width:110px">
<th> N° máximo de evidencias por criterio
Numero máximo de evidencias por criterio </th>
</th> <th class="center_text" style="width:110px">
<th> Puntaje máximo por rubro
Puntaje máximo por rubro </th>
</th> </tr>
</tr>
{% for subcategory in categories %} {% for subcategory in categories %}
{% if subcategory.lvl == 0 %} {% if subcategory.lvl == 0 %}
{% elseif subcategory.lvl == 1 %} {% elseif subcategory.lvl == 1 %}
<tr> <tr>
<td rowspan="{{ category_counter[subcategory.id] | length + 2 }}"> <td class="center_text" rowspan="{{ category_counter[subcategory.id] | length + 3 }}">
<h3> {{ subcategory.title }} </h3> <h3> {{ subcategory.title }} </h3>
</td> </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 %} {% else %}
<td> <tr>
<h4> <td class="no_border">
{{ subcategory.title }} <h4>
{% if category_score[subcategory.id] %} {{ subcategory.title }}
(Total <div class="label label-success">{{ category_score[subcategory.id] }}</div>) {% if category_score[subcategory.id] %}
{% endif %} (Sub total <div class="label label-success">{{ category_score[subcategory.id] }}</div>)
</h4> {% endif %}
</td> </h4>
<td> </td>
</td> <td class="no_border">
<td> </td>
</td> <td class="no_border">
<td> </td>
</td>
</tr> </tr>
{% endif %} {% endif %}
{% if subcategory.items.count > 0 %} {% if subcategory.items.count > 0 %}
{% for item in subcategory.items %} {% for item in subcategory.items %}
<tr> <tr>
<td> <td>
{# Items #} {# Items #}
{{ item.title }} {{ 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 }}" >
{% for widget in form_list[item.id].userItems.children %}
{{ _self.widget_prototype(widget, 'Remove item') }}
{% endfor %}
<ul>
</ul>
</div>
{{ form_end(form_list[item.id]) }}
{% endif %}
</td> {% if 0 %}
<td> {{ form_start(form_list[item.id]) }}
{{ item.score }} <div id="items_{{ item.id }}" class="items span8" data-max="{{ item.maxRepeat }}" data-prototype="{{ form_widget(form_list[item.id].userItems.vars.prototype)|e }}" >
</td> {% for widget in form_list[item.id].userItems.children %}
<td> {{ _self.widget_prototype(widget, 'Remove item') }}
{{ item.maxRepeat }} {% endfor %}
</td> <ul>
<td> </ul>
{{ category_score[subcategory.parentId]}} </div>
</td> {{ form_end(form_list[item.id]) }}
{% endif %}
</td>
<td>
{{ item.score }}
</td>
<td>
{{ item.maxRepeat }}
</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</table> </table>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

@ -37,7 +37,6 @@ $(function() {
$(".items").each(function(index, value) { $(".items").each(function(index, value) {
var itemId = $(this).attr('id'); var itemId = $(this).attr('id');
var lastInput = $(this).find("input:text").last(); 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>'); 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 ); //lastInput.parent().append(addButton );
}); });
@ -83,8 +82,12 @@ function addTagFormDeleteLink($tagFormLi) {
function save(itemId) { function save(itemId) {
var form = $("#"+itemId).parent(); var form = $("#"+itemId).parent();
var serializedForm = form.serialize(); var serializedForm = form.serialize();
$.post('{{ url('curriculum_user.controller:saveUserItemAction', {'course' : course.code }) }}', serializedForm); $.ajax({
return false; //async: false,
type: "POST",
url: '{{ url('curriculum_user.controller:saveUserItemAction', {'course' : course.code }) }}',
data: serializedForm
});
} }
function saveAll() { function saveAll() {
@ -93,10 +96,25 @@ function saveAll() {
var itemId = $(this).attr('id') var itemId = $(this).attr('id')
save(itemId); save(itemId);
}); });
$('#myModal').modal('show');
} }
</script> </script>
<div class="row"> <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"> <div class="span10">
{% if is_granted('ROLE_ADMIN') %} {% if is_granted('ROLE_ADMIN') %}
<div class="actions"> <div class="actions">
@ -107,7 +125,6 @@ function saveAll() {
{{ "Results" | trans }} {{ "Results" | trans }}
</a> </a>
</div> </div>
{% endif %} {% endif %}
<h2>Trayectoria</h2> <h2>Trayectoria</h2>
@ -156,7 +173,7 @@ function saveAll() {
<div class="span2"> <div class="span2">
<div id="saveQuestionBar" data-spy="affix" data-offset-top="500"> <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> </div>
</div> </div>

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

@ -67,7 +67,7 @@ class CurriculumCategoryController extends CommonController
foreach ($row['items'] as $item) { foreach ($row['items'] as $item) {
$url = ' <a class="btn" href="'.$this->createUrl('edit_item', array('id' => $item['id'])).'">'.$editLabel.'</a>'; $url = ' <a class="btn" href="'.$this->createUrl('edit_item', array('id' => $item['id'])).'">'.$editLabel.'</a>';
$items.= '<li>'.$item['title']." (Score: {$item['score']} ) ".$url.'</li>'; $items.= '<li>'.$item['title']." (Score: {$item['score']}) ".$url.'</li>';
} }
$items .= '</ul>'; $items .= '</ul>';
} }

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

Loading…
Cancel
Save