diff --git a/.jetproperties b/.jetproperties new file mode 100644 index 0000000000000000000000000000000000000000..cf694b21711c3050d668f0ae891a5f1dcf472e5d --- /dev/null +++ b/.jetproperties @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<jet-settings> + <template-container>templates</template-container> <source-container></source-container> +</jet-settings> diff --git a/bin/tdt4250/coursework/CourseworkGen.class b/bin/tdt4250/coursework/CourseworkGen.class new file mode 100644 index 0000000000000000000000000000000000000000..348baa3e1ac929ce14dd964b5ba6b65aae7552bd Binary files /dev/null and b/bin/tdt4250/coursework/CourseworkGen.class differ diff --git a/bin/tdt4250/coursework/CourseworkHTMLGenerator.class b/bin/tdt4250/coursework/CourseworkHTMLGenerator.class new file mode 100644 index 0000000000000000000000000000000000000000..5287590f03bab836bcfa3df3e987c6d868229d78 Binary files /dev/null and b/bin/tdt4250/coursework/CourseworkHTMLGenerator.class differ diff --git a/model/CourseworkGenerator.java b/model/CourseworkGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..5a13982ab63147fe354e6ebd589ddf52bf7880e0 --- /dev/null +++ b/model/CourseworkGenerator.java @@ -0,0 +1,6 @@ +public class CourseworkGenerator{ + + public static void main(String args[]) { + System.out.println("Test"); +} +} \ No newline at end of file diff --git a/src/tdt4250/coursework/CourseworkGen.java b/src/tdt4250/coursework/CourseworkGen.java new file mode 100644 index 0000000000000000000000000000000000000000..e8a5a42ca4c9b875f4a4c71cc437ec816015cb2f --- /dev/null +++ b/src/tdt4250/coursework/CourseworkGen.java @@ -0,0 +1,36 @@ +package tdt4250.coursework; + +import java.io.IOException; +import java.io.PrintStream; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +import tdt4250.coursework.University; +import tdt4250.coursework.impl.CourseworkFactoryImpl; + +public class CourseworkGen { + + public static void main(String[] args) throws IOException { + University university = getQuiz(args[0]); + } + + public static University getQuiz(String uriString) throws IOException { + ResourceSet resSet = new ResourceSetImpl(); + resSet.getPackageRegistry().put(CourseworkPackage.eNS_URI, CourseworkPackage.eINSTANCE); + resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("university", new CourseworkFactoryImpl()); + Resource resource = resSet.getResource(URI.createURI(uriString), true); + for (EObject eObject : resource.getContents()) { + if (eObject instanceof University) { + System.out.println((University) eObject); + return (University) eObject; + } + } + return null; + } + + +} diff --git a/src/tdt4250/coursework/CourseworkHTMLGenerator.java b/src/tdt4250/coursework/CourseworkHTMLGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..4735bce28b85cffd59de11bffebea62cc3c7b73f --- /dev/null +++ b/src/tdt4250/coursework/CourseworkHTMLGenerator.java @@ -0,0 +1,168 @@ +package tdt4250.coursework; + +import tdt4250.coursework.*; +import java.util.ArrayList; + +public abstract class CourseworkHTMLGenerator { + + ArrayList<String> generateHTML(University university){ + ArrayList<String> htmlPages = new ArrayList<String>(); + for(Course course : university.getCourse()) { + htmlPages.add(generateCourseHTML(course)); + } + return htmlPages; + } + + String generateCourseHTML(Course course) { + String coursehtml = "<html>" + + "<title>" + + course.getCode() + + " " + + course.getName() + + "</title>" + + "<body>" + + courseWorkTableGen(course) + + contentGen(course) + + assignmentGen(course) + + pkGen(course) + + reductionTableGen(course) + + timetableGen(course); + + coursehtml += "</body></html>"; + + return coursehtml; + } + + String courseWorkTableGen(Course course) { + EvaluationForm evalform = course.getSemesterSpecificCourseInstance().get(0).getEvaluationform(); + String evalTable = "<div><h1>Examination Arrangements</h1><table>" + +"<tr>" + + "<th>" + + "Evaluation form" + + "</th>" + + "<th>" + + "Weighting" + + " </th>" + + "</tr>"; + for (Evaluation eval : evalform.getEvaluation()) { + evalTable += "<tr>" + + "<th>" + + eval.getEvaluationKind().getName() + + "</th>" + + "</tr>"; + } + evalTable += "</table></div>"; + return evalTable; + } + + String contentGen(Course course) { + String contentDiv = "<div><h1>Course Content</h1>" + + course.getContent() + + "</div>"; + return contentDiv; + } + + String assignmentGen(Course course) { + String assignmentDiv = "<div><h1>Compulsory Assignments</h1>"; + for(Evaluation eval : course.getSemesterSpecificCourseInstance().get(0).getEvaluationform().getEvaluation()) { + if(!eval.getEvaluationKind().equals(EvaluationKinds.getByName("Exam"))) { + assignmentDiv += "<br>" + + eval.getEvaluationKind().getName() + + "</br>"; + } + } + assignmentDiv += "</div>"; + return assignmentDiv; + } + + String pkGen(Course course) { + String pkDiv = "<div><h1>Recommended Previous Knowledge</h1>"; + for(Course recCourse : course.getRecommendedCourse()) { + pkDiv += "Course" + + recCourse.getCode() + + " " + + recCourse.getName() + + ", or equivalent. <br>"; + } + pkDiv += "</div>"; + + pkDiv = "<div><h1>Required Previous Knowledge</h1>"; + for(Course reqCourse : course.getRequiredCourse()) { + pkDiv += "Course" + + reqCourse.getCode() + + " " + + reqCourse.getName() + + ", or equivalent. <br>"; + } + pkDiv += "</div>"; + return pkDiv; + } + + String reductionTableGen(Course course) { + String reducDiv = "<div><h1>Credit Reductions</h1><table><br>" + +"<tr>" + + "<th>" + + "Course Code" + + "</th>" + + "<th>" + + "Reduction" + + " </th>" + + "</tr>"; + for (CreditReduction crRed : course.getCreditreduction()) { + reducDiv += "<tr>" + + "<th>" + + crRed.getCourse().getCode() + + "</th>" + + "<th>" + + crRed.getReductionValue() + + " </th>" + + "</tr>"; + + } + reducDiv += "</div>"; + return reducDiv; + } + + String timetableGen(Course course) { + String timetableDiv = "<div><h1>Timetable</h1><table><br>" + + "<tr>" + + "<th>" + + "Date" + + "</th>" + + "<th>" + + "Type" + + "</th>" + + "<th>" + + "Study Programs" + + "</th>" + + "<th>" + + "Room" + + "</th>" + + "</tr>"; + for(TimetableSlot timeslot : course.getSemesterSpecificCourseInstance().get(0).getTimetable().getLecture()) { + timetableDiv += "<tr>" + + "<th>" + + timeslot.getDate() + + "</th>" + + "<th>" + + timeslot.getTimetableSlotKind().getName() + + "</th>" + + "<th>"; + for(StudyProgram sp : timeslot.getStudyprogram()) { + timetableDiv += sp.getName() + "<br>"; + }; + timetableDiv += "</th>" + + "<th>" + + timeslot.getRoom().getName() + + "</th>" + + "</tr>"; + } + timetableDiv += "</table></div>"; + return timetableDiv; + } + + public static void main(String[] args) { + Course uni = new Course(); + } + +}