Optimize code readability

This commit is contained in:
Marcus Kammer 2024-06-15 09:14:37 +02:00
parent 37217905df
commit f1b8f0b7d0
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -14,20 +14,21 @@
(defun choose-sus-form (lang) (defun choose-sus-form (lang)
"Based on LANG decide which sus form to show." "Based on LANG decide which sus form to show."
(check-type lang string) (check-type lang string)
(cond ((string= lang "en") #'ml-survey/views:sus-form-en) (case (string-downcase lang)
((string= lang "de") #'ml-survey/views:sus-form-de) ("en" #'ml-survey/views:sus-form-en)
(t (error "Unsupported language: ~A" lang)))) ("de" #'ml-survey/views:sus-form-de)
(otherwise (error "Unsupported language: ~A" lang))))
(defun process-questionnaire-get (lang s) (defun process-questionnaire-get (lang survey)
(check-type lang string) (check-type lang string)
(check-type s ml-survey:survey) (check-type survey ml-survey:survey)
(setf *html-lang* lang) (setf *html-lang* lang)
(funcall (choose-sus-form lang) (ml-survey:survey-id s))) (funcall (choose-sus-form lang) (ml-survey:survey-id survey)))
(defun process-questionnaire-post (request s) (defun process-questionnaire-post (request survey)
(let ((post-params (post-parameters* request)) (let ((post-params (post-parameters* request))
(questionnaire-id (generate-uuid))) (questionnaire-id (generate-uuid)))
(store-response (ensure-data-file-exist (ml-survey:survey-id s) (store-response (ensure-data-file-exist (ml-survey:survey-id survey)
questionnaire-id) questionnaire-id)
post-params) post-params)
(ml-survey/views:questionnaire-submit))) (ml-survey/views:questionnaire-submit)))