drake

package module
v0.0.0-...-6104d6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 1 Imported by: 0

README

Drake Equation Calculator

Estimate the number of detectable alien civilizations in the Milky Way using the Drake Equation.

About

This project was created as part of the course, Principles and Practices in Science Education, at the University of Toronto with the intention of being a free resource for educators to introduce the Drake Equation to a wider audience.

The questions for the Drake Equation on the survey are from LoPresto and Hubble-Zdanowski (2012).

Running locally

By default, the project runs on port 8080: http://localhost:8080/drake/.

With Docker Compose
docker compose -f server-compose.yaml up -d --build server
With Go
go mod tidy
go run cmd/server/main.go

Two databases are supported SQLite (default) and PostgreSQL. For PostgreSQL, you have to set the following environmental variables:

POSTGRES_USER=%your db user%
POSTGRES_PASSWORD=%your db password%
POSTGRES_HOSTNAME=%your db hostname%
POSTGRES_DB=%your db name%

Adding a new language

Add the language go to translations.go

For Spanish, for example:

//go:generate gotext -srclang=en update -out=catalog.go -lang=en,pt-BR,es github.com/louisbranch/drake/cmd/server

Then run:

go generate translations/translations.go

A new file for the language will be created at translations/locales.

Copy the source file for the one containing the translated messages:

cp translations/locales/es/out.gotext.json translations/locales/es/messages.gotext.json

After translating the messages in messages.gotext.json, run the generator again to update the language catalog:

go generate translations/translations.go

Finally, for the language to appear on the website, add the new language to the server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	CreateSession(*Session) error
	FindSessions() ([]Session, error)
	FindSession(string) (Session, error)

	CreateSurvey(*Survey) error
	UpdateSurvey(*Survey) error
	FindSurvey(string, string) (Survey, error)
	FindSurveys(string) ([]Survey, error)
}

type Session

type Session struct {
	ID           string
	Name         string
	Participants int64
	CreatedAt    time.Time
}

type Survey

type Survey struct {
	ID          string
	SessionID   string
	AccessToken string

	R  *float64
	Fp *float64
	Ne *float64
	Fl *float64
	Fi *float64
	Fc *float64
	L  *float64
	N  *float64

	PresurveyAssessment *float64
	PostsurveyLearnGain *bool
	PostsurveyReason    *string

	CreatedAt time.Time
	UpdatedAt time.Time
}

func (Survey) NextQuestion

func (s Survey) NextQuestion() string

func (*Survey) Result

func (s *Survey) Result()

Directories

Path Synopsis
cmd
db
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL