diff --git a/Dockerfile.aws b/Dockerfile.aws index 03e9af4a..fcc9b809 100644 --- a/Dockerfile.aws +++ b/Dockerfile.aws @@ -1,5 +1,14 @@ -FROM golang:latest - +############################ +# STEP 1 build executable binary +############################ + +FROM golang:alpine AS builder + +# Install git. +# Git is required for fetching the dependencies. + +RUN apk update && apk add --no-cache git + ENV PATH=$PATH:/src/oef/ RUN mkdir -p /src/oef ADD . /src/oef @@ -8,7 +17,48 @@ COPY config/config.aws.yaml /src/oef/config/config.yaml WORKDIR /src/oef/ -RUN go build -o oef *.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o oef *.go +# RUN go build -o oef *.go + +############################ +# STEP 2 build a small image +############################ + +FROM scratch + +# Copy our static executable. +COPY --from=builder /src/oef/oef /src/oef/oef + +# Copy config file +COPY --from=builder /src/oef/config/config.yaml /src/oef/config/config.yaml + +# Copy templates +COPY --from=builder /src/oef/templates /src/oef/templates + +# Copy dist +COPY --from=builder /src/oef/dist /src/oef/dist + +# Copy VERSION file +COPY --from=builder /src/oef/VERSION /src/oef/VERSION + +WORKDIR /src/oef/ + +# Run the oef binary. ENTRYPOINT ["/src/oef/oef"] EXPOSE 80 + +# FROM golang:latest + +# ENV PATH=$PATH:/src/oef/ +# RUN mkdir -p /src/oef +# ADD . /src/oef + +# COPY config/config.aws.yaml /src/oef/config/config.yaml + +# WORKDIR /src/oef/ + +# RUN go build -o oef *.go +# ENTRYPOINT ["/src/oef/oef"] + +# EXPOSE 80 diff --git a/dist/main.bundle.js b/dist/main.bundle.js index de6f73de..9ec16244 100644 --- a/dist/main.bundle.js +++ b/dist/main.bundle.js @@ -73,8 +73,9 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__style_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__style_css__); -$(function () { +$(function () { + setInterval(function() { var timeleft = parseInt($("#timeleft").html()); if (timeleft > 0) { @@ -82,8 +83,20 @@ $(function () { } else { timeleft = 0; } - $("#timeleft").html(timeleft) + + $("#timeleft").html(timeleft); + + var minutes = Math.floor(timeleft/60); + var seconds = timeleft % 60; + + $("#timeleft_view").html(minutes+":"+seconds.toString().padStart(2, "0")); }, 1000); + + $("#reloadCaptcha").on("click",function(eventObject) { + image = eventObject.currentTarget; + + setSrcQuery(document.getElementById('image'), "reload=" + (new Date()).getTime()); + }); $("#myInput").on("keyup", function(eventObject) { @@ -132,6 +145,10 @@ $(function () { $(".karmen-ajax-delete").on("click", deleteHandler); + $("#reset_responses").on("click", function(eventObject) { + $('.form-check-input').removeAttr('checked'); + }); + }); @@ -143,4 +160,4 @@ $(function () { /***/ }) /******/ ]); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgZjVjMjdhYTFjNWFjNTQ0ZTIzNWIiLCJ3ZWJwYWNrOi8vLy4vc3JjL2luZGV4LmpzIiwid2VicGFjazovLy8uL3NyYy9zdHlsZS5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtRQUFBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTtRQUNBOzs7UUFHQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQSxLQUFLO1FBQ0w7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7UUFDQSwyQkFBMkIsMEJBQTBCLEVBQUU7UUFDdkQsaUNBQWlDLGVBQWU7UUFDaEQ7UUFDQTtRQUNBOztRQUVBO1FBQ0Esc0RBQXNELCtEQUErRDs7UUFFckg7UUFDQTs7UUFFQTtRQU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WJ0bi1jb25maXJtJywgZnVuY3Rpb24oKSB7XG5cdCAgICBcblx0ICAgICQuYWpheCh7XG5cdFx0dXJsOiB1cmwsXG5cdFx0dHlwZTogJ0RFTEVURScsXG5cdFx0c3VjY2VzczogZnVuY3Rpb24ocmVzdWx0KSB7XG5cdFx0ICAgIG1vZGFsRWwubW9kYWwoJ2hpZGUnKTtcblx0XHQgICAgd2luZG93LmxvY2F0aW9uLnJlcGxhY2UocmVzdWx0LnJlZGlyZWN0X3VybCk7XG5cdFx0fVxuXHQgICAgfSk7XG5cdCAgICBcblx0fSk7XG5cdFxuXHRyZXR1cm4gZmFsc2U7XG4gICAgfTtcbiAgICBcbiAgICAkKFwiLmthcm1lbi1hamF4LWRlbGV0ZVwiKS5vbihcImNsaWNrXCIsIGRlbGV0ZUhhbmRsZXIpO1xuXG4gICAgJChcIiNyZXNldF9yZXNwb25zZXNcIikub24oXCJjbGlja1wiLCBmdW5jdGlvbihldmVudE9iamVjdCkge1xuXHQkKCcuZm9ybS1jaGVjay1pbnB1dCcpLnJlbW92ZUF0dHIoJ2NoZWNrZWQnKTtcbiAgICB9KTtcbiAgICBcbn0pO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvaW5kZXguanNcbi8vIG1vZHVsZSBpZCA9IDBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIiwiLy8gcmVtb3ZlZCBieSBleHRyYWN0LXRleHQtd2VicGFjay1wbHVnaW5cblxuXG4vLy8vLy8vLy8vLy8vLy8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyAuL3NyYy9zdHlsZS5jc3Ncbi8vIG1vZHVsZSBpZCA9IDFcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/docker/oef_aws/db.env b/docker/oef_aws/db.env new file mode 100644 index 00000000..807bd6f7 --- /dev/null +++ b/docker/oef_aws/db.env @@ -0,0 +1,10 @@ +MYSQL_ROOT_PASSWORD=oef +MYSQL_PASSWORD=oef +MYSQL_DATABASE=oef_prod +MYSQL_USER=oef + + + + + + diff --git a/docker/oef_aws/docker-compose.yml b/docker/oef_aws/docker-compose.yml new file mode 100644 index 00000000..2756416f --- /dev/null +++ b/docker/oef_aws/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3.3" + +services: + + app: + image: andrea/oef:latest + ports: + - 80:80 + environment: + - DB_HOST=oef-micro.cjsemjfwbreb.eu-central-1.rds.amazonaws.com + - DB_PORT=3306 + + + diff --git a/docker/oef_regression_test/docker-compose.yaml b/docker/oef_regression_test/docker-compose.yaml index bacfe0ba..2c582262 100644 --- a/docker/oef_regression_test/docker-compose.yaml +++ b/docker/oef_regression_test/docker-compose.yaml @@ -42,6 +42,7 @@ services: - "4444:4444" - "5900:5900" volumes: + - /etc/localtime:/etc/localtime:ro - /dev/shm:/dev/shm volumes: diff --git a/orm/response.go b/orm/response.go index 37084911..3325d824 100644 --- a/orm/response.go +++ b/orm/response.go @@ -240,14 +240,25 @@ func (model *Response) Update(db *Database, args map[string]string, w http.Respo } // Check if the contest is still active - if !response.(*Response).IsActive() { + if isParticipant(r) && !response.(*Response).IsActive() { return nil, errors.OutOfTime } + + response.(*Response).SingleResponses = make([]*SingleResponse, 0) + err = renderer.Decode(response, r) if err != nil { return nil, err } + // If there aren't single responses then participant + // response Starttime is resetted. + if isAdministrator(r) { + if len(response.(*Response).SingleResponses) == 0 { + response.(*Response).StartTime = time.Time{} + } + } + WriteUpdater(r, response.(*Response)) _, err = SaveResponse(db, response) diff --git a/regression_test/regression_test.go b/regression_test/regression_test.go index 2d4ae25e..581856ef 100644 --- a/regression_test/regression_test.go +++ b/regression_test/regression_test.go @@ -231,6 +231,106 @@ func (t *testSuite) TestSchoolSubscription() { } +func (t *testSuite) TestParticipantResponse() { + login("WINBOXGUF", "GUf3wIP0DF7") + + err := findElement("a.btn-primary").Click() + if err != nil { + panic(err) + } + + err = findElement("#update-response").Click() + if err != nil { + panic(err) + } + + correct := []string{ + "97", "129", "105", "113", "93", "89", "109", "141", "157", + "85", "133", "153", "121", "117", "101", "149", "81", "145", + "125", "137", + } + + for _, answerId := range correct { + err = findElement("#answer_" + answerId).Click() + if err != nil { + panic(err) + } + } + + err = findElement("button.btn-primary").Click() + if err != nil { + panic(err) + } + + logout() + + login("admin", "admin") + + err = findElement("#responses_navbar_link").Click() + if err != nil { + panic(err) + } + + err = findElement("#myInput").SendKeys("BOXILL") + if err != nil { + panic(err) + } + err = findElement("a.oef-selected-by-search").Click() + if err != nil { + panic(err) + } + + scoreEl := findElement("#score") + score, err := scoreEl.Text() + + t.Nil(err) + t.Equal("20", score) + + err = findElement("a.btn-primary").Click() + if err != nil { + panic(err) + } + + err = findElement("#reset_responses").Click() + if err != nil { + panic(err) + } + + err = findElement("button.btn-primary").Click() + if err != nil { + panic(err) + } + + logout() +} + +func (t *testSuite) TestContestActiveWindow() { + login("admin", "admin") + + err := searchAndClick("junior") + if err != nil { + panic(err) + } + + err = findElement("a.btn-primary").Click() + if err != nil { + panic(err) + } + + err = findElement("#contest_description").SendKeys("Gara per la categoria JUNIOR") + + err = findElement("#contest_date").SendKeys("2020-03-04") + err = findElement("#contest_start_time").SendKeys("14:00") + err = findElement("#contest_end_time").SendKeys("15:00") + err = findElement("#contest_duration").SendKeys("45") + + err = findElement(".btn-primary").Click() + + t.True(true) + + logout() +} + func findElement(selector string) selenium.WebElement { element, err := wd.FindElement(selenium.ByCSSSelector, selector) if err != nil { @@ -436,3 +536,16 @@ func clickPrimaryButton() { panic(err) } } + +func searchAndClick(text string) error { + err := findElement("#myInput").SendKeys(text) + if err != nil { + return err + } + err = findElement("a.oef-selected-by-search").Click() + if err != nil { + return err + } + + return nil +} diff --git a/scripts/export_schools/.gitignore b/scripts/export_schools/.gitignore new file mode 100644 index 00000000..afed0735 --- /dev/null +++ b/scripts/export_schools/.gitignore @@ -0,0 +1 @@ +*.csv diff --git a/scripts/export_schools/export_schools b/scripts/export_schools/export_schools new file mode 100755 index 00000000..1fb1b1e4 Binary files /dev/null and b/scripts/export_schools/export_schools differ diff --git a/scripts/export_schools/main.go b/scripts/export_schools/main.go new file mode 100644 index 00000000..8bac1b96 --- /dev/null +++ b/scripts/export_schools/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "flag" + "os" + + "git.andreafazzi.eu/andrea/oef/client" + "git.andreafazzi.eu/andrea/oef/orm" + "github.com/gocarina/gocsv" +) + +func main() { + username := flag.String("username", "admin", "Username") + password := flag.String("password", "admin", "Password") + output := flag.String("output", "schools.csv", "Output filename") + + flag.Parse() + + client, err := client.Dial(flag.Arg(0), *username, *password) + if err != nil { + panic(err) + } + schools := make([]*orm.School, 0) + err = client.ReadAll(&schools) + if err != nil { + panic(err) + } + + f, err := os.Create(*output) + if err != nil { + panic(err) + } + defer f.Close() + + gocsv.MarshalFile(schools, f) +} diff --git a/scripts/export_schools/scuole.xlsx b/scripts/export_schools/scuole.xlsx new file mode 100644 index 00000000..6cbbccc2 Binary files /dev/null and b/scripts/export_schools/scuole.xlsx differ diff --git a/src/index.js b/src/index.js index af767544..d42ec050 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ import './style.css' $(function () { - + setInterval(function() { var timeleft = parseInt($("#timeleft").html()); if (timeleft > 0) { @@ -10,7 +10,13 @@ $(function () { } else { timeleft = 0; } - $("#timeleft").html(timeleft) + + $("#timeleft").html(timeleft); + + var minutes = Math.floor(timeleft/60); + var seconds = timeleft % 60; + + $("#timeleft_view").html(minutes+":"+seconds.toString().padStart(2, "0")); }, 1000); $("#reloadCaptcha").on("click",function(eventObject) { @@ -66,4 +72,8 @@ $(function () { $(".karmen-ajax-delete").on("click", deleteHandler); + $("#reset_responses").on("click", function(eventObject) { + $('.form-check-input').removeAttr('checked'); + }); + }); diff --git a/templates/layout/base.html.tpl b/templates/layout/base.html.tpl index caaaf78a..2b728375 100644 --- a/templates/layout/base.html.tpl +++ b/templates/layout/base.html.tpl @@ -45,7 +45,7 @@ Risposte Scuole Partecipanti - Prove + Prove {{- end -}} {{- if $isSchool -}} Scuola diff --git a/templates/layout/login.html.tpl b/templates/layout/login.html.tpl index 4238442f..abb81010 100644 --- a/templates/layout/login.html.tpl +++ b/templates/layout/login.html.tpl @@ -37,7 +37,7 @@ diff --git a/templates/responses_add_update.html.tpl b/templates/responses_add_update.html.tpl index cadd463d..39c3fd84 100644 --- a/templates/responses_add_update.html.tpl +++ b/templates/responses_add_update.html.tpl @@ -46,7 +46,7 @@ {{if isResponseIn $answer.ID $.Data.AnswersIDs}} {{$checked = true}} {{end}} - + @@ -71,10 +71,12 @@
Per iniziare o riprendere la gara clicca sul pulsante a destra. - + Vai alla gara!