Rev 1814 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1814 | Rev 1827 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.services.assessments; |
1 | package pt.estgp.estgweb.services.assessments; |
2 | 2 | ||
3 | import com.itextpdf.text.*; |
3 | import com.itextpdf.text.*; |
4 | import com.itextpdf.text.Image; |
4 | import com.itextpdf.text.Image; |
5 | import com.itextpdf.text.pdf.PdfPCell; |
5 | import com.itextpdf.text.pdf.PdfPCell; |
6 | import com.itextpdf.text.pdf.PdfPTable; |
6 | import com.itextpdf.text.pdf.PdfPTable; |
7 | import com.itextpdf.text.pdf.PdfWriter; |
7 | import com.itextpdf.text.pdf.PdfWriter; |
8 | import com.itextpdf.text.pdf.draw.LineSeparator; |
8 | import com.itextpdf.text.pdf.draw.LineSeparator; |
9 | import jomm.utils.FilesUtils; |
9 | import jomm.utils.FilesUtils; |
10 | import org.apache.log4j.Logger; |
10 | import org.apache.log4j.Logger; |
- | 11 | import pt.estgp.estgweb.utils.DatesUtils; |
|
11 | import pt.estgp.estgweb.utils.Globals; |
12 | import pt.estgp.estgweb.utils.Globals; |
12 | import pt.estgp.estgweb.domain.*; |
13 | import pt.estgp.estgweb.domain.*; |
13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
14 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
14 | import pt.estgp.estgweb.domain.views.AssessmentView; |
15 | import pt.estgp.estgweb.domain.views.AssessmentView; |
15 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
16 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
16 | import pt.estgp.estgweb.services.data.RepositoryService; |
17 | import pt.estgp.estgweb.services.data.RepositoryService; |
17 | import pt.estgp.estgweb.utils.DatesWebUtils; |
18 | import pt.estgp.estgweb.utils.DatesWebUtils; |
18 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
19 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
19 | 20 | ||
20 | import java.io.*; |
21 | import java.io.*; |
21 | import java.util.List; |
22 | import java.util.List; |
22 | 23 | ||
23 | /** |
24 | /** |
24 | * Created by IntelliJ IDEA. |
25 | * Created by IntelliJ IDEA. |
25 | * User: Filipe Matos |
26 | * User: Filipe Matos |
26 | * Date: 6/Ago/2013 |
27 | * Date: 6/Ago/2013 |
27 | * Time: 2:20:23 |
28 | * Time: 2:20:23 |
28 | * To change this template use File | Settings | File Templates. |
29 | * To change this template use File | Settings | File Templates. |
29 | */ |
30 | */ |
30 | public class GeneratePdfService implements IService { |
31 | public class GeneratePdfService implements IService { |
31 | 32 | ||
32 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(GeneratePdfService.class); |
33 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(GeneratePdfService.class); |
33 | 34 | ||
34 | private RepositoryService repositoryService = new RepositoryService(); |
35 | private RepositoryService repositoryService = new RepositoryService(); |
35 | 36 | ||
36 | public void generateAssessmentPdf(long assessmentId,UserSession userSession) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException { |
37 | public void generateAssessmentPdf(long assessmentId,UserSession userSession) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException { |
37 | Assessment assessment = DaoFactory.getAssessmentDaoImpl().get(assessmentId); |
38 | Assessment assessment = DaoFactory.getAssessmentDaoImpl().get(assessmentId); |
38 | //////////////////////////////////////////////// |
39 | //////////////////////////////////////////////// |
39 | 5+0%2Fdocs%2Fapi+Document">Document doc = null; |
40 | 5+0%2Fdocs%2Fapi+Document">Document doc = null; |
40 | 5+0%2Fdocs%2Fapi+OutputStream">OutputStream os = null; |
41 | 5+0%2Fdocs%2Fapi+OutputStream">OutputStream os = null; |
41 | 42 | ||
42 | try { |
43 | try { |
43 | //cria o documento tamanho A4, margens de 2,54cm |
44 | //cria o documento tamanho A4, margens de 2,54cm |
44 | doc = new 5+0%2Fdocs%2Fapi+Document">Document(PageSize.A4, 72, 72, 72, 72); |
45 | doc = new 5+0%2Fdocs%2Fapi+Document">Document(PageSize.A4, 72, 72, 72, 72); |
45 | //cria a stream de sa�da |
46 | //cria a stream de sa�da |
46 | os = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(Globals.TMP_DIR+"Enunciado"+assessment.getTitle()+".pdf"); |
47 | os = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(Globals.TMP_DIR+"Enunciado"+assessment.getTitle()+".pdf"); |
47 | //associa a stream de sa�da ao |
48 | //associa a stream de sa�da ao |
48 | PdfWriter.getInstance(doc, os); |
49 | PdfWriter.getInstance(doc, os); |
49 | //abre o documento |
50 | //abre o documento |
50 | doc.open(); |
51 | doc.open(); |
51 | //imagem do cabe�alho |
52 | //imagem do cabe�alho |
52 | 1.5.0/docs/api/java/awt/Image.html">Image img = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/logoestg.gif"); |
53 | 1.5.0/docs/api/java/awt/Image.html">Image img = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/logoestg.gif"); |
53 | img.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
54 | img.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
54 | doc.add(img); |
55 | doc.add(img); |
55 | 56 | ||
56 | //paragrafo em branco |
57 | //paragrafo em branco |
57 | doc.add(new Phrase(" ")); |
58 | doc.add(new Phrase(" ")); |
58 | 59 | ||
59 | //fonts |
60 | //fonts |
60 | //primeira linha para o caracteres especiais |
61 | //primeira linha para o caracteres especiais |
61 | // BaseFont specialCharacter = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); |
62 | // BaseFont specialCharacter = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); |
62 | 1.5.0/docs/api/java/awt/Font.html">Font fontHeader = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,14,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
63 | 1.5.0/docs/api/java/awt/Font.html">Font fontHeader = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,14,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
63 | 1.5.0/docs/api/java/awt/Font.html">Font fontBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
64 | 1.5.0/docs/api/java/awt/Font.html">Font fontBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
64 | 1.5.0/docs/api/java/awt/Font.html">Font fontNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
65 | 1.5.0/docs/api/java/awt/Font.html">Font fontNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
65 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
66 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
66 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
67 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
67 | 68 | ||
68 | 69 | ||
69 | //cabe�alho |
70 | //cabe�alho |
70 | //unidade curricular |
71 | //unidade curricular |
71 | Paragraph courseUnit = new Paragraph(assessment.getCourseUnit().getName(),fontHeader); |
72 | Paragraph courseUnit = new Paragraph(assessment.getCourseUnit().getName(),fontHeader); |
72 | courseUnit.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
73 | courseUnit.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
73 | doc.add(courseUnit); |
74 | doc.add(courseUnit); |
74 | 75 | ||
75 | //primeira linha cabe�alho |
76 | //primeira linha cabe�alho |
76 | 1.5.0/docs/api/java/lang/String.html">String evaluationTime = ""; |
77 | 1.5.0/docs/api/java/lang/String.html">String evaluationTime = ""; |
77 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_CONTINUOUS)) |
78 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_CONTINUOUS)) |
78 | evaluationTime="Avalia��o Cont�nua"; |
79 | evaluationTime="Avalia��o Cont�nua"; |
79 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_FIRSTEXAM)) |
80 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_FIRSTEXAM)) |
80 | evaluationTime="Exame Normal"; |
81 | evaluationTime="Exame Normal"; |
81 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_SECONDEXAM)) |
82 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_SECONDEXAM)) |
82 | evaluationTime="Exame Recurso"; |
83 | evaluationTime="Exame Recurso"; |
83 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_THIRDEXAM)) |
84 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_THIRDEXAM)) |
84 | evaluationTime="Exame Especial"; |
85 | evaluationTime="Exame Especial"; |
85 | 86 | ||
86 | 1.5.0/docs/api/java/lang/String.html">String yearText = " - Ano lectivo"; |
87 | 1.5.0/docs/api/java/lang/String.html">String yearText = " - Ano lectivo"; |
87 | 1.5.0/docs/api/java/lang/String.html">String year = " - "+assessment.getYear(); |
88 | 1.5.0/docs/api/java/lang/String.html">String year = " - "+assessment.getYear(); |
88 | 1.5.0/docs/api/java/lang/String.html">String course = " - "+assessment.getCourseUnit().getCourseName(); |
89 | 1.5.0/docs/api/java/lang/String.html">String course = " - "+assessment.getCourseUnit().getCourseName(); |
89 | Paragraph firstLine = new Paragraph(); |
90 | Paragraph firstLine = new Paragraph(); |
90 | firstLine.add(new Chunk(evaluationTime,fontBold)); |
91 | firstLine.add(new Chunk(evaluationTime,fontBold)); |
91 | firstLine.add(new Chunk(yearText,fontNormal)); |
92 | firstLine.add(new Chunk(yearText,fontNormal)); |
92 | firstLine.add(new Chunk(year,fontNormal)); |
93 | firstLine.add(new Chunk(year,fontNormal)); |
93 | firstLine.add(new Chunk(course,fontNormal)); |
94 | firstLine.add(new Chunk(course,fontNormal)); |
94 | firstLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
95 | firstLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
95 | doc.add(firstLine); |
96 | doc.add(firstLine); |
96 | 97 | ||
97 | //segunda linha cabe�alho |
98 | //segunda linha cabe�alho |
98 | 1.5.0/docs/api/java/lang/String.html">String dateText = "Data:"; |
99 | 1.5.0/docs/api/java/lang/String.html">String dateText = "Data:"; |
99 | 1.5.0/docs/api/java/lang/String.html">String date = " "+ DatesWebUtils.getStringFromDate(assessment.getStartDate()); |
100 | 1.5.0/docs/api/java/lang/String.html">String date = " "+ DatesWebUtils.getStringFromDate(assessment.getStartDate()); |
100 | 1.5.0/docs/api/java/lang/String.html">String timeText = " - Dura��o:"; |
101 | 1.5.0/docs/api/java/lang/String.html">String timeText = " - Dura��o:"; |
101 | 1.5.0/docs/api/java/lang/String.html">String time = " "+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessment.getTime().getHours())+":"+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessment.getTime().getMinutes()); |
102 | 1.5.0/docs/api/java/lang/String.html">String time = " "+1.5.0/docs/api/java/lang/String.html">String.valueOf(DatesUtils.getHours(assessment.getTime()))+":"+1.5.0/docs/api/java/lang/String.html">String.valueOf(DatesUtils.getMinutes(assessment.getTime())); |
102 | 1.5.0/docs/api/java/lang/String.html">String ownerText = " - Docente:"; |
103 | 1.5.0/docs/api/java/lang/String.html">String ownerText = " - Docente:"; |
103 | 1.5.0/docs/api/java/lang/String.html">String owner = " "+assessment.getOwner().getName(); |
104 | 1.5.0/docs/api/java/lang/String.html">String owner = " "+assessment.getOwner().getName(); |
104 | Paragraph secondLine = new Paragraph(); |
105 | Paragraph secondLine = new Paragraph(); |
105 | secondLine.add(new Chunk(dateText,fontBold)); |
106 | secondLine.add(new Chunk(dateText,fontBold)); |
106 | secondLine.add(new Chunk(date,fontNormal)); |
107 | secondLine.add(new Chunk(date,fontNormal)); |
107 | secondLine.add(new Chunk(timeText,fontBold)); |
108 | secondLine.add(new Chunk(timeText,fontBold)); |
108 | secondLine.add(new Chunk(time,fontNormal)); |
109 | secondLine.add(new Chunk(time,fontNormal)); |
109 | secondLine.add(new Chunk(ownerText,fontBold)); |
110 | secondLine.add(new Chunk(ownerText,fontBold)); |
110 | secondLine.add(new Chunk(owner,fontNormal)); |
111 | secondLine.add(new Chunk(owner,fontNormal)); |
111 | secondLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
112 | secondLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
112 | doc.add(secondLine); |
113 | doc.add(secondLine); |
113 | 114 | ||
114 | //paragrafo em branco |
115 | //paragrafo em branco |
115 | //doc.add(new Paragraph("Barra pah",fontNormal)); |
116 | //doc.add(new Paragraph("Barra pah",fontNormal)); |
116 | doc.add(Chunk.NEWLINE); |
117 | doc.add(Chunk.NEWLINE); |
117 | //Barra horizontal |
118 | //Barra horizontal |
118 | LineSeparator objectName = new LineSeparator(); |
119 | LineSeparator objectName = new LineSeparator(); |
119 | doc.add(objectName); |
120 | doc.add(objectName); |
120 | doc.add(Chunk.NEWLINE); |
121 | doc.add(Chunk.NEWLINE); |
121 | 122 | ||
122 | //quest�es |
123 | //quest�es |
123 | int numberQ=0; |
124 | int numberQ=0; |
124 | for(AssessmentQuestion question : assessment.getQuestions()) |
125 | for(AssessmentQuestion question : assessment.getQuestions()) |
125 | { |
126 | { |
126 | numberQ++; |
127 | numberQ++; |
127 | 1.5.0/docs/api/java/lang/String.html">String numberQuotation = 1.5.0/docs/api/java/lang/String.html">String.valueOf(numberQ) + ". ("+1.5.0/docs/api/java/lang/String.html">String.valueOf(question.getQuotation())+") "; |
128 | 1.5.0/docs/api/java/lang/String.html">String numberQuotation = 1.5.0/docs/api/java/lang/String.html">String.valueOf(numberQ) + ". ("+1.5.0/docs/api/java/lang/String.html">String.valueOf(question.getQuotation())+") "; |
128 | 1.5.0/docs/api/java/lang/String.html">String questionText = question.getTextpt(); |
129 | 1.5.0/docs/api/java/lang/String.html">String questionText = question.getTextpt(); |
129 | Paragraph questionP = new Paragraph(); |
130 | Paragraph questionP = new Paragraph(); |
130 | questionP.add(new Chunk(numberQuotation,fontTextBold)); |
131 | questionP.add(new Chunk(numberQuotation,fontTextBold)); |
131 | questionP.add(new Chunk(questionText,fontTextNormal)); |
132 | questionP.add(new Chunk(questionText,fontTextNormal)); |
132 | questionP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
133 | questionP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
133 | doc.add(questionP); |
134 | doc.add(questionP); |
134 | if(question.getImage()!=null) |
135 | if(question.getImage()!=null) |
135 | { |
136 | { |
136 | 1.5.0/docs/api/java/awt/Image.html">Image image = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imageStream/"+question.getImage().getId()); |
137 | 1.5.0/docs/api/java/awt/Image.html">Image image = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imageStream/"+question.getImage().getId()); |
137 | image.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
138 | image.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
138 | doc.add(image); |
139 | doc.add(image); |
139 | } |
140 | } |
140 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO) || question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_CHECK)) |
141 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO) || question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_CHECK)) |
141 | { |
142 | { |
142 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
143 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
143 | { |
144 | { |
144 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
145 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
145 | { |
146 | { |
146 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa=null; |
147 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa=null; |
147 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO)) |
148 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO)) |
148 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
149 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
149 | else |
150 | else |
150 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/checkbox.png"); |
151 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/checkbox.png"); |
151 | imagePa.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.PARAGRAPH); |
152 | imagePa.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.PARAGRAPH); |
152 | Paragraph pAP = new Paragraph(); |
153 | Paragraph pAP = new Paragraph(); |
153 | pAP.add(new Chunk(imagePa, -1.00f, -2.00f)); |
154 | pAP.add(new Chunk(imagePa, -1.00f, -2.00f)); |
154 | pAP.add(new Chunk(" "+pA.getTextpt(),fontTextNormal)); |
155 | pAP.add(new Chunk(" "+pA.getTextpt(),fontTextNormal)); |
155 | pAP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
156 | pAP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
156 | doc.add(pAP); |
157 | doc.add(pAP); |
157 | } |
158 | } |
158 | } |
159 | } |
159 | } |
160 | } |
160 | 161 | ||
161 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_MATRIX)) |
162 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_MATRIX)) |
162 | { |
163 | { |
163 | PdfPTable table = null; |
164 | PdfPTable table = null; |
164 | int numPossibles=0; |
165 | int numPossibles=0; |
165 | //construir tabela |
166 | //construir tabela |
166 | //para saber o numero de respostas possiveis |
167 | //para saber o numero de respostas possiveis |
167 | for(AssessmentQuestionItem itemTam : question.getQuestionItems()) |
168 | for(AssessmentQuestionItem itemTam : question.getQuestionItems()) |
168 | { |
169 | { |
169 | numPossibles = itemTam.getPossibleAnswers().size()+1; |
170 | numPossibles = itemTam.getPossibleAnswers().size()+1; |
170 | table = new PdfPTable(numPossibles); |
171 | table = new PdfPTable(numPossibles); |
171 | PdfPCell colunaVazia = new PdfPCell(new Paragraph()); |
172 | PdfPCell colunaVazia = new PdfPCell(new Paragraph()); |
172 | colunaVazia.setBorder(0); |
173 | colunaVazia.setBorder(0); |
173 | table.addCell(colunaVazia); |
174 | table.addCell(colunaVazia); |
174 | for(AssessmentQuestionPossibleAnswer possibleTam : itemTam.getPossibleAnswers()) |
175 | for(AssessmentQuestionPossibleAnswer possibleTam : itemTam.getPossibleAnswers()) |
175 | { |
176 | { |
176 | PdfPCell possible = new PdfPCell(new Paragraph(possibleTam.getTextpt(),fontTextNormal)); |
177 | PdfPCell possible = new PdfPCell(new Paragraph(possibleTam.getTextpt(),fontTextNormal)); |
177 | possible.setBorder(0); |
178 | possible.setBorder(0); |
178 | table.addCell(possible); |
179 | table.addCell(possible); |
179 | } |
180 | } |
180 | break; |
181 | break; |
181 | } |
182 | } |
182 | 183 | ||
183 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
184 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
184 | { |
185 | { |
185 | PdfPCell item1 = new PdfPCell(new Paragraph(item.getTextpt(),fontTextNormal)); |
186 | PdfPCell item1 = new PdfPCell(new Paragraph(item.getTextpt(),fontTextNormal)); |
186 | item1.setBorder(0); |
187 | item1.setBorder(0); |
187 | table.addCell(item1); |
188 | table.addCell(item1); |
188 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
189 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
189 | { |
190 | { |
190 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa= 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
191 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa= 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
191 | PdfPCell imageCell = new PdfPCell(imagePa); |
192 | PdfPCell imageCell = new PdfPCell(imagePa); |
192 | imageCell.setBorder(0); |
193 | imageCell.setBorder(0); |
193 | table.addCell(imageCell); |
194 | table.addCell(imageCell); |
194 | } |
195 | } |
195 | } |
196 | } |
196 | float splitWidth = 1.0f / (float)numPossibles; |
197 | float splitWidth = 1.0f / (float)numPossibles; |
197 | float[] tams = new float[numPossibles]; |
198 | float[] tams = new float[numPossibles]; |
198 | for(int i=0;i<numPossibles;i++) |
199 | for(int i=0;i<numPossibles;i++) |
199 | { |
200 | { |
200 | tams[i] = splitWidth; |
201 | tams[i] = splitWidth; |
201 | } |
202 | } |
202 | table.setWidths(tams); |
203 | table.setWidths(tams); |
203 | table.setWidthPercentage(100.0f); |
204 | table.setWidthPercentage(100.0f); |
204 | doc.add(table); |
205 | doc.add(table); |
205 | } |
206 | } |
206 | doc.add(Chunk.NEWLINE); |
207 | doc.add(Chunk.NEWLINE); |
207 | } |
208 | } |
208 | 209 | ||
209 | } finally { |
210 | } finally { |
210 | if (doc != null) { |
211 | if (doc != null) { |
211 | //fechamento do documento |
212 | //fechamento do documento |
212 | doc.close(); |
213 | doc.close(); |
213 | } |
214 | } |
214 | if (os != null) { |
215 | if (os != null) { |
215 | //fechamento da stream de sa�da |
216 | //fechamento da stream de sa�da |
216 | os.close(); |
217 | os.close(); |
217 | } |
218 | } |
218 | } |
219 | } |
219 | 220 | ||
220 | //repositoryStream |
221 | //repositoryStream |
221 | 1.5.0/docs/api/java/lang/String.html">String fileName = Globals.TMP_DIR+"Enunciado"+assessment.getTitle()+".pdf"; |
222 | 1.5.0/docs/api/java/lang/String.html">String fileName = Globals.TMP_DIR+"Enunciado"+assessment.getTitle()+".pdf"; |
222 | 1.5.0/docs/api/java/io/File.html">File file = new 1.5.0/docs/api/java/io/File.html">File(fileName); |
223 | 1.5.0/docs/api/java/io/File.html">File file = new 1.5.0/docs/api/java/io/File.html">File(fileName); |
223 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(fileName); |
224 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(fileName); |
224 | 1.5.0/docs/api/java/lang/String.html">String description = "assessment.file "+assessment.getCourseUnit().getName(); |
225 | 1.5.0/docs/api/java/lang/String.html">String description = "assessment.file "+assessment.getCourseUnit().getName(); |
225 | 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream inputStream = new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(file); |
226 | 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream inputStream = new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(file); |
226 | 1.5.0/docs/api/java/lang/String.html">String identifier = assessment.getIdentifier(); |
227 | 1.5.0/docs/api/java/lang/String.html">String identifier = assessment.getIdentifier(); |
227 | 228 | ||
228 | if(identifier==null) |
229 | if(identifier==null) |
229 | identifier = repositoryService.storeRepositoryFile(inputStream,"application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain, null, userSession); |
230 | identifier = repositoryService.storeRepositoryFile(inputStream,"application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain, null, userSession); |
230 | else |
231 | else |
231 | repositoryService.updateRepositoryFile(identifier,inputStream, "application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain); |
232 | repositoryService.updateRepositoryFile(identifier,inputStream, "application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain); |
232 | 233 | ||
233 | assessment.setIdentifier(identifier); |
234 | assessment.setIdentifier(identifier); |
234 | 235 | ||
235 | // return new AssessmentView(assessment); |
236 | // return new AssessmentView(assessment); |
236 | } |
237 | } |
237 | 238 | ||
238 | public void generateAssessmentResponsePdf(long assessmentResponseId,long assessmentId,UserSession userSession) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException { |
239 | public void generateAssessmentResponsePdf(long assessmentResponseId,long assessmentId,UserSession userSession) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException { |
239 | AssessmentResponse assessmentResponse = DaoFactory.getAssessmentResponseDaoImpl().get(assessmentResponseId); |
240 | AssessmentResponse assessmentResponse = DaoFactory.getAssessmentResponseDaoImpl().get(assessmentResponseId); |
240 | Assessment assessment = DaoFactory.getAssessmentDaoImpl().get(assessmentId); |
241 | Assessment assessment = DaoFactory.getAssessmentDaoImpl().get(assessmentId); |
241 | //////////////////////////////////////////////// |
242 | //////////////////////////////////////////////// |
242 | 5+0%2Fdocs%2Fapi+Document">Document doc = null; |
243 | 5+0%2Fdocs%2Fapi+Document">Document doc = null; |
243 | 5+0%2Fdocs%2Fapi+OutputStream">OutputStream os = null; |
244 | 5+0%2Fdocs%2Fapi+OutputStream">OutputStream os = null; |
244 | 245 | ||
245 | try { |
246 | try { |
246 | //cria o documento tamanho A4, margens de 2,54cm |
247 | //cria o documento tamanho A4, margens de 2,54cm |
247 | doc = new 5+0%2Fdocs%2Fapi+Document">Document(PageSize.A4, 72, 72, 72, 72); |
248 | doc = new 5+0%2Fdocs%2Fapi+Document">Document(PageSize.A4, 72, 72, 72, 72); |
248 | //cria a stream de sa�da |
249 | //cria a stream de sa�da |
249 | os = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(Globals.TMP_DIR+"Resposta"+assessment.getTitle()+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessmentResponse.getId())+".pdf"); |
250 | os = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(Globals.TMP_DIR+"Resposta"+assessment.getTitle()+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessmentResponse.getId())+".pdf"); |
250 | //associa a stream de sa�da ao |
251 | //associa a stream de sa�da ao |
251 | PdfWriter.getInstance(doc, os); |
252 | PdfWriter.getInstance(doc, os); |
252 | //abre o documento |
253 | //abre o documento |
253 | doc.open(); |
254 | doc.open(); |
254 | //imagem do cabe�alho |
255 | //imagem do cabe�alho |
255 | 1.5.0/docs/api/java/awt/Image.html">Image img = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/logoestg.gif"); |
256 | 1.5.0/docs/api/java/awt/Image.html">Image img = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/logoestg.gif"); |
256 | img.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
257 | img.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
257 | doc.add(img); |
258 | doc.add(img); |
258 | 259 | ||
259 | //paragrafo em branco |
260 | //paragrafo em branco |
260 | doc.add(new Phrase(" ")); |
261 | doc.add(new Phrase(" ")); |
261 | 262 | ||
262 | //fonts |
263 | //fonts |
263 | //primeira linha para o caracteres especiais |
264 | //primeira linha para o caracteres especiais |
264 | // BaseFont specialCharacter = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); |
265 | // BaseFont specialCharacter = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); |
265 | 1.5.0/docs/api/java/awt/Font.html">Font fontHeader = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,14,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
266 | 1.5.0/docs/api/java/awt/Font.html">Font fontHeader = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,14,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
266 | 1.5.0/docs/api/java/awt/Font.html">Font fontBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
267 | 1.5.0/docs/api/java/awt/Font.html">Font fontBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
267 | 1.5.0/docs/api/java/awt/Font.html">Font fontNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
268 | 1.5.0/docs/api/java/awt/Font.html">Font fontNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
268 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
269 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextBold = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
269 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
270 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextNormal = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
270 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextEvaluate = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL,BaseColor.RED); |
271 | 1.5.0/docs/api/java/awt/Font.html">Font fontTextEvaluate = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,12,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL,BaseColor.RED); |
271 | 272 | ||
272 | 273 | ||
273 | //cabe�alho |
274 | //cabe�alho |
274 | //unidade curricular |
275 | //unidade curricular |
275 | Paragraph courseUnit = new Paragraph(assessment.getCourseUnit().getName(),fontHeader); |
276 | Paragraph courseUnit = new Paragraph(assessment.getCourseUnit().getName(),fontHeader); |
276 | courseUnit.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
277 | courseUnit.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
277 | doc.add(courseUnit); |
278 | doc.add(courseUnit); |
278 | 279 | ||
279 | //primeira linha cabe�alho |
280 | //primeira linha cabe�alho |
280 | 1.5.0/docs/api/java/lang/String.html">String evaluationTime = ""; |
281 | 1.5.0/docs/api/java/lang/String.html">String evaluationTime = ""; |
281 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_CONTINUOUS)) |
282 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_CONTINUOUS)) |
282 | evaluationTime="Avalia��o Cont�nua"; |
283 | evaluationTime="Avalia��o Cont�nua"; |
283 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_FIRSTEXAM)) |
284 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_FIRSTEXAM)) |
284 | evaluationTime="Exame Normal"; |
285 | evaluationTime="Exame Normal"; |
285 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_SECONDEXAM)) |
286 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_SECONDEXAM)) |
286 | evaluationTime="Exame Recurso"; |
287 | evaluationTime="Exame Recurso"; |
287 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_THIRDEXAM)) |
288 | if(assessment.getEvaluationTime().equals(Globals.ASSESSMENT_EVALUATION_TIME_THIRDEXAM)) |
288 | evaluationTime="Exame Especial"; |
289 | evaluationTime="Exame Especial"; |
289 | 290 | ||
290 | 1.5.0/docs/api/java/lang/String.html">String yearText = " - Ano lectivo"; |
291 | 1.5.0/docs/api/java/lang/String.html">String yearText = " - Ano lectivo"; |
291 | 1.5.0/docs/api/java/lang/String.html">String year = " - "+assessment.getYear(); |
292 | 1.5.0/docs/api/java/lang/String.html">String year = " - "+assessment.getYear(); |
292 | 1.5.0/docs/api/java/lang/String.html">String course = " - "+assessment.getCourseUnit().getCourseName(); |
293 | 1.5.0/docs/api/java/lang/String.html">String course = " - "+assessment.getCourseUnit().getCourseName(); |
293 | Paragraph firstLine = new Paragraph(); |
294 | Paragraph firstLine = new Paragraph(); |
294 | firstLine.add(new Chunk(evaluationTime,fontBold)); |
295 | firstLine.add(new Chunk(evaluationTime,fontBold)); |
295 | firstLine.add(new Chunk(yearText,fontNormal)); |
296 | firstLine.add(new Chunk(yearText,fontNormal)); |
296 | firstLine.add(new Chunk(year,fontNormal)); |
297 | firstLine.add(new Chunk(year,fontNormal)); |
297 | firstLine.add(new Chunk(course,fontNormal)); |
298 | firstLine.add(new Chunk(course,fontNormal)); |
298 | firstLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
299 | firstLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
299 | doc.add(firstLine); |
300 | doc.add(firstLine); |
300 | 301 | ||
301 | //segunda linha cabe�alho |
302 | //segunda linha cabe�alho |
302 | 1.5.0/docs/api/java/lang/String.html">String dateText = "Data:"; |
303 | 1.5.0/docs/api/java/lang/String.html">String dateText = "Data:"; |
303 | 1.5.0/docs/api/java/lang/String.html">String date = " "+ DatesWebUtils.getStringFromDate(assessment.getStartDate()); |
304 | 1.5.0/docs/api/java/lang/String.html">String date = " "+ DatesWebUtils.getStringFromDate(assessment.getStartDate()); |
304 | 1.5.0/docs/api/java/lang/String.html">String timeText = " - Dura��o:"; |
305 | 1.5.0/docs/api/java/lang/String.html">String timeText = " - Dura��o:"; |
305 | 1.5.0/docs/api/java/lang/String.html">String time = " "+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessment.getTime().getHours())+":"+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessment.getTime().getMinutes()); |
306 | 1.5.0/docs/api/java/lang/String.html">String time = " "+1.5.0/docs/api/java/lang/String.html">String.valueOf(DatesUtils.getHours(assessment.getTime()))+":"+1.5.0/docs/api/java/lang/String.html">String.valueOf(DatesUtils.getMinutes(assessment.getTime())); |
306 | 1.5.0/docs/api/java/lang/String.html">String ownerText = " - Docente:"; |
307 | 1.5.0/docs/api/java/lang/String.html">String ownerText = " - Docente:"; |
307 | 1.5.0/docs/api/java/lang/String.html">String owner = " "+assessment.getOwner().getName(); |
308 | 1.5.0/docs/api/java/lang/String.html">String owner = " "+assessment.getOwner().getName(); |
308 | 1.5.0/docs/api/java/lang/String.html">String quotationText = " - Nota:"; |
309 | 1.5.0/docs/api/java/lang/String.html">String quotationText = " - Nota:"; |
309 | 1.5.0/docs/api/java/lang/String.html">String quotation = " "+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessmentResponse.getQuotation()); |
310 | 1.5.0/docs/api/java/lang/String.html">String quotation = " "+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessmentResponse.getQuotation()); |
310 | Paragraph secondLine = new Paragraph(); |
311 | Paragraph secondLine = new Paragraph(); |
311 | secondLine.add(new Chunk(dateText,fontBold)); |
312 | secondLine.add(new Chunk(dateText,fontBold)); |
312 | secondLine.add(new Chunk(date,fontNormal)); |
313 | secondLine.add(new Chunk(date,fontNormal)); |
313 | secondLine.add(new Chunk(timeText,fontBold)); |
314 | secondLine.add(new Chunk(timeText,fontBold)); |
314 | secondLine.add(new Chunk(time,fontNormal)); |
315 | secondLine.add(new Chunk(time,fontNormal)); |
315 | secondLine.add(new Chunk(ownerText,fontBold)); |
316 | secondLine.add(new Chunk(ownerText,fontBold)); |
316 | secondLine.add(new Chunk(owner,fontNormal)); |
317 | secondLine.add(new Chunk(owner,fontNormal)); |
317 | if(assessmentResponse.isEvaluated()) |
318 | if(assessmentResponse.isEvaluated()) |
318 | { |
319 | { |
319 | secondLine.add(new Chunk(quotationText,fontBold)); |
320 | secondLine.add(new Chunk(quotationText,fontBold)); |
320 | secondLine.add(new Chunk(quotation,fontNormal)); |
321 | secondLine.add(new Chunk(quotation,fontNormal)); |
321 | } |
322 | } |
322 | secondLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
323 | secondLine.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_CENTER); |
323 | doc.add(secondLine); |
324 | doc.add(secondLine); |
324 | 325 | ||
325 | //paragrafo em branco |
326 | //paragrafo em branco |
326 | //doc.add(new Paragraph("Barra pah",fontNormal)); |
327 | //doc.add(new Paragraph("Barra pah",fontNormal)); |
327 | doc.add(Chunk.NEWLINE); |
328 | doc.add(Chunk.NEWLINE); |
328 | //Barra horizontal |
329 | //Barra horizontal |
329 | LineSeparator objectName = new LineSeparator(); |
330 | LineSeparator objectName = new LineSeparator(); |
330 | doc.add(objectName); |
331 | doc.add(objectName); |
331 | doc.add(Chunk.NEWLINE); |
332 | doc.add(Chunk.NEWLINE); |
332 | 333 | ||
333 | //quest�es |
334 | //quest�es |
334 | int numberQ=0; |
335 | int numberQ=0; |
335 | for(AssessmentQuestion question : assessment.getQuestions()) |
336 | for(AssessmentQuestion question : assessment.getQuestions()) |
336 | { |
337 | { |
337 | numberQ++; |
338 | numberQ++; |
338 | 1.5.0/docs/api/java/lang/String.html">String numberQuotation = 1.5.0/docs/api/java/lang/String.html">String.valueOf(numberQ) + ". ("+1.5.0/docs/api/java/lang/String.html">String.valueOf(question.getQuotation())+") "; |
339 | 1.5.0/docs/api/java/lang/String.html">String numberQuotation = 1.5.0/docs/api/java/lang/String.html">String.valueOf(numberQ) + ". ("+1.5.0/docs/api/java/lang/String.html">String.valueOf(question.getQuotation())+") "; |
339 | 1.5.0/docs/api/java/lang/String.html">String questionText = question.getTextpt(); |
340 | 1.5.0/docs/api/java/lang/String.html">String questionText = question.getTextpt(); |
340 | Paragraph questionP = new Paragraph(); |
341 | Paragraph questionP = new Paragraph(); |
341 | questionP.add(new Chunk(numberQuotation,fontTextBold)); |
342 | questionP.add(new Chunk(numberQuotation,fontTextBold)); |
342 | questionP.add(new Chunk(questionText,fontTextNormal)); |
343 | questionP.add(new Chunk(questionText,fontTextNormal)); |
343 | questionP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
344 | questionP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
344 | doc.add(questionP); |
345 | doc.add(questionP); |
345 | if(question.getImage()!=null) |
346 | if(question.getImage()!=null) |
346 | { |
347 | { |
347 | 1.5.0/docs/api/java/awt/Image.html">Image image = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imageStream/"+question.getImage().getId()); |
348 | 1.5.0/docs/api/java/awt/Image.html">Image image = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imageStream/"+question.getImage().getId()); |
348 | image.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
349 | image.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
349 | doc.add(image); |
350 | doc.add(image); |
350 | } |
351 | } |
351 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_TEXT)) |
352 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_TEXT)) |
352 | { |
353 | { |
353 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
354 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
354 | { |
355 | { |
355 | if(answer.getPossibleAnswer().getQuestionItem().getQuestion()== question) |
356 | if(answer.getPossibleAnswer().getQuestionItem().getQuestion()== question) |
356 | { |
357 | { |
357 | Paragraph answerP = new Paragraph(); |
358 | Paragraph answerP = new Paragraph(); |
358 | answerP.add(new Chunk("Resposta: ",fontTextBold)); |
359 | answerP.add(new Chunk("Resposta: ",fontTextBold)); |
359 | answerP.add(new Chunk(answer.getTextAnswer(), fontTextNormal)); |
360 | answerP.add(new Chunk(answer.getTextAnswer(), fontTextNormal)); |
360 | 361 | ||
361 | if(assessmentResponse.isEvaluated()) |
362 | if(assessmentResponse.isEvaluated()) |
362 | { //verifica se est� correcta |
363 | { //verifica se est� correcta |
363 | if(question.getQuotation()==answer.getQuotation()) |
364 | if(question.getQuotation()==answer.getQuotation()) |
364 | { |
365 | { |
365 | answerP.add(new Chunk(" Correcta",fontTextEvaluate)); |
366 | answerP.add(new Chunk(" Correcta",fontTextEvaluate)); |
366 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
367 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
367 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
368 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
368 | } |
369 | } |
369 | else if(answer.getQuotation()==0) |
370 | else if(answer.getQuotation()==0) |
370 | { |
371 | { |
371 | answerP.add(new Chunk(" Errada",fontTextEvaluate)); |
372 | answerP.add(new Chunk(" Errada",fontTextEvaluate)); |
372 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
373 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
373 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
374 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
374 | } |
375 | } |
375 | else |
376 | else |
376 | { |
377 | { |
377 | // double quotationA = (answer.getQuotation()*100)/question.getQuotation(); |
378 | // double quotationA = (answer.getQuotation()*100)/question.getQuotation(); |
378 | double quotationA = answer.getQuotation(); |
379 | double quotationA = answer.getQuotation(); |
379 | answerP.add(new Chunk(" Incompleta("+quotationA+")",fontTextEvaluate)); |
380 | answerP.add(new Chunk(" Incompleta("+quotationA+")",fontTextEvaluate)); |
380 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
381 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
381 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
382 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
382 | } |
383 | } |
383 | } |
384 | } |
384 | doc.add(answerP); |
385 | doc.add(answerP); |
385 | break; |
386 | break; |
386 | } |
387 | } |
387 | } |
388 | } |
388 | } |
389 | } |
389 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_PRACTICAL)) |
390 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_PRACTICAL)) |
390 | { |
391 | { |
391 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
392 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
392 | { |
393 | { |
393 | if(answer.getPossibleAnswer().getQuestionItem().getQuestion()== question) |
394 | if(answer.getPossibleAnswer().getQuestionItem().getQuestion()== question) |
394 | { |
395 | { |
395 | if(answer.getIdentifier()!= null && answer.getIdentifier().trim().length() !=0) |
396 | if(answer.getIdentifier()!= null && answer.getIdentifier().trim().length() !=0) |
396 | { |
397 | { |
397 | Paragraph answerP = new Paragraph("Foi entregue um ficheiro", fontTextBold); |
398 | Paragraph answerP = new Paragraph("Foi entregue um ficheiro", fontTextBold); |
398 | if(assessmentResponse.isEvaluated()) |
399 | if(assessmentResponse.isEvaluated()) |
399 | { //verifica se est� correcta |
400 | { //verifica se est� correcta |
400 | if(question.getQuotation()==answer.getQuotation()) |
401 | if(question.getQuotation()==answer.getQuotation()) |
401 | { |
402 | { |
402 | answerP.add(new Chunk(" Correcta",fontTextEvaluate)); |
403 | answerP.add(new Chunk(" Correcta",fontTextEvaluate)); |
403 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
404 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
404 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
405 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
405 | } |
406 | } |
406 | else if(answer.getQuotation()==0) |
407 | else if(answer.getQuotation()==0) |
407 | { |
408 | { |
408 | answerP.add(new Chunk(" Errada",fontTextEvaluate)); |
409 | answerP.add(new Chunk(" Errada",fontTextEvaluate)); |
409 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
410 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
410 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
411 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
411 | } |
412 | } |
412 | else |
413 | else |
413 | { |
414 | { |
414 | // double quotationA = (answer.getQuotation()*100)/question.getQuotation(); |
415 | // double quotationA = (answer.getQuotation()*100)/question.getQuotation(); |
415 | double quotationA = answer.getQuotation(); |
416 | double quotationA = answer.getQuotation(); |
416 | answerP.add(new Chunk(" Incompleta("+quotationA+")",fontTextEvaluate)); |
417 | answerP.add(new Chunk(" Incompleta("+quotationA+")",fontTextEvaluate)); |
417 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
418 | if(answer.getNote() != null && answer.getNote().trim().length() !=0) |
418 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
419 | answerP.add(new Chunk(" Obs:"+answer.getNote(),fontTextEvaluate)); |
419 | } |
420 | } |
420 | } |
421 | } |
421 | doc.add(answerP); |
422 | doc.add(answerP); |
422 | break; |
423 | break; |
423 | } |
424 | } |
424 | } |
425 | } |
425 | } |
426 | } |
426 | } |
427 | } |
427 | 428 | ||
428 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO) || question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_CHECK)) |
429 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO) || question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_CHECK)) |
429 | { |
430 | { |
430 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
431 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
431 | { |
432 | { |
432 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
433 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
433 | { |
434 | { |
434 | 1.5.0/docs/api/java/lang/String.html">String evaluated=null; |
435 | 1.5.0/docs/api/java/lang/String.html">String evaluated=null; |
435 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa=null; |
436 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa=null; |
436 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO)) |
437 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_RADIO)) |
437 | { |
438 | { |
438 | boolean isRadioAnswered = false; |
439 | boolean isRadioAnswered = false; |
439 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
440 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
440 | { |
441 | { |
441 | if(answer.getPossibleAnswer() == pA) |
442 | if(answer.getPossibleAnswer() == pA) |
442 | { |
443 | { |
443 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radioboxselected.png"); |
444 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radioboxselected.png"); |
444 | isRadioAnswered = true; |
445 | isRadioAnswered = true; |
445 | if(assessmentResponse.isEvaluated()) |
446 | if(assessmentResponse.isEvaluated()) |
446 | { //verifica se est� correcta |
447 | { //verifica se est� correcta |
447 | if(pA.getQuotation()>0) |
448 | if(pA.getQuotation()>0) |
448 | { |
449 | { |
449 | evaluated = " Correcta"; |
450 | evaluated = " Correcta"; |
450 | } |
451 | } |
451 | else if(pA.getQuotation()==0) |
452 | else if(pA.getQuotation()==0) |
452 | { |
453 | { |
453 | evaluated = " Errada"; |
454 | evaluated = " Errada"; |
454 | } |
455 | } |
455 | } |
456 | } |
456 | break; |
457 | break; |
457 | } |
458 | } |
458 | } |
459 | } |
459 | if(!isRadioAnswered) |
460 | if(!isRadioAnswered) |
460 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
461 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
461 | } |
462 | } |
462 | 463 | ||
463 | else |
464 | else |
464 | { |
465 | { |
465 | boolean isCheckAnswered = false; |
466 | boolean isCheckAnswered = false; |
466 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
467 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
467 | { |
468 | { |
468 | if(answer.getPossibleAnswer() == pA) |
469 | if(answer.getPossibleAnswer() == pA) |
469 | { |
470 | { |
470 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/checkboxselected.jpg"); |
471 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/checkboxselected.jpg"); |
471 | isCheckAnswered = true; |
472 | isCheckAnswered = true; |
472 | if(assessmentResponse.isEvaluated()) |
473 | if(assessmentResponse.isEvaluated()) |
473 | { //verifica se est� correcta |
474 | { //verifica se est� correcta |
474 | if(pA.getQuotation()>0) |
475 | if(pA.getQuotation()>0) |
475 | { |
476 | { |
476 | evaluated = " Correcta"; |
477 | evaluated = " Correcta"; |
477 | } |
478 | } |
478 | else if(pA.getQuotation()==0) |
479 | else if(pA.getQuotation()==0) |
479 | { |
480 | { |
480 | evaluated = " Errada"; |
481 | evaluated = " Errada"; |
481 | } |
482 | } |
482 | } |
483 | } |
483 | break; |
484 | break; |
484 | } |
485 | } |
485 | } |
486 | } |
486 | if(!isCheckAnswered) |
487 | if(!isCheckAnswered) |
487 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/checkbox.png"); |
488 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/checkbox.png"); |
488 | } |
489 | } |
489 | 490 | ||
490 | imagePa.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.PARAGRAPH); |
491 | imagePa.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.PARAGRAPH); |
491 | Paragraph pAP = new Paragraph(); |
492 | Paragraph pAP = new Paragraph(); |
492 | pAP.add(new Chunk(imagePa, -1.00f, -2.00f)); |
493 | pAP.add(new Chunk(imagePa, -1.00f, -2.00f)); |
493 | pAP.add(new Chunk(" "+pA.getTextpt(),fontTextNormal)); |
494 | pAP.add(new Chunk(" "+pA.getTextpt(),fontTextNormal)); |
494 | if(evaluated!=null) |
495 | if(evaluated!=null) |
495 | { |
496 | { |
496 | pAP.add(new Chunk(evaluated,fontTextEvaluate)); |
497 | pAP.add(new Chunk(evaluated,fontTextEvaluate)); |
497 | evaluated=null; |
498 | evaluated=null; |
498 | } |
499 | } |
499 | pAP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
500 | pAP.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_JUSTIFIED); |
500 | doc.add(pAP); |
501 | doc.add(pAP); |
501 | } |
502 | } |
502 | } |
503 | } |
503 | } |
504 | } |
504 | 505 | ||
505 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_MATRIX)) |
506 | if(question.getType().equals(Globals.ASSESSMENT_QUESTION_TYPE_MATRIX)) |
506 | { |
507 | { |
507 | PdfPTable table = null; |
508 | PdfPTable table = null; |
508 | int numPossibles=0; |
509 | int numPossibles=0; |
509 | //construir tabela |
510 | //construir tabela |
510 | //para saber o numero de respostas possiveis |
511 | //para saber o numero de respostas possiveis |
511 | for(AssessmentQuestionItem itemTam : question.getQuestionItems()) |
512 | for(AssessmentQuestionItem itemTam : question.getQuestionItems()) |
512 | { |
513 | { |
513 | numPossibles = itemTam.getPossibleAnswers().size()+2; //mais um para items e para correcções |
514 | numPossibles = itemTam.getPossibleAnswers().size()+2; //mais um para items e para correcções |
514 | table = new PdfPTable(numPossibles); |
515 | table = new PdfPTable(numPossibles); |
515 | PdfPCell colunaVazia = new PdfPCell(new Paragraph()); |
516 | PdfPCell colunaVazia = new PdfPCell(new Paragraph()); |
516 | colunaVazia.setBorder(0); |
517 | colunaVazia.setBorder(0); |
517 | table.addCell(colunaVazia); |
518 | table.addCell(colunaVazia); |
518 | for(AssessmentQuestionPossibleAnswer possibleTam : itemTam.getPossibleAnswers()) |
519 | for(AssessmentQuestionPossibleAnswer possibleTam : itemTam.getPossibleAnswers()) |
519 | { |
520 | { |
520 | PdfPCell possible = new PdfPCell(new Paragraph(possibleTam.getTextpt(),fontTextNormal)); |
521 | PdfPCell possible = new PdfPCell(new Paragraph(possibleTam.getTextpt(),fontTextNormal)); |
521 | possible.setBorder(0); |
522 | possible.setBorder(0); |
522 | table.addCell(possible); |
523 | table.addCell(possible); |
523 | } |
524 | } |
524 | table.addCell(colunaVazia); //para fechar a primeira linha da tabela |
525 | table.addCell(colunaVazia); //para fechar a primeira linha da tabela |
525 | break; |
526 | break; |
526 | } |
527 | } |
527 | 528 | ||
528 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
529 | for(AssessmentQuestionItem item : question.getQuestionItems()) |
529 | { |
530 | { |
530 | 1.5.0/docs/api/java/lang/String.html">String evaluated=null; |
531 | 1.5.0/docs/api/java/lang/String.html">String evaluated=null; |
531 | PdfPCell item1 = new PdfPCell(new Paragraph(item.getTextpt(),fontTextNormal)); |
532 | PdfPCell item1 = new PdfPCell(new Paragraph(item.getTextpt(),fontTextNormal)); |
532 | item1.setBorder(0); |
533 | item1.setBorder(0); |
533 | table.addCell(item1); |
534 | table.addCell(item1); |
534 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa=null; |
535 | 1.5.0/docs/api/java/awt/Image.html">Image imagePa=null; |
535 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
536 | for(AssessmentQuestionPossibleAnswer pA : item.getPossibleAnswers()) |
536 | { |
537 | { |
537 | boolean isRadioAnswered = false; |
538 | boolean isRadioAnswered = false; |
538 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
539 | for(AssessmentQuestionAnswer answer : assessmentResponse.getAnswers()) |
539 | { |
540 | { |
540 | if(answer.getPossibleAnswer() == pA) |
541 | if(answer.getPossibleAnswer() == pA) |
541 | { |
542 | { |
542 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radioboxselected.png"); |
543 | imagePa = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radioboxselected.png"); |
543 | isRadioAnswered = true; |
544 | isRadioAnswered = true; |
544 | if(assessmentResponse.isEvaluated()) |
545 | if(assessmentResponse.isEvaluated()) |
545 | { //verifica se esta correcta |
546 | { //verifica se esta correcta |
546 | if(pA.getQuotation()>0) |
547 | if(pA.getQuotation()>0) |
547 | { |
548 | { |
548 | evaluated = " Correcta"; |
549 | evaluated = " Correcta"; |
549 | } |
550 | } |
550 | else if(pA.getQuotation()==0) |
551 | else if(pA.getQuotation()==0) |
551 | { |
552 | { |
552 | evaluated = " Errada"; |
553 | evaluated = " Errada"; |
553 | } |
554 | } |
554 | } |
555 | } |
555 | break; |
556 | break; |
556 | } |
557 | } |
557 | } |
558 | } |
558 | 559 | ||
559 | if(!isRadioAnswered) |
560 | if(!isRadioAnswered) |
560 | imagePa= 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
561 | imagePa= 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/radiobox.png"); |
561 | 562 | ||
562 | PdfPCell imageCell = new PdfPCell(imagePa); |
563 | PdfPCell imageCell = new PdfPCell(imagePa); |
563 | imageCell.setBorder(0); |
564 | imageCell.setBorder(0); |
564 | table.addCell(imageCell); |
565 | table.addCell(imageCell); |
565 | } |
566 | } |
566 | if(evaluated != null) |
567 | if(evaluated != null) |
567 | { |
568 | { |
568 | PdfPCell evaluatedCell = new PdfPCell(new Paragraph(evaluated,fontTextEvaluate)); |
569 | PdfPCell evaluatedCell = new PdfPCell(new Paragraph(evaluated,fontTextEvaluate)); |
569 | evaluatedCell.setBorder(0); |
570 | evaluatedCell.setBorder(0); |
570 | table.addCell(evaluatedCell); |
571 | table.addCell(evaluatedCell); |
571 | evaluated=null; |
572 | evaluated=null; |
572 | } |
573 | } |
573 | else |
574 | else |
574 | { |
575 | { |
575 | PdfPCell evaluatedCell = new PdfPCell(new Paragraph()); |
576 | PdfPCell evaluatedCell = new PdfPCell(new Paragraph()); |
576 | evaluatedCell.setBorder(0); |
577 | evaluatedCell.setBorder(0); |
577 | table.addCell(evaluatedCell); |
578 | table.addCell(evaluatedCell); |
578 | } |
579 | } |
579 | } |
580 | } |
580 | float splitWidth = 1.0f / (float)numPossibles; |
581 | float splitWidth = 1.0f / (float)numPossibles; |
581 | float[] tams = new float[numPossibles]; |
582 | float[] tams = new float[numPossibles]; |
582 | for(int i=0;i<numPossibles;i++) |
583 | for(int i=0;i<numPossibles;i++) |
583 | { |
584 | { |
584 | tams[i] = splitWidth; |
585 | tams[i] = splitWidth; |
585 | } |
586 | } |
586 | table.setWidths(tams); |
587 | table.setWidths(tams); |
587 | table.setWidthPercentage(100.0f); |
588 | table.setWidthPercentage(100.0f); |
588 | doc.add(table); |
589 | doc.add(table); |
589 | } |
590 | } |
590 | doc.add(Chunk.NEWLINE); |
591 | doc.add(Chunk.NEWLINE); |
591 | } |
592 | } |
592 | 593 | ||
593 | } finally { |
594 | } finally { |
594 | if (doc != null) { |
595 | if (doc != null) { |
595 | //fechamento do documento |
596 | //fechamento do documento |
596 | doc.close(); |
597 | doc.close(); |
597 | } |
598 | } |
598 | if (os != null) { |
599 | if (os != null) { |
599 | //fechamento da stream de saida |
600 | //fechamento da stream de saida |
600 | os.close(); |
601 | os.close(); |
601 | } |
602 | } |
602 | } |
603 | } |
603 | 604 | ||
604 | //repositoryStream |
605 | //repositoryStream |
605 | 1.5.0/docs/api/java/lang/String.html">String fileName = Globals.TMP_DIR+"Resposta"+assessment.getTitle()+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessmentResponse.getId())+".pdf"; |
606 | 1.5.0/docs/api/java/lang/String.html">String fileName = Globals.TMP_DIR+"Resposta"+assessment.getTitle()+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessmentResponse.getId())+".pdf"; |
606 | 1.5.0/docs/api/java/io/File.html">File file = new 1.5.0/docs/api/java/io/File.html">File(fileName); |
607 | 1.5.0/docs/api/java/io/File.html">File file = new 1.5.0/docs/api/java/io/File.html">File(fileName); |
607 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(fileName); |
608 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(fileName); |
608 | 1.5.0/docs/api/java/lang/String.html">String description = "assessmentResponse.file "+assessment.getCourseUnit().getName()+assessmentResponse.getOwner().getName(); |
609 | 1.5.0/docs/api/java/lang/String.html">String description = "assessmentResponse.file "+assessment.getCourseUnit().getName()+assessmentResponse.getOwner().getName(); |
609 | 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream inputStream = new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(file); |
610 | 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream inputStream = new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(file); |
610 | 1.5.0/docs/api/java/lang/String.html">String identifierResponse = assessmentResponse.getIdentifier(); |
611 | 1.5.0/docs/api/java/lang/String.html">String identifierResponse = assessmentResponse.getIdentifier(); |
611 | 612 | ||
612 | if(identifierResponse==null) |
613 | if(identifierResponse==null) |
613 | identifierResponse = repositoryService.storeRepositoryFile(inputStream,"application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain, null, userSession); |
614 | identifierResponse = repositoryService.storeRepositoryFile(inputStream,"application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain, null, userSession); |
614 | else |
615 | else |
615 | repositoryService.updateRepositoryFile(identifierResponse,inputStream, "application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain); |
616 | repositoryService.updateRepositoryFile(identifierResponse,inputStream, "application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain); |
616 | 617 | ||
617 | assessmentResponse.setIdentifier(identifierResponse); |
618 | assessmentResponse.setIdentifier(identifierResponse); |
618 | } |
619 | } |
619 | 620 | ||
620 | 621 | ||
621 | 622 | ||
622 | 623 | ||
623 | public AssessmentView generateEvaluationsPdf(long assessmentId,UserSession userSession) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException { |
624 | public AssessmentView generateEvaluationsPdf(long assessmentId,UserSession userSession) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException { |
624 | AssessmentImpl assessment = DaoFactory.getAssessmentDaoImpl().get(assessmentId); |
625 | AssessmentImpl assessment = DaoFactory.getAssessmentDaoImpl().get(assessmentId); |
625 | List<AssessmentResponse> responses = DaoFactory.getAssessmentResponseDaoImpl().loadResponsesByAssessmentId(assessmentId); |
626 | List<AssessmentResponse> responses = DaoFactory.getAssessmentResponseDaoImpl().loadResponsesByAssessmentId(assessmentId); |
626 | 627 | ||
627 | //////////////////////////////////////////////// |
628 | //////////////////////////////////////////////// |
628 | 5+0%2Fdocs%2Fapi+Document">Document doc = null; |
629 | 5+0%2Fdocs%2Fapi+Document">Document doc = null; |
629 | 5+0%2Fdocs%2Fapi+OutputStream">OutputStream os = null; |
630 | 5+0%2Fdocs%2Fapi+OutputStream">OutputStream os = null; |
630 | 631 | ||
631 | try { |
632 | try { |
632 | //cria o documento tamanho A4, margens de 2,54cm |
633 | //cria o documento tamanho A4, margens de 2,54cm |
633 | doc = new 5+0%2Fdocs%2Fapi+Document">Document(PageSize.A4, 72, 72, 72, 72); |
634 | doc = new 5+0%2Fdocs%2Fapi+Document">Document(PageSize.A4, 72, 72, 72, 72); |
634 | //cria a stream de saida |
635 | //cria a stream de saida |
635 | os = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(Globals.TMP_DIR+ assessment.getTitle()+".pdf"); |
636 | os = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(Globals.TMP_DIR+ assessment.getTitle()+".pdf"); |
636 | //associa a stream de saida ao |
637 | //associa a stream de saida ao |
637 | PdfWriter.getInstance(doc, os); |
638 | PdfWriter.getInstance(doc, os); |
638 | //abre o documento |
639 | //abre o documento |
639 | doc.open(); |
640 | doc.open(); |
640 | //imagem do cabecalho |
641 | //imagem do cabecalho |
641 | 1.5.0/docs/api/java/awt/Image.html">Image img = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/logoestg.gif"); |
642 | 1.5.0/docs/api/java/awt/Image.html">Image img = 1.5.0/docs/api/java/awt/Image.html">Image.getInstance(Globals.SITE_URL+"/imgs/logoestg.gif"); |
642 | img.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
643 | img.setAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
643 | doc.add(img); |
644 | doc.add(img); |
644 | 645 | ||
645 | //Barra horizontal |
646 | //Barra horizontal |
646 | LineSeparator objectName = new LineSeparator(); |
647 | LineSeparator objectName = new LineSeparator(); |
647 | doc.add(objectName); |
648 | doc.add(objectName); |
648 | 649 | ||
649 | //adiciona um paragrafo para dar espaco |
650 | //adiciona um paragrafo para dar espaco |
650 | // Paragraph p = new Paragraph(""); |
651 | // Paragraph p = new Paragraph(""); |
651 | // Paragraph paragrafo = new Paragraph(); |
652 | // Paragraph paragrafo = new Paragraph(); |
652 | // paragrafo.setSpacingBefore(10); |
653 | // paragrafo.setSpacingBefore(10); |
653 | // paragrafo.setIndentationLeft(58); |
654 | // paragrafo.setIndentationLeft(58); |
654 | // paragrafo.setSpacingBefore(20); |
655 | // paragrafo.setSpacingBefore(20); |
655 | // paragrafo.setLeading(20); |
656 | // paragrafo.setLeading(20); |
656 | // paragrafo.add(new Chunk()); |
657 | // paragrafo.add(new Chunk()); |
657 | // doc.add(paragrafo); |
658 | // doc.add(paragrafo); |
658 | //doc.add(p); |
659 | //doc.add(p); |
659 | 660 | ||
660 | 661 | ||
661 | //doc.add(Chunk.NEWLINE); |
662 | //doc.add(Chunk.NEWLINE); |
662 | //Informacoes sobre a prova |
663 | //Informacoes sobre a prova |
663 | 664 | ||
664 | Phrase anoCurso = new Phrase("\nAno Lectivo: "+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessment.getYear())+ |
665 | Phrase anoCurso = new Phrase("\nAno Lectivo: "+1.5.0/docs/api/java/lang/String.html">String.valueOf(assessment.getYear())+ |
665 | " / Curso: "+assessment.getCourseUnit().getCourseName()+"\n"); |
666 | " / Curso: "+assessment.getCourseUnit().getCourseName()+"\n"); |
666 | Phrase courseUnit = new Phrase("Unidade Curricular: "+assessment.getCourseUnit().getName()+ |
667 | Phrase courseUnit = new Phrase("Unidade Curricular: "+assessment.getCourseUnit().getName()+ |
667 | "\nDocente: "+assessment.getOwner().getName()+"\n"); |
668 | "\nDocente: "+assessment.getOwner().getName()+"\n"); |
668 | doc.add(anoCurso); |
669 | doc.add(anoCurso); |
669 | doc.add(courseUnit); |
670 | doc.add(courseUnit); |
670 | 671 | ||
671 | doc.add(new Phrase(" ")); |
672 | doc.add(new Phrase(" ")); |
672 | 673 | ||
673 | 674 | ||
674 | ////tabela |
675 | ////tabela |
675 | PdfPTable table = new PdfPTable(assessment.getQuestions().size()+3); |
676 | PdfPTable table = new PdfPTable(assessment.getQuestions().size()+3); |
676 | 1.5.0/docs/api/java/awt/Font.html">Font fontHeader = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
677 | 1.5.0/docs/api/java/awt/Font.html">Font fontHeader = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.BOLD); |
677 | //primeira linha para as cotacoes |
678 | //primeira linha para as cotacoes |
678 | PdfPCell colunaVazia = new PdfPCell(new Paragraph()); |
679 | PdfPCell colunaVazia = new PdfPCell(new Paragraph()); |
679 | colunaVazia.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
680 | colunaVazia.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
680 | colunaVazia.setColspan(2); |
681 | colunaVazia.setColspan(2); |
681 | PdfPCell cotacaoMaxima = new PdfPCell(new Paragraph("20",fontHeader)); |
682 | PdfPCell cotacaoMaxima = new PdfPCell(new Paragraph("20",fontHeader)); |
682 | cotacaoMaxima.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
683 | cotacaoMaxima.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
683 | table.addCell(colunaVazia); |
684 | table.addCell(colunaVazia); |
684 | //table.addCell(colunaVazia); |
685 | //table.addCell(colunaVazia); |
685 | table.addCell(cotacaoMaxima); |
686 | table.addCell(cotacaoMaxima); |
686 | 687 | ||
687 | for(AssessmentQuestion question : assessment.getQuestions()) |
688 | for(AssessmentQuestion question : assessment.getQuestions()) |
688 | { |
689 | { |
689 | PdfPCell coluna = new PdfPCell(new Paragraph(1.5.0/docs/api/java/lang/String.html">String.valueOf(question.getQuotation()),fontHeader)); |
690 | PdfPCell coluna = new PdfPCell(new Paragraph(1.5.0/docs/api/java/lang/String.html">String.valueOf(question.getQuotation()),fontHeader)); |
690 | coluna.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
691 | coluna.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
691 | table.addCell(coluna); |
692 | table.addCell(coluna); |
692 | } |
693 | } |
693 | 694 | ||
694 | //segunda linha |
695 | //segunda linha |
695 | PdfPCell col1 = new PdfPCell(new Paragraph("N�",fontHeader)); |
696 | PdfPCell col1 = new PdfPCell(new Paragraph("N�",fontHeader)); |
696 | col1.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
697 | col1.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
697 | PdfPCell col2 = new PdfPCell(new Paragraph("Nome",fontHeader)); |
698 | PdfPCell col2 = new PdfPCell(new Paragraph("Nome",fontHeader)); |
698 | col2.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
699 | col2.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
699 | PdfPCell col3 = new PdfPCell(new Paragraph("Nota",fontHeader)); |
700 | PdfPCell col3 = new PdfPCell(new Paragraph("Nota",fontHeader)); |
700 | col3.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
701 | col3.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
701 | table.addCell(col1); |
702 | table.addCell(col1); |
702 | table.addCell(col2); |
703 | table.addCell(col2); |
703 | table.addCell(col3); |
704 | table.addCell(col3); |
704 | int numberQ=0; |
705 | int numberQ=0; |
705 | for(AssessmentQuestion question : assessment.getQuestions()) |
706 | for(AssessmentQuestion question : assessment.getQuestions()) |
706 | { |
707 | { |
707 | numberQ++; |
708 | numberQ++; |
708 | PdfPCell coluna = new PdfPCell(new Paragraph("P"+1.5.0/docs/api/java/lang/String.html">String.valueOf(numberQ),fontHeader)); |
709 | PdfPCell coluna = new PdfPCell(new Paragraph("P"+1.5.0/docs/api/java/lang/String.html">String.valueOf(numberQ),fontHeader)); |
709 | coluna.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
710 | coluna.setBackgroundColor(new BaseColor(0Xc0, 0Xc0,0Xc0)); |
710 | table.addCell(coluna); |
711 | table.addCell(coluna); |
711 | } |
712 | } |
712 | 713 | ||
713 | 1.5.0/docs/api/java/awt/Font.html">Font fontText = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
714 | 1.5.0/docs/api/java/awt/Font.html">Font fontText = new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.FontFamily.TIMES_ROMAN,10,1.5.0/docs/api/java/awt/Font.html">Font.NORMAL); |
714 | //cotacoes das respostas |
715 | //cotacoes das respostas |
715 | for(AssessmentResponse response : responses) |
716 | for(AssessmentResponse response : responses) |
716 | { |
717 | { |
717 | 1.5.0/docs/api/java/lang/String.html">String code=""; |
718 | 1.5.0/docs/api/java/lang/String.html">String code=""; |
718 | if(response.getOwner() instanceof Student) |
719 | if(response.getOwner() instanceof Student) |
719 | { |
720 | { |
720 | code = 1.5.0/docs/api/java/lang/String.html">String.valueOf(((Student)response.getOwner()).getSigesCode()); |
721 | code = 1.5.0/docs/api/java/lang/String.html">String.valueOf(((Student)response.getOwner()).getSigesCode()); |
721 | } |
722 | } |
722 | PdfPCell colunaNumero = new PdfPCell(new Paragraph(code,fontText)); |
723 | PdfPCell colunaNumero = new PdfPCell(new Paragraph(code,fontText)); |
723 | PdfPCell colunaNome = new PdfPCell(new Paragraph(response.getOwner().getName(),fontText)); |
724 | PdfPCell colunaNome = new PdfPCell(new Paragraph(response.getOwner().getName(),fontText)); |
724 | PdfPCell colunaNota = new PdfPCell(new Paragraph(1.5.0/docs/api/java/lang/String.html">String.valueOf(response.getQuotation()),fontText)); |
725 | PdfPCell colunaNota = new PdfPCell(new Paragraph(1.5.0/docs/api/java/lang/String.html">String.valueOf(response.getQuotation()),fontText)); |
725 | table.addCell(colunaNumero); |
726 | table.addCell(colunaNumero); |
726 | table.addCell(colunaNome); |
727 | table.addCell(colunaNome); |
727 | table.addCell(colunaNota); |
728 | table.addCell(colunaNota); |
728 | //numero nome e nota adicionados |
729 | //numero nome e nota adicionados |
729 | //percorrer as questoes |
730 | //percorrer as questoes |
730 | for(AssessmentQuestion question : assessment.getQuestions()) |
731 | for(AssessmentQuestion question : assessment.getQuestions()) |
731 | { |
732 | { |
732 | 1.5.0/docs/api/java/lang/String.html">String semResposta=" "; |
733 | 1.5.0/docs/api/java/lang/String.html">String semResposta=" "; |
733 | double percentagemF=0; |
734 | double percentagemF=0; |
734 | boolean respondida = false; |
735 | boolean respondida = false; |
735 | for(AssessmentQuestionAnswer answer : response.getAnswers()) |
736 | for(AssessmentQuestionAnswer answer : response.getAnswers()) |
736 | { |
737 | { |
737 | if(answer.getPossibleAnswer().getQuestionItem().getQuestion()==question) |
738 | if(answer.getPossibleAnswer().getQuestionItem().getQuestion()==question) |
738 | { |
739 | { |
739 | // percentagemF += (answer.getQuotation()*100) / question.getQuotation(); |
740 | // percentagemF += (answer.getQuotation()*100) / question.getQuotation(); |
740 | percentagemF += answer.getQuotation(); |
741 | percentagemF += answer.getQuotation(); |
741 | respondida=true; |
742 | respondida=true; |
742 | } |
743 | } |
743 | } |
744 | } |
744 | if(respondida){ |
745 | if(respondida){ |
745 | // int percentagemI = (int)percentagemF; |
746 | // int percentagemI = (int)percentagemF; |
746 | // PdfPCell colunaPercentagem = new PdfPCell(new Paragraph(String.valueOf(percentagemI)+"%",fontText)); |
747 | // PdfPCell colunaPercentagem = new PdfPCell(new Paragraph(String.valueOf(percentagemI)+"%",fontText)); |
747 | PdfPCell colunaPercentagem = new PdfPCell(new Paragraph(1.5.0/docs/api/java/lang/String.html">String.valueOf(percentagemF),fontText)); |
748 | PdfPCell colunaPercentagem = new PdfPCell(new Paragraph(1.5.0/docs/api/java/lang/String.html">String.valueOf(percentagemF),fontText)); |
748 | table.addCell(colunaPercentagem); |
749 | table.addCell(colunaPercentagem); |
749 | } |
750 | } |
750 | else{ |
751 | else{ |
751 | PdfPCell colunaPercentagem = new PdfPCell(new Paragraph(semResposta,fontText)); |
752 | PdfPCell colunaPercentagem = new PdfPCell(new Paragraph(semResposta,fontText)); |
752 | table.addCell(colunaPercentagem); |
753 | table.addCell(colunaPercentagem); |
753 | } |
754 | } |
754 | } |
755 | } |
755 | } |
756 | } |
756 | float splitWidth = 0.65f / (float)(assessment.getQuestions().size()+1); |
757 | float splitWidth = 0.65f / (float)(assessment.getQuestions().size()+1); |
757 | float[] tams = new float[assessment.getQuestions().size()+3]; |
758 | float[] tams = new float[assessment.getQuestions().size()+3]; |
758 | tams[0]=0.10f; |
759 | tams[0]=0.10f; |
759 | tams[1]=0.25f; |
760 | tams[1]=0.25f; |
760 | for(int i=2;i<assessment.getQuestions().size()+3;i++) |
761 | for(int i=2;i<assessment.getQuestions().size()+3;i++) |
761 | { |
762 | { |
762 | tams[i] = splitWidth; |
763 | tams[i] = splitWidth; |
763 | } |
764 | } |
764 | // float[] tams = {0.10f,0.25f,0.10f,0.10f,0.10f,0.03f,0.04f,0.04f}; |
765 | // float[] tams = {0.10f,0.25f,0.10f,0.10f,0.10f,0.03f,0.04f,0.04f}; |
765 | 766 | ||
766 | table.setWidths(tams); |
767 | table.setWidths(tams); |
767 | 768 | ||
768 | table.setWidthPercentage(100.0f); |
769 | table.setWidthPercentage(100.0f); |
769 | table.setHorizontalAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
770 | table.setHorizontalAlignment(5+0%2Fdocs%2Fapi+Element">Element.ALIGN_LEFT); |
770 | doc.add(table); |
771 | doc.add(table); |
771 | 772 | ||
772 | } finally { |
773 | } finally { |
773 | if (doc != null) { |
774 | if (doc != null) { |
774 | //fechamento do documento |
775 | //fechamento do documento |
775 | doc.close(); |
776 | doc.close(); |
776 | } |
777 | } |
777 | if (os != null) { |
778 | if (os != null) { |
778 | //fechamento da stream de saida |
779 | //fechamento da stream de saida |
779 | os.close(); |
780 | os.close(); |
780 | } |
781 | } |
781 | } |
782 | } |
782 | 783 | ||
783 | //repositoryStream |
784 | //repositoryStream |
784 | 1.5.0/docs/api/java/lang/String.html">String fileName = Globals.TMP_DIR+ assessment.getTitle()+".pdf"; |
785 | 1.5.0/docs/api/java/lang/String.html">String fileName = Globals.TMP_DIR+ assessment.getTitle()+".pdf"; |
785 | 1.5.0/docs/api/java/io/File.html">File file = new 1.5.0/docs/api/java/io/File.html">File(fileName); |
786 | 1.5.0/docs/api/java/io/File.html">File file = new 1.5.0/docs/api/java/io/File.html">File(fileName); |
786 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(fileName); |
787 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(fileName); |
787 | 1.5.0/docs/api/java/lang/String.html">String description = "assessment.evaluations.file "+assessment.getCourseUnit().getName(); |
788 | 1.5.0/docs/api/java/lang/String.html">String description = "assessment.evaluations.file "+assessment.getCourseUnit().getName(); |
788 | 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream inputStream = new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(file); |
789 | 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream inputStream = new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(file); |
789 | 1.5.0/docs/api/java/lang/String.html">String identifierEvaluations = assessment.getEvaluationsIdentifier(); |
790 | 1.5.0/docs/api/java/lang/String.html">String identifierEvaluations = assessment.getEvaluationsIdentifier(); |
790 | 791 | ||
791 | if(identifierEvaluations==null) |
792 | if(identifierEvaluations==null) |
792 | identifierEvaluations = repositoryService.storeRepositoryFile(inputStream,"application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain, null, userSession); |
793 | identifierEvaluations = repositoryService.storeRepositoryFile(inputStream,"application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain, null, userSession); |
793 | else |
794 | else |
794 | repositoryService.updateRepositoryFile(identifierEvaluations,inputStream, "application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain); |
795 | repositoryService.updateRepositoryFile(identifierEvaluations,inputStream, "application/pdf",extension,(int)file.length(),file.getName(),description, ResourceAccessControlEnum.publicDomain); |
795 | 796 | ||
796 | assessment.setEvaluationsIdentifier(identifierEvaluations); |
797 | assessment.setEvaluationsIdentifier(identifierEvaluations); |
797 | 798 | ||
798 | return new AssessmentView(assessment); |
799 | return new AssessmentView(assessment); |
799 | // return new AssessmentView(); |
800 | // return new AssessmentView(); |
800 | } |
801 | } |
801 | 802 | ||
802 | } |
803 | } |
803 | 804 |