# HG changeset patch # User Adam Chlipala # Date 1257189068 18000 # Node ID be1aec7333a54128d3c0cda795c3fdd38926de31 # Parent c1f49f6ba856c7f85772bc878c5f7afd41a77337 Saving paper assignments diff -r c1f49f6ba856 -r be1aec7333a5 demo/more/bid.ur --- a/demo/more/bid.ur Mon Nov 02 11:37:41 2009 -0500 +++ b/demo/more/bid.ur Mon Nov 02 14:11:08 2009 -0500 @@ -21,26 +21,26 @@ FROM paper JOIN bid ON bid.Paper = paper.Id JOIN user ON bid.User = user.Id ORDER BY paper.Id, bid.Interest, user.Nam) - (fn r (pid, int, acc, ints, papers) => - if pid = Some r.Paper.Id then + (fn r (paper, int, acc, ints, papers) => + if (case paper of None => False | Some r' => r'.Id = r.Paper.Id) then if int = r.Bid.Interest then - return (pid, int, (r.User.Id, r.User.Nam) :: acc, ints, papers) + return (paper, int, (r.User.Id, r.User.Nam) :: acc, ints, papers) else - return (pid, r.Bid.Interest, (r.User.Id, r.User.Nam) :: [], + return (paper, r.Bid.Interest, (r.User.Id, r.User.Nam) :: [], (int, acc) :: ints, papers) else - return (Some r.Paper.Id, r.Bid.Interest, + return (Some r.Paper, r.Bid.Interest, (r.User.Id, r.User.Nam) :: [], [], - case pid of + case paper of None => papers - | Some pid => (pid, (int, acc) :: ints) :: papers)) + | Some r => (r.Id, r -- #Id, (int, acc) :: ints) :: papers)) (None, #" ", [], [], []); let val papersL = case tup.1 of - Some pid => (pid, (tup.2, tup.3) :: tup.4) :: tup.5 - | _ => [] + Some r => (r.Id, r -- #Id, (tup.2, tup.3) :: tup.4) :: tup.5 + | None => [] - fun makePapers () = List.mapM (fn (pid, ints) => + fun makePapers () = List.mapM (fn (pid, extra, ints) => ints <- List.mapM (fn (int, users) => cg <- CheckGroup.create (List.mp @@ -50,7 +50,13 @@ ex <- Expandable.create (CheckGroup.render cg); return (int, cg, ex)) ints; - return (pid, ints)) papersL + return (pid, extra, ints)) papersL + + fun saveAssignment ls = + dml (DELETE FROM assignment WHERE TRUE); + List.app (fn (pid, uids) => + List.app (fn uid => dml (INSERT INTO assignment (Paper, User) + VALUES ({[pid]}, {[uid]}))) uids) ls in papers <- source []; @@ -59,9 +65,9 @@

Assign papers

+ return (List.mapX (fn (pid, extra, ints) =>
- Paper #{[pid]}: + #{[pid]}: {summarizePaper extra}: this <- CheckGroup.selected cg; total <- total; @@ -72,6 +78,17 @@ {[intOut int]}: {Expandable.render ex}
) ints}
) papers)}/> + +
+