From 58a35ee6a35fdb7c676bcf78ae0a01d56f8ee82b Mon Sep 17 00:00:00 2001 From: Samu Date: Sun, 28 Jul 2013 19:33:27 +0000 Subject: despues de mucho un commit --- diff --git a/EjercitarWeb/WebContent/js/attc.css b/EjercitarWeb/WebContent/js/attc.css new file mode 100644 index 0000000..ac12ee0 --- /dev/null +++ b/EjercitarWeb/WebContent/js/attc.css @@ -0,0 +1,99 @@ +@media screen { +/* override css in main */ +body{ + margin-left: auto; margin-right: auto; + margin-top:20px; + width:100%; + position:relative; + left:0px; + top:0px; + z-index:0; + background-color:#FFFFFF; + color:#47535E; + font-size:0.7em; + font-family:Arial, sans-serif; +} + +div.mainContent{ + margin-left: auto; margin-right: auto; + width:800px; +} +table{ + margin-left: auto; margin-right: auto; + width:98%; + border:1px solid #E6E6E6; + border-radius:5px; + box-sizing: border-box; + background-color:#F6F6F6; + border-collapse: collapse; +} +table td,table th{ + border:1px solid #E6E6E6; + border-top:1px solid #FFFFFF; +} +table th{ + background-color:#FFFFFF; +} +/*attc classes*/ +/*attc classes*/ +div.attcControls{ + width:100%; + border:1px solid #E6E6E6; + border-radius:5px; + box-sizing: border-box; + background-color:#F6F6F6; +} +div.attcControls ul{ + overflow:hidden; + padding:2px 2px 2px 2px; + margin:0px; +} +div.attcControls ul li{ + margin:0px; + padding:0px 0px 0px 10px; + list-style-type: none; + display: inline; + float:right; + clear:none; +} +div.attcControls ul li a{ + border:1px solid #9CDFF7; + border-radius:3px; + box-sizing: border-box; + background-color:#86D6F5; + padding:2px; + color:white; + text-decoration:none; + display:inline-block; + background-image:none; + font-weight:normal; +} +div.attcControls ul li a:hover{ + border:1px solid white; + color:#47535E; +} +div.attcControls ul li fieldset{ + border:1px solid #9CDFF7; + border-radius:3px; + box-sizing: border-box; + background-color:#86D6F5; + padding:2px; + margin:0px; + color:white; + text-decoration:none; +} +div.attcControls ul li fieldset label{ + padding-right:5px; +} +div.attcControls ul li fieldset select{ + font-size:1em; + padding:0px; + margin:0px; +} + +input.attcEditCheckRadioBoxes{ + display: block; + margin-left: auto; + margin-right: auto; +} +} \ No newline at end of file diff --git a/EjercitarWeb/WebContent/js/attc.googleCharts.js b/EjercitarWeb/WebContent/js/attc.googleCharts.js new file mode 100644 index 0000000..c8bd0fb --- /dev/null +++ b/EjercitarWeb/WebContent/js/attc.googleCharts.js @@ -0,0 +1,302 @@ +google.load("visualization", "1", {packages:["corechart"]}); +(function( $ ){ + $.fn.attc = function(options) { + var numPattern = /[^0-9\.]/g; + var tableEl = this; + var dataArray=new Array(); + var numRows = tableEl.find('tbody tr').length; + //defaults + var settings = $.extend( { + 'location':tableEl.attr('id'), + 'hideTable' : false, + 'hideChart' : false, + 'type':'bar', + 'googleOptions':new Object(), + 'controls':{ + showHide:true, + create:true, + chartType:true + }, + 'controlsLabels':{ + showChart:"Show chart", + hideChart:"Hide chart", + showTable:"Show table", + hideTable:"Hide table", + createChart:"Edit chart", + changeChart:"Change chart" + }, + chartOptionList:'' + }, options); + //set editing attribute to false so it can be tested: + tableEl.attr('data-attc-editing',false); + //function to create a table + var CreateChart = function(type,location,tableEl) + { + var dataArray=new Array(); + switch(type){ + case 'pie': + //console.log("making a pie"); + var headerValues=$('#'+tableEl.attr('data-attc-colvalues')); + var headerDesc=tableEl.attr('data-attc-colDescription'); + if(headerDesc.split(',').length >0){ + headerDesc=$('#'+headerDesc.split(',')[0]); + }else{ + headerDesc=$('#'+headerDesc); + } + var colIndexValues=headerValues.index()+1; + var colIndexDesc=headerDesc.index()+1; + dataArray[0]=[headerDesc.text(), headerValues.text()]; + for(i=1;i <=numRows;i++){ + //loop values and description to get array + var value=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexValues+')').text(); + value=parseFloat(value.replace(numPattern,'')); + var description=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexDesc+')').text(); + //console.log(colIndexDesc+ ':'+description); + dataArray[i]=[description,value]; + } + var chart = new google.visualization.PieChart(document.getElementById(location)); + break; + + case 'bar': + case 'column': + case 'area': + case 'line': + var headerDesc=$('#'+tableEl.attr('data-attc-colDescription')); + var colIndexDesc=headerDesc.index()+1; + var headerValuesArray=tableEl.attr('data-attc-colvalues').split(','); + //var headerValuesArray=$('#'+tableEl.attr('data-attc-colvalues')).split(','); + var headerIndexArray=new Array(); + var colIndexValues=0; + var value=""; + var description=""; + //get index for each column + for(x=0;x0 ){ + if(tableEl.get(0).tagName=='TABLE'){ + //fork depending on the setting + CreateChart(settings.type,settings.location,tableEl); + + //hide the table + if(settings.hideTable=="true"){ + tableEl.hide(); + } + if(settings.hideChart=="true"){ + $('#'+settings.location).hide(); + } + //start making the controls + var controls=''; + if(settings.controls.showHide){ + controls+='
  • '+(settings.hideChart ? settings.controlsLabels.showChart : settings.controlsLabels.hideChart)+'
  • '; + + controls+='
  • '+(settings.hideTable ? settings.controlsLabels.showTable : settings.controlsLabels.hideTable)+'
  • '; + } + //start making the controls + if(settings.controls.create){ + controls+='
  • '+(settings.controlsLabels.createChart)+'
  • ' + } + if(settings.controls.chartType){ + controls+='
  • '; + } + //if there are any controls to show + if(controls !=''){ + controls='
      '+controls+'
    '; + var controlsEl=$(controls); + //set the select list to show current selected chart + controlsEl.find("select[data-attc-controls-updateChart]").val(settings.type); + // + controlsEl.on("click", "a[data-attc-controls-showHide]", function(e){ + e.preventDefault(); + var el=$('#'+$(this).attr('data-attc-controls-showHide')); + el.find('tbody').show(); + el.toggle(); + $(this).text(el.is(':visible') ? $(this).attr('data-attc-textHide') : $(this).attr('data-attc-textShow')); + }); + controlsEl.on("change", "select[data-attc-controls-updateChart]", function(){ + //update chart type for other functions + tableEl.attr('data-attc-type',$(this).val()); + //grab the new chart and re-run the creation + CreateChart($(this).val(),settings.location,tableEl); + //if editing then update the editing controls + if(tableEl.attr('data-attc-editing')=='true'){ + controlsEl.find("a[data-attc-controls-addCreateOptions]").click(); + } + }); + controlsEl.find("a[data-attc-controls-addCreateOptions]").on("click", function(e){ + e.preventDefault(); + if(!tableEl.is(':visible')){ + //show the thead only + tableEl.show(); + tableEl.find('tbody').hide(); + } + //set table as editing + tableEl.attr('data-attc-editing',true); + //remove existing edit boxes + tableEl.find('thead th input.attcEditCheckRadioBoxes').remove(); + //add check boxes to the th elements + tableEl.find('thead th').each(function(index) { + //find col type by adding all values together and checking if it's not NaN + var items=0; + var col=index+1; + var inputType='checkbox'; + var inputColType='value'; + var descriptionCol=tableEl.attr('data-attc-colDescription'); + var valuesCols=tableEl.attr('data-attc-colvalues').split(','); + valuesCols.push(descriptionCol); + tableEl.find('tbody>tr>td:nth-child('+col+')').each( function(){ + items+=parseFloat($(this).text().replace(numPattern,'')); + }); + + if(isNaN(items)){ + inputType='radio'; + inputColType='desc'; + } + //force back to radio if pie chart + if(tableEl.attr('data-attc-type')=='pie'){ + inputType='radio'; + } + var appendEl='-1){ + appendEl+=' checked="checked"'; + } + appendEl+=' class="attcEditCheckRadioBoxes"/>'; + appendEl=$(appendEl).on("click", function(){ + //give this col an id if it doesn't have one + var myId='attcCol'+$(this).val(); + if($(this).parents('th').attr('id')!= undefined){ + myId=$(this).parents('th').attr('id'); + }else{ + $(this).parents('th').attr('id',myId); + } + //change the attribute to this column + if($(this).attr('data-attc-colType')=='desc'){ + tableEl.attr('data-attc-colDescription',myId); + }else{ + //todo remove value if unchecked + if(tableEl.attr('data-attc-type') =='pie'){ + tableEl.attr('data-attc-colValues',myId); + }else{ + //select all the checked inputs + var checkedIds=tableEl.find('input[data-attc-colType=value]:checked').parents('th').map(function() { return this.id; }).get().toString(); + tableEl.attr('data-attc-colValues',checkedIds); + } + } + //re-create chart + CreateChart(tableEl.attr('data-attc-type'),settings.location,tableEl); + }); + $(this).prepend(appendEl); + + + }); + }); + //add controls above the table el + tableEl.before(controlsEl); + } + }else{ + alert(tableEl.attr('id')+' is not a table it\'s a: ' + tableEl.get(0).tagName); + } + }else{ + // + } + //maintain chain + return this + }; +})( jQuery ); + +$(document).ready(function(){ + $('[data-attc-createChart]').attc(); +}); \ No newline at end of file diff --git a/EjercitarWeb/WebContent/ver_resultados.jsp b/EjercitarWeb/WebContent/ver_resultados.jsp index da3b642..2c53c0c 100644 --- a/EjercitarWeb/WebContent/ver_resultados.jsp +++ b/EjercitarWeb/WebContent/ver_resultados.jsp @@ -6,14 +6,33 @@ Resultados + + + + + + + <%@page import="java.util.List" import="model.Tema" import="model.Profesor"%>
    +
    + + +
    +

    holas

    + +
    +
    Seleccione un tema @@ -28,11 +47,42 @@

    -
    +
    + + +
    +
    + + +
    +
    +
    + + +
    +

    holas1

    + +
    +
    +

    holas2

    + +
    +
    +

    holas3

    + +
    +
    - +
    + + +
    diff --git a/EjercitarWeb/src/src/CargarResultadosServlet.java b/EjercitarWeb/src/src/CargarResultadosServlet.java index 1dec8a3..a06b5ff 100644 --- a/EjercitarWeb/src/src/CargarResultadosServlet.java +++ b/EjercitarWeb/src/src/CargarResultadosServlet.java @@ -66,11 +66,20 @@ public class CargarResultadosServlet extends HttpServlet { try { - out.printf(""); - out.printf(""); + out.printf(""); out.printf(""); - out.printf(""); @@ -78,7 +87,7 @@ public class CargarResultadosServlet extends HttpServlet { out.printf("Apellido"); out.printf(""); - out.printf(""); @@ -88,7 +97,7 @@ public class CargarResultadosServlet extends HttpServlet { .setParameter("tema", tema).getResultList(); for (Concepto concepto : conceptoList) { - out.printf(""); } -- cgit v0.9.1
    "); + out.printf(""); out.printf("Nombre"); out.printf(""); + out.printf(""); out.printf("Tema"); out.printf(""); + out.printf(""); out.printf(concepto.getNombre()); out.printf("