From d94eb0dbd330b8bcceccd8e0c5afcf33aa3149a2 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 20 Nov 2009 23:15:28 +0100 Subject: Fix the score update procedure. --- logikorr.lisp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/logikorr.lisp b/logikorr.lisp index 6431144..441c83d 100644 --- a/logikorr.lisp +++ b/logikorr.lisp @@ -29,7 +29,10 @@ (last-name (if comma (subseq name 0 comma) nil)) (first-name (if comma (subseq name (+ comma 2)) name))) (make-student :id id - :score (coerce score 'vector) + :score (make-array (list (length score)) + :initial-contents score + :adjustable t + :fill-pointer t) :last-name last-name :first-name first-name)) and do (incf id)))) @@ -170,10 +173,15 @@ div.autocomplete ul li { (define-easy-handler (update-student-score :uri "/update-student-score") (id score-number score) - (let ((student (find-student-by-id (parse-integer id)))) - (setf (elt (student-score student) (parse-integer score-number)) + (let ((student (find-student-by-id (parse-integer id))) + (index (parse-integer score-number))) + (loop while (<= (length (student-score student)) index) + do (vector-push-extend 0 (student-score student))) + (setf (elt (student-score student) index) (let ((*read-eval* nil)) - (read score))))) + (let ((score (read-from-string score))) + (check-type score number))))) + "\"OK\"") (define-easy-handler (add-student-score :uri "/add-student-score") (id) -- cgit v1.2.3