Commit feb343c181436465d576ca1051b431f526b10951

Authored by lyandro.santana
1 parent d544ce89

marcacao

git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%20Web/Fontes/avaliador-api@10373 c2178572-b5ca-4887-91d2-9e3a90c7d55b
src/main/java/br/com/checker/emag/core/MarkEvaluation.java
... ... @@ -236,29 +236,70 @@ public class MarkEvaluation extends Evaluation {
236 236  
237 237 for (String tag : tags) {
238 238 for (Element element : getDocument().getAllElements(tag)) {
  239 +
239 240 /*if(element.getAttributes().getCount()==0)
240 241 occurrences.add(this.buildOccurrence("1.2", true, element.toString(), element, "1"));
241 242 else*/
  243 +
  244 + if(element != null){
  245 + Element img = element.getFirstElement("img");
  246 + if(img != null){
  247 + if(img.getAttributes().get("alt") != null && img.getAttributes().get("alt").getValue().isEmpty()){
  248 + occurrences.add(this.buildOccurrence("1.2", true, element.getStartTag().toString(), element, "1"));
  249 + }else{
  250 + if(element.getContent().toString().isEmpty() || element.getContent().toString().equals(""))
  251 + occurrences.add(this.buildOccurrence("1.2", true, element.getStartTag().toString(), element, "1"));
  252 + }
  253 + }
  254 + }
  255 +
  256 + /*
  257 +
242 258 if(element.getTextExtractor().toString().isEmpty())
243   - occurrences.add(this.buildOccurrence("1.2", false, element.toString(), element, "1"));
  259 + occurrences.add(this.buildOccurrence("1.2", true, element.toString(), element, "1"));
244 260 else{
245 261  
246 262 Element img = element.getFirstElement("img");
247 263 if(img != null)
248   - if(img.getAttributeValue("alt").equals("") || img.getAttributeValue("alt").isEmpty())
249   - occurrences.add(this.buildOccurrence("1.2", false, element.toString(), element, "1"));
  264 + if(img.getAttributes().get("alt").getValue().equals("") || img.getAttributeValue("alt").isEmpty())
  265 + occurrences.add(this.buildOccurrence("1.2", true, element.toString(), element, "1"));
250 266  
251   - }
  267 + }*/
252 268 }
253 269  
254 270 }
255   -
256   - //Sorting
257   - Collections.sort(occurrences, new Comparator<Occurrence>() {
258   - public int compare(Occurrence occurrence1, Occurrence occurrence2){
259   - return occurrence1.getLine().compareTo(occurrence2.getLine());
260   - }
261   - });
  271 +
  272 +
  273 + for (Element element : getDocument().getAllElements()) {
  274 +
  275 + if(element != null){
  276 + Element img = element.getFirstElement("img");
  277 +
  278 + if(img != null){
  279 +
  280 + if(img.getAttributes().get("alt") != null && img.getAttributes().get("alt").getValue().isEmpty())
  281 + occurrences.add(this.buildOccurrence("1.2", false, element.getStartTag().toString(), element, "1"));
  282 +
  283 + }else{
  284 + if(element.getSource().toString().trim().equals("")){
  285 + occurrences.add(this.buildOccurrence("1.2", false, element.getStartTag().toString(), element, "1"));
  286 + }
  287 + /*if(element.getTextExtractor().toString().isEmpty())
  288 + occurrences.add(this.buildOccurrence("1.2", false, element.toString(), element, "1"));*/
  289 + }
  290 + }
  291 + /*
  292 + if(element.getTextExtractor().toString().isEmpty())
  293 + occurrences.add(this.buildOccurrence("1.2", false, element.toString(), element, "1"));
  294 + else{
  295 + Element img = element.getFirstElement("img");
  296 + if(img != null)
  297 + if(img.getAttributeValue("alt").equals("") || img.getAttributeValue("alt").isEmpty())
  298 + occurrences.add(this.buildOccurrence("1.2", false, element.toString(), element, "1"));
  299 + }*/
  300 + }
  301 +
  302 + this.oder(occurrences);
262 303  
263 304  
264 305 /*boolean isError = false;
... ... @@ -330,20 +371,68 @@ public class MarkEvaluation extends Evaluation {
330 371 //List<String> tagsH = new ArrayList<String>();
331 372 //List<Element> elementTag = new ArrayList<Element>();
332 373  
  374 + boolean achou = false;
  375 + int limhaMinima= 0;
  376 +
333 377 for (Element htmlElement : elementsObj) {
334 378 if (htmlElement.getName().matches("h[1-6]")) {
335 379 int tagId = Integer.parseInt(htmlElement.getName().substring(1));
336 380  
  381 + //System.out.println("Tag verificada: "+htmlElement.getName());
  382 +
  383 + if(tagId == 1)
  384 + limhaMinima = this.getRow(htmlElement);
  385 +
  386 +
  387 + List<Element> elementsObj2 = getDocument().getAllElements();
  388 +
  389 + int verificar = tagId-1;
  390 +
  391 + if(tagId > 1){
  392 + for (Element htmlElement2 : elementsObj2) {
  393 + if (htmlElement2.getName().matches("h[1-6]")) {
  394 +
  395 + if(this.getRow(htmlElement2) < this.getRow(htmlElement) && this.getRow(htmlElement2) >= limhaMinima){
  396 + int tagId2 = Integer.parseInt(htmlElement2.getName().substring(1));
  397 + if(verificar == tagId2)
  398 + achou = true;
  399 + //System.out.println("====> verificando: "+htmlElement2.getName()+" --- : "+verificar+" = "+ tagId2);
  400 + }
  401 + }
  402 + }
  403 +
  404 + if(!achou)
  405 + occurrences.add(this.buildOccurrence("1.3", true,htmlElement.toString(), htmlElement, "2"));
  406 + //System.out.println("Pegou: "+htmlElement.getName());
  407 + achou = false;
  408 + }
  409 +
  410 +
  411 +
  412 + /*if(tagId==1)
  413 + tagsH.clear();
  414 + */
  415 +
  416 + /*
337 417 if(tagId > 1)
338 418 for (int i = tagId-1; i >= 1; i--) {
  419 +
  420 +
339 421 Element h = getDocument().getFirstElement("h"+i);
  422 +
  423 +
  424 +
340 425 if(h != null)
341 426 if(this.getRow(getDocument().getFirstElement("h"+i)) > this.getRow(htmlElement)){
  427 +
  428 + //System.out.println("====> verificando: "+h.toString());
342 429 occurrences.add(this.buildOccurrence("1.3", true,htmlElement.toString(), htmlElement, "2"));
343 430 break;
344 431 }
345 432  
346   - }
  433 + }*/
  434 +
  435 + //System.out.println("------------------------------------------------------------------");
347 436 /*
348 437  
349 438 tagsH.add(htmlElement.getName());
... ... @@ -465,15 +554,20 @@ public class MarkEvaluation extends Evaluation {
465 554 }*/
466 555  
467 556  
468   -
  557 + List<Integer> verificadsos = new ArrayList<Integer>();
469 558 for(Element nav : this.getDocument().getAllElements("nav")){
470 559 if(nav !=null){
471 560 int firstNavRow = this.getRow(nav);
472 561  
473 562 for(Element section : this.getDocument().getAllElements("section")){
474 563  
475   - if(firstNavRow < this.getRow(section))
476   - occurrences.add(this.buildOccurrence("1.4", false,section.getStartTag().toString(), section, "1"));
  564 + if(firstNavRow < this.getRow(section)){
  565 + if(!verificadsos.contains(this.getRow(section))){
  566 + occurrences.add(this.buildOccurrence("1.4", false,section.getStartTag().toString(), section, "1"));
  567 + verificadsos.add(this.getRow(section));
  568 + }
  569 +
  570 + }
477 571 }
478 572 }
479 573 }
... ...