-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing Multipage Error & Adding Completion Stamps (#43)
* Initial Fix * Fixed multipage surveys * update readme * test csv * Corrected numbering The curr page is 1 forward. * package-lock.json will cause install errors. Just keep package.json and then it will be auto generated * Setting response insertion to have right type * Adds completion stamp, queries supported in encrypted url Co-authored-by: Sumant R Shringari <[email protected]>
- Loading branch information
1 parent
c08ae45
commit 6febf8b
Showing
11 changed files
with
224 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,4 +106,7 @@ dist | |
# Application outputs | ||
.data | ||
built | ||
*.pem | ||
*.pem | ||
|
||
# package lock | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { response } from "express"; | ||
import { Request, Response } from "express-serve-static-core"; | ||
import {Db_Wrapper, env_config} from "../config" | ||
|
||
export const setPageNums = (survey) => { | ||
var pagefinal = 0 | ||
|
||
survey.forEach((elem) => { | ||
elem["page"] = Number(elem["page"]) | ||
pagefinal = Math.max(Number(elem["page"]), pagefinal) | ||
}) | ||
|
||
return pagefinal | ||
} | ||
|
||
export const setSurveyResponse = (req: Request<{}>) => { | ||
let response = {...req.body} | ||
if (response.start_time) { | ||
response["start_time"] = new Date(response["start_time"]) | ||
} | ||
|
||
if (response.sent) { | ||
response["sent"] = new Date(response["sent"]) | ||
} | ||
|
||
response["raw_data"] = "Surveyor_Incomplete" | ||
|
||
delete response["_csrf"] | ||
delete response["start"] | ||
delete response["check"] | ||
delete response["final"] | ||
delete response["curr_page"] | ||
return response | ||
} | ||
|
||
export const setSurveyCompleted = () => { | ||
const completion_stamp = {} | ||
completion_stamp["paid"] = false | ||
completion_stamp["end_time"] = new Date() | ||
completion_stamp["raw_data"] = "Surveyor" | ||
|
||
return completion_stamp | ||
} | ||
|
||
export const isSurveyCompleted = async (parsed) => { | ||
|
||
let queries: any[] = await Db_Wrapper.find({ | ||
"url": parsed.url, | ||
"WorkerId": parsed.WorkerId, | ||
"sent": new Date(parsed.sent), | ||
"paid": {"$exists": 1} | ||
}, "responses") | ||
|
||
return !(queries.length == 0) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.