Skip to content

Commit

Permalink
conscript,docs: how tos for anchor and payment display
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcKaufmann committed Mar 18, 2024
1 parent 63c6726 commit ab79ae6
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
43 changes: 43 additions & 0 deletions congame-doc/conscript.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,46 @@ code repository. This is not possible (out of security concerns) with
[step-id --> ,(lambda () expr)]
[step-id --> {step-id expr}]]
]

@section{How Tos}

The Tutorial explains how to use conscript. Here we list some @emph{How Tos}
that are not covered in a terse style, providing examples to achieve a given
goal without providing the full study around or explaining how it works.

@subsection{How to add links}

To provide a link on a study page, use the anchor tag @racket[a]:

@codeblock[#:keep-lang-line? #f]|{
#lang conscript
(defstep (links)
@md{# Links

A link to the @a[#:href
"https://docs.totalinsightmanagement.com/Conscript_Tutorial.html"]{Conscript
Tutorial}.

Sometimes you want a link to open in a new tab, so you provide the
attribute `target` with the value `"_blank"`:

@a[ #:href
"https://docs.totalinsightmanagement.com/Conscript_Tutorial.html" #:target
"_blank" ]{Open conscript tutorial in new tab}}) }|


@subsection{How to display monetary amounts}

To display monetary amounts, first @racket[require] the module @racket[conscript/survey-tools] which provides @racket[~$] for dollars, @racket[~euro] for euros, or @racket[~pound] for pounds:

@codeblock[#:keep-lang-file? #f]|{
#lang conscript
(require conscript/survey-tools)

(define (payments)
(define bonus 4.25)
@md{# Bonus

Your bonus is @(~$ bonus).
})
}|
41 changes: 41 additions & 0 deletions congame-example-study/conscript-how-tos.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#lang conscript

(require conscript/survey-tools)

(provide
how-tos)

(defstep (start)
@md{
@button[#:to-step-id 'links]{How to add links}

@button[#:to-step-id 'payments]{How to display payments}
})

(defstep (links)
@md{# Links

A link to the @a[#:href "https://docs.totalinsightmanagement.com/Conscript_Tutorial.html"]{Conscript Tutorial}.

Sometimes you want a link to open in a new tab, so you provide the attribute `target` with the value `"_blank"`:

@a[
#:href "https://docs.totalinsightmanagement.com/Conscript_Tutorial.html"
#:target "_blank"
]{Open conscript tutorial in new tab}

@button{Next}})

(define (payments)
(define bonus 4.25)
@md{# Bonus

Your bonus is @(~$ bonus).

@button{Next}
})

(defstudy how-tos
[start --> start]
[links --> start]
[payments --> start])
14 changes: 14 additions & 0 deletions conscript/survey-tools.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@
(submod congame/components/study accessors)
congame/components/resource
koyo/haml
racket/format
racket/list
racket/runtime-path)



;; Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(provide
~$ ~pound ~euro)

(define ((~currency [currency "$"]) a)
(format "~a~a" currency (~r a #:precision 2)))

(define ~$ (~currency "$"))
(define ~pound (~currency "£"))
(define ~euro (~currency ""))

;; Slider ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(provide
Expand Down

0 comments on commit ab79ae6

Please sign in to comment.