Commit 8ad3b91ac9fa8a05e83035cdd16dcb8049be8f1e
1 parent
09d26583
Exists in
master
and in
1 other branch
marcacao
git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%20Web/Fontes/avaliador-api@10365 c2178572-b5ca-4887-91d2-9e3a90c7d55b
Showing
1 changed file
with
39 additions
and
8 deletions
Show diff stats
src/main/java/br/com/checker/emag/core/MarkEvaluation.java
... | ... | @@ -236,10 +236,19 @@ public class MarkEvaluation extends Evaluation { |
236 | 236 | |
237 | 237 | for (String tag : tags) { |
238 | 238 | for (Element element : getDocument().getAllElements(tag)) { |
239 | - if(element.getAttributes().getCount()==0) | |
239 | + /*if(element.getAttributes().getCount()==0) | |
240 | 240 | occurrences.add(this.buildOccurrence("1.2", true, element.toString(), element, "1")); |
241 | - else if(element.getTextExtractor().toString().isEmpty()) | |
241 | + else*/ | |
242 | + if(element.getTextExtractor().toString().isEmpty()) | |
242 | 243 | occurrences.add(this.buildOccurrence("1.2", false, element.toString(), element, "1")); |
244 | + else{ | |
245 | + | |
246 | + Element img = element.getFirstElement("img"); | |
247 | + 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")); | |
250 | + | |
251 | + } | |
243 | 252 | } |
244 | 253 | |
245 | 254 | } |
... | ... | @@ -318,24 +327,44 @@ public class MarkEvaluation extends Evaluation { |
318 | 327 | |
319 | 328 | |
320 | 329 | List<Element> elementsObj = getDocument().getAllElements(); |
321 | - List<String> tagsH = new ArrayList<String>(); | |
322 | - List<Element> elementTag = new ArrayList<Element>(); | |
330 | + //List<String> tagsH = new ArrayList<String>(); | |
331 | + //List<Element> elementTag = new ArrayList<Element>(); | |
323 | 332 | |
324 | 333 | for (Element htmlElement : elementsObj) { |
325 | 334 | if (htmlElement.getName().matches("h[1-6]")) { |
335 | + int tagId = Integer.parseInt(htmlElement.getName().substring(1)); | |
336 | + | |
337 | + if(tagId > 1) | |
338 | + for (int i = tagId-1; i >= 1; i--) { | |
339 | + Element h = getDocument().getFirstElement("h"+i); | |
340 | + if(h != null) | |
341 | + if(this.getRow(getDocument().getFirstElement("h"+i)) > this.getRow(htmlElement)){ | |
342 | + occurrences.add(this.buildOccurrence("1.3", true,htmlElement.toString(), htmlElement, "2")); | |
343 | + break; | |
344 | + } | |
345 | + | |
346 | + } | |
347 | + /* | |
348 | + | |
326 | 349 | tagsH.add(htmlElement.getName()); |
327 | - elementTag.add(htmlElement); | |
350 | + elementTag.add(htmlElement);*/ | |
328 | 351 | } |
329 | 352 | } |
330 | 353 | |
331 | - for (int i = 1; i < tagsH.size(); i++) { | |
354 | + /*for (int i = 1; i < tagsH.size(); i++) { | |
332 | 355 | int atual = Integer.parseInt(tagsH.get(i).substring(1)); |
333 | 356 | int anterior = Integer.parseInt(tagsH.get(i-1).substring(1)); |
334 | 357 | |
358 | + | |
359 | + //if(!tagsH.get(i).toString().equals(tagsH.get(i-1).toString())) | |
360 | + if(anterior > atual) | |
361 | + occurrences.add(this.buildOccurrence("1.3", true,elementTag.get(i).toString(), elementTag.get(i), "2")); | |
362 | + | |
335 | 363 | if(!tagsH.get(i).toString().equals(tagsH.get(i-1).toString())) |
336 | 364 | if(anterior!=(atual-1)) |
337 | 365 | occurrences.add(this.buildOccurrence("1.3", true,elementTag.get(i).toString(), elementTag.get(i), "2")); |
338 | - } | |
366 | + | |
367 | + }*/ | |
339 | 368 | |
340 | 369 | if(!hasH()) |
341 | 370 | occurrences.add(this.buildOccurrence("1.3", true,"Observação - Sem fonte (os níveis de título não foram utilizados)", getDocument().getFirstElement(), "1")); |
... | ... | @@ -440,7 +469,9 @@ public class MarkEvaluation extends Evaluation { |
440 | 469 | for(Element nav : this.getDocument().getAllElements("nav")){ |
441 | 470 | if(nav !=null){ |
442 | 471 | int firstNavRow = this.getRow(nav); |
472 | + | |
443 | 473 | for(Element section : this.getDocument().getAllElements("section")){ |
474 | + | |
444 | 475 | if(firstNavRow < this.getRow(section)) |
445 | 476 | occurrences.add(this.buildOccurrence("1.4", false,section.getStartTag().toString(), section, "1")); |
446 | 477 | } |
... | ... | @@ -542,7 +573,7 @@ public class MarkEvaluation extends Evaluation { |
542 | 573 | |
543 | 574 | String href; |
544 | 575 | boolean existAnchor = false; |
545 | - | |
576 | + | |
546 | 577 | |
547 | 578 | for (Element link : getDocument().getAllElements("a")) { |
548 | 579 | href = link.getAttributeValue("href"); | ... | ... |