2024-07-07 13:46:09 +02:00
|
|
|
;;;; -*- mode: common-lisp; coding: utf-8; -*-
|
|
|
|
|
2024-05-31 15:18:13 +02:00
|
|
|
(in-package :ml-survey/views)
|
|
|
|
|
2024-06-24 18:21:03 +02:00
|
|
|
(defun new-survey (&optional survey-id)
|
2024-05-31 15:18:13 +02:00
|
|
|
"Generates the view to create a new survey."
|
2024-06-27 23:31:47 +02:00
|
|
|
(let ((questionnaires (ml-survey:list-questionnaires)))
|
|
|
|
(with-page (:title "New Survey")
|
|
|
|
(body-header "New Survey" (navbar-en))
|
|
|
|
(:main :class "container"
|
|
|
|
:id "main-content"
|
2024-05-31 15:18:13 +02:00
|
|
|
|
2024-06-27 23:31:47 +02:00
|
|
|
;; If `questionnaires' is an empty list, show the user an warning
|
|
|
|
;; message.
|
|
|
|
(unless questionnaires
|
|
|
|
(:div :class "alert alert-warning"
|
|
|
|
:role "alert"
|
|
|
|
(format nil "There are no questionnaires available.~%
|
2024-07-06 09:37:54 +02:00
|
|
|
The folder: ~a is empty." (ml-survey:questionnaires-dir))))
|
2024-06-24 18:21:03 +02:00
|
|
|
|
2024-06-27 23:31:47 +02:00
|
|
|
;; When a new survey was created, show the user an info message.
|
|
|
|
(when survey-id
|
|
|
|
(:div :class "alert alert-info"
|
|
|
|
:role "alert"
|
|
|
|
(format nil "Your new survey: ~A is created." survey-id)))
|
2024-05-31 15:18:13 +02:00
|
|
|
|
2024-06-27 23:31:47 +02:00
|
|
|
(:form :action "/new-survey"
|
|
|
|
:method "post"
|
2024-05-31 15:18:13 +02:00
|
|
|
|
2024-06-27 23:31:47 +02:00
|
|
|
(:fieldset
|
|
|
|
(:legend "Metadata")
|
|
|
|
(:div :class "mb-3"
|
|
|
|
(:label :class "form-label"
|
|
|
|
:for "title" "Title")
|
|
|
|
(:input :class "form-control"
|
|
|
|
:type "text"
|
|
|
|
:id "title"
|
|
|
|
:required ""
|
|
|
|
:name "title"))
|
|
|
|
(:div :class "mb-3"
|
|
|
|
(:label :class "form-label"
|
|
|
|
:for "description" "Description")
|
|
|
|
(:textarea :class "form-control"
|
|
|
|
:rows "3"
|
|
|
|
:id "description"
|
|
|
|
:name "description")))
|
2024-06-24 17:22:40 +02:00
|
|
|
|
2024-06-27 23:31:47 +02:00
|
|
|
(when questionnaires
|
|
|
|
(:fieldset
|
|
|
|
(:legend "Questionnaires")
|
|
|
|
(:div :class "mb-3"
|
|
|
|
(loop for q in questionnaires
|
|
|
|
do (:div :class "form-check"
|
|
|
|
(:input :class "form-check-input"
|
|
|
|
:type "checkbox"
|
|
|
|
:value q
|
|
|
|
:id q
|
|
|
|
:name "questionnaire"
|
|
|
|
(:label :class "form-check-label"
|
|
|
|
:for q
|
|
|
|
q)))))))
|
|
|
|
|
|
|
|
(:button :type"Submit"
|
|
|
|
:class "btn btn-primary"
|
|
|
|
"Create Survey"))))))
|