Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Show course data

  • Loading branch information...
commit c40965b8e3f37aa0c4625e948c288fa89d51a6d3 1 parent 315d042
@MasseR authored
Showing with 26 additions and 4 deletions.
  1. +11 −1 code/Main.hs
  2. +15 −3 code/public/js/doThings.js
View
12 code/Main.hs
@@ -167,6 +167,15 @@ fileResponse fun = H.docTypeHtml $ do
("parent." `mappend` fun `mappend` "()")
H.body $ mempty
+creditsData :: Mining Response
+creditsData = do
+ c <- gets credits
+ ok . toResponse . toJSON . combineResults $ c
+ where
+ combineResults credits = let
+ courses = foldr (\c m -> M.insert (creditId c) (creditId c, creditName c, creditCredits c) m) mempty credits
+ in [[id', name, T.pack . show $ credit] | (id', name, credit) <- M.elems courses]
+
thesisData :: Mining Response
thesisData = do
t <- gets thesis
@@ -300,7 +309,7 @@ mainView students = H.docTypeHtml $ do
H.table ! A.class_ "databox" $ mempty
H.div ! A.id "degreeData" ! A.style "display: none" ! A.class_ "hero-unit" $ do
H.table ! A.class_ "databox" $ mempty
- H.div ! A.id "creditData" ! A.style "display: none" ! A.class_ "hero-unit" $ do
+ H.div ! A.id "courseData" ! A.style "display: none" ! A.class_ "hero-unit" $ do
H.table ! A.class_ "databox" $ mempty
where
data_toggle = attribute "data-toggle" " data-toggle=\""
@@ -331,6 +340,7 @@ main = do
, dirs "student/upload" $ studentsUpload
, dirs "student/data" $ studentsData
, dirs "degree/data" $ thesisData
+ , dirs "course/data" $ creditsData
, dirs "thesis/upload" $ thesisUpload
, dir "static" $ serveDirectory EnableBrowsing [] "public/"
]) state
View
18 code/public/js/doThings.js
@@ -14,9 +14,9 @@ $(document).ready(function() {
else
$("#degreeData").hide();
if(page == 'credits')
- $("#creditData").show();
+ $("#courseData").show();
else
- $("#creditData").hide();
+ $("#courseData").hide();
});
var initPage = function(settings) {
@@ -87,9 +87,21 @@ $(document).ready(function() {
{ "sTitle": "Degree" },
{ "sTitle": "# of known courses" },
],
- moreInfo: function(data) { return $.get("/degree", {studentId: data[0]}); },
+ moreInfo: function(data) { return $.get("/degree", {thesisId: data[0]}); },
dataUri: "/degree/data"
});
+ window.touchCourse = initPage({
+ template: $("#degreeModalTemplate").text(),
+ dtElem: $("#courseData .databox"),
+ dtColumns: [
+ { "sTitle": "Course id" },
+ { "sTitle": "Course name" },
+ { "sTitle": "Course credits" },
+ ],
+ moreInfo: function(data) { return $.get("/course", {courseId: data[0]}); },
+ dataUri: "/course/data"
+ });
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.