Last active
August 29, 2015 14:20
-
-
Save Zolomon/330afce0914462dd4c64 to your computer and use it in GitHub Desktop.
error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\Users\zol\code\clojure\xmr.clj (master) | |
λ lein run | |
begin | |
map-problems-to-exam: clojure.lang.LazySeq@4762b6a2 | |
({:exams join-problems-to-exam: {:code "091021", :id 1} | |
problems | |
({:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 0, :id 1} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 1, :id 2} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 2, :id 3} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 3, :id 4} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 4, :id 5} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 5, :id 6} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 6, :id 7} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 7, :id 8} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 8, :id 9} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 9, :id 10} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 10, :id 11} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 11, :id 12} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 12, :id 13} {:examid 1, :updatedat 2014-10-29 18:24:24.000 +00:00, :createdat 2014-10-29 18:24:23.000 +00:00, :index 13, :id 14}) | |
Exception in thread "main" java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry, compiling:(taggify.clj:97:16) | |
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3558) | |
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3552) | |
at clojure.lang.Compiler$BodyExpr.eval(Compiler.java:5800) | |
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:417) | |
at clojure.lang.Compiler.eval(Compiler.java:6708) | |
at clojure.lang.Compiler.load(Compiler.java:7130) | |
at clojure.lang.RT.loadResourceScript(RT.java:370) | |
at clojure.lang.RT.loadResourceScript(RT.java:361) | |
at clojure.lang.RT.load(RT.java:440) | |
at clojure.lang.RT.load(RT.java:411) | |
at clojure.core$load$fn__5066.invoke(core.clj:5641) | |
at clojure.core$load.doInvoke(core.clj:5640) | |
at clojure.lang.RestFn.invoke(RestFn.java:408) | |
at clojure.core$load_one.invoke(core.clj:5446) | |
at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) | |
at clojure.core$load_lib.doInvoke(core.clj:5485) | |
at clojure.lang.RestFn.applyTo(RestFn.java:142) | |
at clojure.core$apply.invoke(core.clj:626) | |
at clojure.core$load_libs.doInvoke(core.clj:5524) | |
at clojure.lang.RestFn.applyTo(RestFn.java:137) | |
at clojure.core$apply.invoke(core.clj:626) | |
at clojure.core$require.doInvoke(core.clj:5607) | |
at clojure.lang.RestFn.invoke(RestFn.java:408) | |
at user$eval5$fn__7.invoke(form-init39307419760850694.clj:1) | |
at user$eval5.invoke(form-init39307419760850694.clj:1) | |
at clojure.lang.Compiler.eval(Compiler.java:6703) | |
at clojure.lang.Compiler.eval(Compiler.java:6693) | |
at clojure.lang.Compiler.load(Compiler.java:7130) | |
at clojure.lang.Compiler.loadFile(Compiler.java:7086) | |
at clojure.main$load_script.invoke(main.clj:274) | |
at clojure.main$init_opt.invoke(main.clj:279) | |
at clojure.main$initialize.invoke(main.clj:307) | |
at clojure.main$null_opt.invoke(main.clj:342) | |
at clojure.main$main.doInvoke(main.clj:420) | |
at clojure.lang.RestFn.invoke(RestFn.java:421) | |
at clojure.lang.Var.invoke(Var.java:383) | |
at clojure.lang.AFn.applyToHelper(AFn.java:156) | |
at clojure.lang.Var.applyTo(Var.java:700) | |
at clojure.main.main(main.java:37) | |
Caused by: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry | |
at clojure.lang.APersistentMap$KeySeq.first(APersistentMap.java:154) | |
at clojure.lang.PersistentHashSet.create(PersistentHashSet.java:45) | |
at clojure.core$set.invoke(core.clj:3782) | |
at clojure.set$join.invoke(set.clj:117) | |
at xmr.taggify$join_problems_to_exam.invoke(taggify.clj:54) | |
at clojure.core$map$fn__4245.invoke(core.clj:2559) | |
at clojure.lang.LazySeq.sval(LazySeq.java:40) | |
at clojure.lang.LazySeq.seq(LazySeq.java:49) | |
at clojure.lang.LazySeq.first(LazySeq.java:71) | |
at clojure.lang.RT.first(RT.java:577) | |
at clojure.core$first.invoke(core.clj:55) | |
at clojure.pprint$pprint_reader_macro.invoke(dispatch.clj:50) | |
at clojure.pprint$pprint_list.invoke(dispatch.clj:77) | |
at clojure.lang.MultiFn.invoke(MultiFn.java:227) | |
at clojure.pprint$write_out.invoke(pprint_base.clj:194) | |
at clojure.pprint$pprint_map$fn__8262$fn__8264.invoke(dispatch.clj:96) | |
at clojure.pprint$pprint_map$fn__8262.invoke(dispatch.clj:96) | |
at clojure.pprint$pprint_map.invoke(dispatch.clj:95) | |
at clojure.lang.MultiFn.invoke(MultiFn.java:227) | |
at clojure.pprint$write_out.invoke(pprint_base.clj:194) | |
at clojure.pprint$pprint_simple_list$fn__8244.invoke(dispatch.clj:68) | |
at clojure.pprint$pprint_simple_list.invoke(dispatch.clj:67) | |
at clojure.pprint$pprint_list.invoke(dispatch.clj:78) | |
at clojure.lang.MultiFn.invoke(MultiFn.java:227) | |
at clojure.pprint$write_out.invoke(pprint_base.clj:194) | |
at clojure.pprint$pprint$fn__7654.invoke(pprint_base.clj:250) | |
at clojure.pprint$pprint.invoke(pprint_base.clj:248) | |
at clojure.pprint$pprint.invoke(pprint_base.clj:245) | |
at clojure.lang.AFn.applyToHelper(AFn.java:154) | |
at clojure.lang.AFn.applyTo(AFn.java:144) | |
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3553) | |
... 38 more |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns xmr.taggify | |
(:require [clojure.java.io :as io] | |
[clojure.java.jdbc :as sql] | |
[clojure.pprint :as pp] | |
[clojure.set :as set]) | |
(:import java.io.File) | |
(:gen-class)) | |
(def directory (io/as-file (io/resource "public/images/courses"))) | |
(def courses (.listFiles directory)) | |
(def db | |
{:classname "org.sqlite.JDBC" | |
:subprotocol "sqlite" | |
:subname "resources/old.db"}) | |
(defn add-questions-to-problems | |
[course] | |
course) | |
(defn parse-questions | |
[courses] | |
(map add-questions-to-problems courses)) | |
(defn parse-answers | |
[courses] | |
courses) | |
(defn parse-tags | |
[courses] | |
courses) | |
;; (defn add-problems-to-exam | |
;; [exam] | |
;; (assoc exam :problems (sql/with-db-connection [db-con db] | |
;; (sql/query db-con ["select * from problems where ExamId=?" (exam :id)])))) | |
(defn get-problems-for-exam | |
[exam] | |
(sql/with-db-connection [db-con db] | |
(sql/query db-con ["select * from problems where ExamId=?" (exam :id)]))) | |
(defn rename | |
[exam] | |
(do | |
(println "problems") | |
(println (get-problems-for-exam exam)) | |
(let [problems (get-problems-for-exam exam)] | |
(set/rename problems {:examid :id})))) | |
(defn join-problems-to-exam | |
[exam] | |
(do (println (str "join-problems-to-exam: " exam)) | |
(set/join exam (rename exam)))) | |
(defn map-problems-to-exams | |
[exams] | |
(do (println (str "map-problems-to-exam: " (doall exams))) | |
(map join-problems-to-exam exams))) | |
(defn add-problems-to-exams | |
[course] | |
(update-in course [:exams] map-problems-to-exams)) | |
(defn parse-problems | |
[courses] | |
(map add-problems-to-exams courses)) | |
(defn add-exam-to-course | |
[course] | |
(assoc course :exams (sql/with-db-connection [db-con db] | |
(sql/query db-con ["select id,code from exams where CourseId=?" (course :id)])))) | |
(defn parse-exams | |
[courses] | |
(map add-exam-to-course courses)) | |
(defn parse-courses | |
[db] | |
(sql/with-db-connection [db-con db] | |
(sql/query db-con ["select * from courses"]))) | |
(defn write-tags | |
"Reads the old database to write tags.txt files for each exam that is tagged." | |
[] | |
(-> db | |
parse-courses | |
parse-exams | |
parse-problems | |
;;parse-questions | |
;;parse-answers | |
;;parse-tags | |
)) | |
(def -main | |
(do (println "begin") | |
(println (pp/pprint (write-tags))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment