Commit 06667d78527dbf4d8b44aab3f491d5f1973f3db9

Authored by lyandro.santana
1 parent ad2f7921

marcação

git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%20Web/Fontes/avaliador-api@10435 c2178572-b5ca-4887-91d2-9e3a90c7d55b
src/main/java/br/com/checker/emag/core/MarkEvaluation.java
@@ -244,27 +244,13 @@ public class MarkEvaluation extends Evaluation { @@ -244,27 +244,13 @@ public class MarkEvaluation extends Evaluation {
244 if(element != null){ 244 if(element != null){
245 Element img = element.getFirstElement("img"); 245 Element img = element.getFirstElement("img");
246 if(img != null){ 246 if(img != null){
247 - if(img.getAttributes().get("alt") != null && img.getAttributes().get("alt").getValue().isEmpty()){ 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")); 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 - } 249 + }else{
  250 + if(element.getContent().toString().isEmpty() || element.getContent().toString().trim().equals(""))
  251 + occurrences.add(this.buildOccurrence("1.2", true, element.getStartTag().toString(), element, "1"));
253 } 252 }
254 } 253 }
255 -  
256 - /*  
257 -  
258 - if(element.getTextExtractor().toString().isEmpty())  
259 - occurrences.add(this.buildOccurrence("1.2", true, element.toString(), element, "1"));  
260 - else{  
261 -  
262 - Element img = element.getFirstElement("img");  
263 - if(img != null)  
264 - if(img.getAttributes().get("alt").getValue().equals("") || img.getAttributeValue("alt").isEmpty())  
265 - occurrences.add(this.buildOccurrence("1.2", true, element.toString(), element, "1"));  
266 -  
267 - }*/  
268 } 254 }
269 255
270 } 256 }
@@ -274,29 +260,15 @@ public class MarkEvaluation extends Evaluation { @@ -274,29 +260,15 @@ public class MarkEvaluation extends Evaluation {
274 260
275 if(element != null){ 261 if(element != null){
276 Element img = element.getFirstElement("img"); 262 Element img = element.getFirstElement("img");
277 -  
278 if(img != null){ 263 if(img != null){
279 -  
280 if(img.getAttributes().get("alt") != null && img.getAttributes().get("alt").getValue().isEmpty()) 264 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")); 265 occurrences.add(this.buildOccurrence("1.2", false, element.getStartTag().toString(), element, "1"));
282 -  
283 }else{ 266 }else{
284 - if(element.getSource().toString().trim().equals("")){ 267 + if(element.getSource().toString().trim().equals(""))
285 occurrences.add(this.buildOccurrence("1.2", false, element.getStartTag().toString(), element, "1")); 268 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 } 269 }
290 } 270 }
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 - }*/ 271 +
300 } 272 }
301 273
302 this.oder(occurrences); 274 this.oder(occurrences);
@@ -368,93 +340,19 @@ public class MarkEvaluation extends Evaluation { @@ -368,93 +340,19 @@ public class MarkEvaluation extends Evaluation {
368 340
369 341
370 List<Element> elementsObj = getDocument().getAllElements(); 342 List<Element> elementsObj = getDocument().getAllElements();
371 - //List<String> tagsH = new ArrayList<String>();  
372 - //List<Element> elementTag = new ArrayList<Element>();  
373 -  
374 - boolean achou = false;  
375 - int limhaMinima= 0;  
376 343
  344 + int anterior = 1;
377 for (Element htmlElement : elementsObj) { 345 for (Element htmlElement : elementsObj) {
378 if (htmlElement.getName().matches("h[1-6]")) { 346 if (htmlElement.getName().matches("h[1-6]")) {
379 int tagId = Integer.parseInt(htmlElement.getName().substring(1)); 347 int tagId = Integer.parseInt(htmlElement.getName().substring(1));
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 - /*  
417 - if(tagId > 1)  
418 - for (int i = tagId-1; i >= 1; i--) {  
419 -  
420 -  
421 - Element h = getDocument().getFirstElement("h"+i);  
422 -  
423 -  
424 -  
425 - if(h != null)  
426 - if(this.getRow(getDocument().getFirstElement("h"+i)) > this.getRow(htmlElement)){  
427 -  
428 - //System.out.println("====> verificando: "+h.toString()); 348 + if(!(tagId <= anterior)){
  349 + if(!(tagId == anterior+1))
429 occurrences.add(this.buildOccurrence("1.3", true,htmlElement.toString(), htmlElement, "2")); 350 occurrences.add(this.buildOccurrence("1.3", true,htmlElement.toString(), htmlElement, "2"));
430 - break;  
431 - }  
432 -  
433 - }*/  
434 -  
435 - //System.out.println("------------------------------------------------------------------");  
436 - /*  
437 -  
438 - tagsH.add(htmlElement.getName());  
439 - elementTag.add(htmlElement);*/ 351 + }
  352 + anterior = tagId;
440 } 353 }
441 } 354 }
442 355
443 - /*for (int i = 1; i < tagsH.size(); i++) {  
444 - int atual = Integer.parseInt(tagsH.get(i).substring(1));  
445 - int anterior = Integer.parseInt(tagsH.get(i-1).substring(1));  
446 -  
447 -  
448 - //if(!tagsH.get(i).toString().equals(tagsH.get(i-1).toString()))  
449 - if(anterior > atual)  
450 - occurrences.add(this.buildOccurrence("1.3", true,elementTag.get(i).toString(), elementTag.get(i), "2"));  
451 -  
452 - if(!tagsH.get(i).toString().equals(tagsH.get(i-1).toString()))  
453 - if(anterior!=(atual-1))  
454 - occurrences.add(this.buildOccurrence("1.3", true,elementTag.get(i).toString(), elementTag.get(i), "2"));  
455 -  
456 - }*/  
457 -  
458 if(!hasH()) 356 if(!hasH())
459 occurrences.add(this.buildOccurrence("1.3", true,"Observa&ccedil;&atilde;o - Sem fonte (os n&iacute;veis de t&iacute;tulo n&atilde;o foram utilizados)", getDocument().getFirstElement(), "1")); 357 occurrences.add(this.buildOccurrence("1.3", true,"Observa&ccedil;&atilde;o - Sem fonte (os n&iacute;veis de t&iacute;tulo n&atilde;o foram utilizados)", getDocument().getFirstElement(), "1"));
460 358
@@ -719,13 +617,7 @@ public class MarkEvaluation extends Evaluation { @@ -719,13 +617,7 @@ public class MarkEvaluation extends Evaluation {
719 occurrences.add(this.buildOccurrence("1.5", false, elemento.toString(), elemento,"5")); 617 occurrences.add(this.buildOccurrence("1.5", false, elemento.toString(), elemento,"5"));
720 } 618 }
721 619
722 -  
723 - //Sorting  
724 - Collections.sort(occurrences, new Comparator<Occurrence>() {  
725 - public int compare(Occurrence occurrence1, Occurrence occurrence2){  
726 - return occurrence1.getLine().compareTo(occurrence2.getLine());  
727 - }  
728 - }); 620 + this.oder(occurrences);
729 621
730 return occurrences; 622 return occurrences;
731 } 623 }