19 package org.turro.admin;
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.function.BiConsumer;
25 import org.turro.action.IMailSender;
26 import org.turro.action.MailSenders;
27 import org.turro.auth.Authentication;
28 import org.turro.collections.CumulativeList;
29 import org.turro.elephant.context.ElephantContext;
30 import org.turro.exporter.FieldsExporter;
31 import org.turro.html.HtmlContent;
32 import org.turro.i18n.I_;
33 import org.turro.log.WebLoggers;
34 import org.turro.message.MessageQueue;
35 import org.turro.plugin.contacts.IContact;
36 import org.turro.sql.SqlClause;
37 import org.turro.students.db.StudentsPU;
38 import org.turro.students.entities.Response;
53 return "Responses to challenges by student";
70 File result = File.createTempFile(
"report",
"_Responses.csv");
71 FieldsExporter.of(getEntries()).export(result);
74 }
catch (IOException ex) {
75 WebLoggers.severe(
this).exception(ex).log();
79 private List<StudentsEntry> getEntries() {
80 BiConsumer<CumulativeList<ResponsesEntry>, Response> consumer = (l, r) -> {
81 for(IContact student : r.getStudentList()) {
82 ResponsesEntry e =
new ResponsesEntry();
83 e.challengeId = r.getChallenge().getId();
84 e.creation = r.getCreation();
85 e.challenge = r.getChallenge().getQuestion();
86 e.student = student.getFullName();
87 e.response = HtmlContent.plain(r.getText(), 255);
91 return CumulativeList.of(ResponsesEntry.class)
92 .forEachMultiCreate(SqlClause.select(
"r").from(
"Response r")
93 .dao(
new StudentsPU())
94 .resultList(Response.class),
static IMailSender getHeavy()
static boolean isAdministrator()
static IContact getIContact()
static String get(String msg)
static void pushMessage(IContact contact, String msg)
IMailSender onFinish(Consumer command)
IMailSender addAttachment(File file)