Skip to content

Instantly share code, notes, and snippets.

@jcable
Last active February 9, 2020 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcable/22ec66e7b246775c18d53c52e6e5c417 to your computer and use it in GitHub Desktop.
Save jcable/22ec66e7b246775c18d53c52e6e5c417 to your computer and use it in GitHub Desktop.
Jotform update fields
#!/bin/sh
# get the current set of questions
curl 'https://eu-api.jotform.com/form/200321541644039/questions?apiKey='$JOT_API_KEY|jq . > new_boat.json
{
"responseCode": 200,
"message": "success",
"content": {
"1": {
"defaultValue": "",
"description": "The current name of your boat",
"hint": "",
"inputTextMask": "",
"labelAlign": "Auto",
"maxsize": "",
"name": "nameOf",
"order": "1",
"qid": "1",
"readonly": "No",
"required": "Yes",
"size": "20",
"subLabel": "",
"text": "Name of boat",
"type": "control_textbox",
"validation": "None"
},
"3": {
"defaultValue": "",
"description": "",
"hint": "",
"inputTextMask": "",
"labelAlign": "Auto",
"maxsize": "",
"name": "previousNames",
"order": "6",
"qid": "3",
"readonly": "No",
"required": "No",
"size": "20",
"subLabel": "separate names with commas",
"text": "Previous names",
"type": "control_textbox",
"validation": "None"
},
"5": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"maxSelection": "",
"minSelection": "",
"name": "mainSail",
"options": "Bermudan|Gaff|Gunter|Junk|Lateen|Lug|Spritsail|Square",
"order": "9",
"otherText": "Other",
"qid": "5",
"readonly": "No",
"required": "No",
"selected": "Gaff",
"shuffle": "No",
"special": "None",
"spreadCols": "3",
"text": "Main sail type",
"type": "control_checkbox"
},
"6": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "rigType",
"options": "Cutter|Ketch|Yawl|Schooner|Sloop|Cat boat|Other",
"order": "10",
"otherText": "Other",
"qid": "6",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "3",
"text": "Rig type",
"type": "control_radio"
},
"7": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "engine",
"options": "None|Inboard|Outboard",
"order": "11",
"otherText": "Other",
"qid": "7",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "3",
"text": "Engine",
"type": "control_radio"
},
"9": {
"ageVerification": "No",
"allowTime": "No",
"autoCalendar": "No",
"dateSeparator": "-",
"days": "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday",
"defaultDate": "none",
"defaultTime": "none",
"description": "",
"format": "yyyymmdd",
"labelAlign": "Auto",
"limitDate": "{\"days\":{\"monday\":true,\"tuesday\":true,\"wednesday\":true,\"thursday\":true,\"friday\":true,\"saturday\":true,\"sunday\":true},\"future\":true,\"past\":true,\"custom\":\"false\",\"ranges\":\"false\",\"start\":\"\",\"end\":\"\"}",
"liteMode": "Yes",
"minAge": "13",
"months": "January|February|March|April|May|June|July|August|September|October|November|December",
"name": "yearBuilt9",
"onlyFuture": "No",
"order": "31",
"qid": "9",
"readonly": "No",
"required": "No",
"startWeekOn": "Sunday",
"step": "10",
"sublabels": {
"day": "Day",
"month": "Month",
"year": "Year",
"last": "Last Name",
"hour": "Hour",
"minutes": "Minutes",
"litemode": "Date"
},
"text": "Year built / Launched",
"timeFormat": "AM/PM",
"today": "Today",
"type": "control_datetime",
"validateLiteDate": "Yes"
},
"12": {
"cols": "40",
"defaultValue": "",
"description": "",
"entryLimit": "None-0",
"entryLimitMin": "None-0",
"hint": "",
"labelAlign": "Auto",
"maxsize": "",
"mde": "Yes",
"name": "shortDescription",
"order": "32",
"qid": "12",
"readonly": "No",
"required": "No",
"rows": "6",
"subLabel": "",
"text": "Short description",
"type": "control_textarea",
"validation": "None",
"wysiwyg": "Disable"
},
"15": {
"boxAlign": "Left",
"builderDescription": "",
"cfname": "Country Picker",
"country": "None",
"customCSS": "",
"fieldParameters": "[{\"default\":\"None\",\"parentID\":\"52934d4e3be147110a000028\",\"name\":\"country\",\"order\":\"0\",\"readable\":\"Default country\",\"type\":\"dropdown\",\"tip\":\"Default country (optional).\",\"options\":\"None,Albania,Algeria,American Samoa,Andorra,Angola,Anguilla,Antarctica,Antigua and Barbuda,Argentina,Armenia,Aruba,Australia,Austria,Azerbaijan,Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize,Benin,Bermuda,Bhutan,Bolivia,Bosnia and Herzegovina,Botswana,Bouvet Island,Brazil,British Indian Ocean Territory,British Virgin Islands,Brunei,Bulgaria,Burkina Faso,Burundi,C\\u00f4te d'Ivoire,Cambodia,Cameroon,Canada,Cape Verde,Cayman Islands,Central African Republic,Chad,Chile,China,Christmas Island,Cocos (Keeling) Islands,Colombia,Comoros,Congo,Cook Islands,Costa Rica,Croatia,Cuba,Cyprus,Czech Republic,Democratic Republic of the Congo,Denmark,Djibouti,Dominica,Dominican Republic,East Timor,Ecuador,Egypt,El Salvador,Equatorial Guinea,Eritrea,Estonia,Ethiopia,Faeroe Islands,Falkland Islands,Fiji,Finland,France,France, Metropolitan,French Guiana,French Polynesia,French Southern Territories,Gabon,Georgia,Germany,Ghana,Gibraltar,Greece,Greenland,Grenada,Guadeloupe,Guam,Guatemala,Guinea,Guinea-Bissau,Guyana,Haiti,Heard and Mc Donald Islands,Honduras,Hong Kong,Hungary,Iceland,India,Indonesia,Iran,Iraq,Ireland,Israel,Italy,Jamaica,Japan,Jordan,Kazakhstan,Kenya,Kiribati,Kosovo,Kuwait,Kyrgyzstan,Laos,Latvia,Lebanon,Lesotho,Liberia,Libya,Liechtenstein,Lithuania,Luxembourg,Macau,Madagascar,Malawi,Malaysia,Maldives,Mali,Malta,Marshall Islands,Martinique,Mauritania,Mauritius,Mayotte,Mexico,Micronesia,Moldova,Monaco,Mongolia,Montenegro,Montserrat,Morocco,Mozambique,Myanmar,Namibia,Nauru,Nepal,Netherlands,Netherlands Antilles,New Caledonia,New Zealand,Nicaragua,Niger,Nigeria,Niue,Norfolk Island,North Korea,North Macedonia,Northern Marianas,Norway,Oman,Pakistan,Palau,Palestine,Panama,Papua New Guinea,Paraguay,Peru,Philippines,Pitcairn Islands,Poland,Portugal,Puerto Rico,Qatar,Reunion,Romania,Russia,Rwanda,S\\u0413\\u0408o Tom\\u0413\\u00a9 and Pr\\u0413\\u00adncipe,Saint Helena,St. Pierre and Miquelon,Saint Kitts and Nevis,Saint Lucia,Saint Vincent and the Grenadines,Samoa,San Marino,Saudi Arabia,Senegal,Serbia,Seychelles,Sierra Leone,Singapore,Slovakia,Slovenia,Solomon Islands,Somalia,South Africa,South Georgia and the South Sandwich Islands,South Korea,Spain,Sri Lanka,Sudan,Suriname,Svalbard and Jan Mayen Islands,Swaziland,Sweden,Switzerland,Syria,Taiwan,Tajikistan,Tanzania,Thailand,The Bahamas,The Gambia,Togo,Tokelau,Tonga,Trinidad and Tobago,Tunisia,Turkey,Turkmenistan,Turks and Caicos Islands,Tuvalu,US Virgin Islands,Uganda,Ukraine,United Arab Emirates,United Kingdom,United States,United States Minor Outlying Islands,Uruguay,Uzbekistan,Vanuatu,Vatican City,Venezuela,Vietnam,Wallis and Futuna Islands,Western Sahara,Yemen,Zambia,Zimbabwe\",\"paramStatus\":\"enabled\"},{\"default\":\"Whole country name\",\"parentID\":\"52934d4e3be147110a000028\",\"name\":\"submit\",\"order\":\"1\",\"readable\":\"Submission Value\",\"type\":\"dropdown\",\"tip\":\"\",\"options\":\"Whole country name,Abbreviation\",\"paramStatus\":\"enabled\"}]",
"finalSrc": "http://widgets.jotform.io/pickers/?pickerType=countries",
"frameHeight": "50",
"frameSrc": "http://widgets.jotform.io/pickers/?pickerType=countries",
"frameWidth": "365",
"inlineEditDefaultValue": "Type a question",
"label": "Yes",
"labelAlign": "Auto",
"maxWidth": "587",
"name": "homeCountry",
"order": "34",
"paramChunks": "",
"qid": "15",
"required": "No",
"selectedField": "52934d4e3be147110a000027",
"settingNames": "country,submit,customCSS",
"settingNamesCSS": "",
"static": "No",
"submit": "Whole country name",
"text": "Home Country",
"type": "control_widget",
"widgetTabs": "[[\"general\",\"settingNames\"],[\"customcss\",\"settingNamesCSS\"]]",
"widgetType": "field"
},
"17": {
"description": "",
"fields": "[{\"fieldID\":\"2\",\"type\":\"textbox\",\"row\":\"1\",\"col\":\"1\"},{\"fieldID\":\"9\",\"type\":\"textbox\",\"row\":\"1\",\"col\":\"2\"},{\"fieldID\":\"3\",\"type\":\"textbox\",\"row\":\"2\",\"col\":\"1\"},{\"fieldID\":\"6\",\"type\":\"number\",\"row\":\"2\",\"col\":\"2\",\"hint\":\"ex:23\"},{\"fieldID\":\"7\",\"type\":\"textbox\",\"row\":\"3\",\"col\":\"1\"},{\"fieldID\":\"8\",\"type\":\"textbox\",\"row\":\"3\",\"col\":\"2\"},{\"fieldID\":\"10\",\"type\":\"textbox\",\"row\":\"4\",\"col\":\"1\"},{\"fieldID\":\"11\",\"type\":\"textbox\",\"row\":\"4\",\"col\":\"2\"}]",
"labelAlign": "Auto",
"name": "otherRegistrations",
"order": "37",
"qid": "17",
"required": "No",
"sublabels": {
"field_2": "SSR",
"field_9": "VHF Call Sign",
"field_3": "National Register of Historic Vessels Number",
"field_6": "National Small Boats Register Number",
"field_7": "Fishing Number",
"field_8": "Sail Number",
"field_10": "MSSI",
"field_11": "Others"
},
"text": "Other Registrations",
"type": "control_mixed"
},
"18": {
"description": "",
"fields": "[{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"textbox\",\"row\":\"2\",\"col\":\"1\"},{\"fieldID\":\"4\",\"type\":\"textbox\",\"row\":\"3\",\"col\":\"1\"}]",
"labelAlign": "Auto",
"name": "part118",
"order": "36",
"qid": "18",
"required": "No",
"sublabels": {
"field_2": "Official Registry Number",
"field_3": "Port of Registry",
"field_4": "Year Registered"
},
"text": "Part 1 British Registry Details",
"type": "control_mixed"
},
"20": {
"description": "",
"fields": "[{\"fieldID\":\"1\",\"type\":\"dropdown\",\"row\":\"1\",\"col\":\"1\",\"options\":\"Fishing\\nLeisure\\nTrade\\nOther\",\"defaultValue\":\"Leisure\"},{\"fieldID\":\"2\",\"type\":\"dropdown\",\"row\":\"2\",\"col\":\"1\",\"options\":\"Fishing\\nLeisure\\nTrade\\nOther\",\"defaultValue\":\"Leisure\"}]",
"labelAlign": "Auto",
"name": "function",
"order": "38",
"qid": "20",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Original Function",
"field_2": "Current Function"
},
"text": "Function",
"type": "control_mixed"
},
"23": {
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"maxSelection": "",
"minSelection": "",
"multipleSelection": "No",
"name": "hullType",
"options": "[{\"text\":\"long keel deep forefoot\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/lkdf.5e3ce9c9b1ca83.66594591.png\"},{\"text\":\"long keel sloping forefoot\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/lksf.5e3ce9d7cced48.29740388.png\"},{\"text\":\"cut away stern\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/cas.5e3ce9e81b6198.68429611.png\"},{\"text\":\"fin keel\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/fk.5e3ce9fb902751.72455894.png\"},{\"text\":\"bilge keel\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/bk2.5e3cf2a57587e7.87913572.jpg\"},{\"text\":\"centre-boarder\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/lk.5e3cf7427703e8.98281560.png\"},{\"text\":\"dinghy\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/dinghy.5e3cfd089a5e13.57763343.png\"},{\"text\":\"centre-board dinghy\",\"link\":\"https:\\/\\/www.jotform.com\\/uploads\\/jfbcable\\/form_files\\/cbd.5e3cfd1ccc4398.04137561.jpg\"}]",
"order": "28",
"qid": "23",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "2",
"text": "Hull Type",
"type": "control_imagechoice"
},
"24": {
"allowOther": "No",
"calcValues": "",
"description": "The main material used to construct the hull",
"labelAlign": "Auto",
"name": "constructionMaterial",
"options": "GRP|Wood|Plywood|Steel|Aluminium|Ferro|Iron|wood/epoxy|other",
"order": "30",
"otherText": "Other",
"qid": "24",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "3",
"text": "Construction Material",
"type": "control_radio"
},
"25": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "constructionMethod",
"options": "Carvel|Clinker|Cold moulded|Hot Moulded|Clinker-ply|Stitch and glue|Strip planking|Strip planking / epoxy sheathed",
"order": "29",
"otherText": "Other",
"qid": "25",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "2",
"text": "Construction Method",
"type": "control_radio"
},
"26": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "sparMaterial",
"options": "Wood|Alloy|Steel|Carbon|Wood/Carbon|Alloy/Carbon",
"order": "27",
"otherText": "Other",
"qid": "26",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "2",
"text": "Spar Material",
"type": "control_radio"
},
"27": {
"calcValues": "",
"description": "If you intend to race your boat needs a handicap",
"labelAlign": "Auto",
"name": "doYou",
"options": "YES|NO",
"order": "13",
"qid": "27",
"readonly": "No",
"required": "No",
"selected": "",
"text": "Do you want a handicap",
"type": "control_yesno"
},
"28": {
"description": "All entries should be in decimal feet, so 4'6\" should be entered as 4.5.\nLWL excludes rudder.\nDepth is from the lowest part of the boat to the gunwale.",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"7\",\"type\":\"number\",\"row\":\"1\",\"col\":\"2\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"6\",\"type\":\"number\",\"row\":\"2\",\"col\":\"2\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"number\",\"row\":\"3\",\"col\":\"1\",\"hint\":\"\"},{\"fieldID\":\"8\",\"type\":\"number\",\"row\":\"3\",\"col\":\"2\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "hullMeasurements",
"order": "15",
"qid": "28",
"required": "No",
"sublabels": {
"field_1": "LENGTH OVER SPARS (LOS)",
"field_7": "BEAM",
"field_2": "LENGTH ON DECK (LOD)",
"field_6": "DEPTH",
"field_3": "LENGTH ON WATERLINE (LWL)",
"field_8": "DEPTH"
},
"text": "Hull Measurements",
"type": "control_mixed"
},
"31": {
"cols": "40",
"defaultValue": "",
"description": "",
"entryLimit": "None-0",
"entryLimitMin": "None-0",
"hint": "",
"labelAlign": "Auto",
"maxsize": "",
"mde": "Yes",
"name": "fullDescription",
"order": "40",
"qid": "31",
"readonly": "No",
"required": "No",
"rows": "6",
"subLabel": "",
"text": "Full Description",
"type": "control_textarea",
"validation": "None",
"wysiwyg": "Disable"
},
"35": {
"calcValues": "",
"description": "I want this. boat to be publicly listed on the OGA Boat Register",
"labelAlign": "Auto",
"name": "publicListing",
"options": "YES|NO",
"order": "2",
"qid": "35",
"readonly": "No",
"required": "No",
"selected": "",
"text": "Public Listing",
"type": "control_yesno"
},
"36": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "designClass36",
"options": "One off|Standard example of a production class|Customised example of a production class",
"order": "7",
"otherText": "Other",
"qid": "36",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "1",
"text": "Design Class",
"type": "control_radio"
},
"37": {
"calcValues": "",
"description": "",
"emptyText": "",
"labelAlign": "Auto",
"multipleSelections": "No",
"name": "designer",
"options": "",
"order": "12",
"qid": "37",
"required": "No",
"searchText": "Search",
"selected": "",
"shuffle": "No",
"size": "0",
"special": "None",
"subLabel": "",
"text": "Designer",
"type": "control_dropdown",
"visibleOptions": "1",
"width": "150"
},
"40": {
"defaultValue": "",
"description": "",
"hint": "",
"inputTextMask": "",
"labelAlign": "Auto",
"maxsize": "",
"name": "homePort",
"order": "35",
"qid": "40",
"readonly": "No",
"required": "No",
"size": "20",
"subLabel": "",
"text": "Home Port",
"type": "control_textbox",
"validation": "None"
},
"41": {
"align": "Center",
"alt": "",
"description": "Please refer to this diagram when adding the data needed for your handicap",
"height": "503",
"labelText": "Measurement Diagram",
"link": "",
"name": "image",
"order": "14",
"qid": "41",
"src": "https://www.jotform.com/uploads/jfbcable/form_files/hull-measure.5e36fe92a09ca3.02985908.png",
"target": "_blank",
"text": "hull-measure.5e36fe92a09ca3.02985908",
"type": "control_image",
"width": "618"
},
"42": {
"defaultValue": "",
"description": "In square feet",
"hint": "ex: 23",
"labelAlign": "Auto",
"maxsize": "",
"maxValue": "",
"minValue": "",
"name": "sailArea42",
"order": "16",
"qid": "42",
"readonly": "No",
"required": "No",
"size": "5",
"subLabel": "To convert square metres to square feet multiply by 10.76. ",
"text": "Sail Area",
"type": "control_number"
},
"43": {
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "doYou43",
"options": "YES|NO",
"order": "17",
"qid": "43",
"readonly": "No",
"required": "No",
"selected": "",
"text": "Do you set head sails when racing?",
"type": "control_yesno"
},
"44": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "foreTriangle",
"order": "18",
"qid": "44",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Height (I)",
"field_2": "Base (J)"
},
"text": "Fore Triangle",
"type": "control_mixed"
},
"45": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"number\",\"row\":\"3\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "biggestStaysail",
"order": "19",
"qid": "45",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Luff",
"field_2": "Leech",
"field_3": "Foot"
},
"text": "Biggest Staysail",
"type": "control_mixed"
},
"46": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"number\",\"row\":\"3\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "biggestJib",
"order": "20",
"qid": "46",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Luff",
"field_2": "Leech",
"field_3": "Foot"
},
"text": "Biggest Jib",
"type": "control_mixed"
},
"47": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"number\",\"row\":\"3\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "biggestDownwind",
"order": "21",
"qid": "47",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Luff",
"field_2": "Leech",
"field_3": "Foot"
},
"text": "Biggest Downwind Sail",
"type": "control_mixed"
},
"48": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"number\",\"row\":\"3\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "mainsail",
"order": "22",
"qid": "48",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Luff (H)",
"field_2": "Head (G)",
"field_3": "Foot (F)"
},
"text": "Mainsail",
"type": "control_mixed"
},
"49": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "topsail",
"order": "24",
"qid": "49",
"required": "No",
"sublabels": {
"field_1": "Luff (TH)",
"field_2": "Perpendicular (TI)"
},
"text": "Topsail",
"type": "control_mixed"
},
"50": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "mizenTopsail",
"order": "25",
"qid": "50",
"required": "No",
"sublabels": {
"field_1": "Luff (TH)",
"field_2": "Perpendicular (TI)"
},
"text": "Mizen Topsail",
"type": "control_mixed"
},
"51": {
"description": "decimal feet",
"fields": "[{\"fieldID\":\"1\",\"type\":\"number\",\"row\":\"1\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"2\",\"type\":\"number\",\"row\":\"2\",\"col\":\"1\",\"hint\":\"ex:23\"},{\"fieldID\":\"3\",\"type\":\"number\",\"row\":\"3\",\"col\":\"1\",\"hint\":\"ex:23\"}]",
"labelAlign": "Auto",
"name": "mizen",
"order": "23",
"qid": "51",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "Luff",
"field_2": "Head",
"field_3": "Foot"
},
"text": "Mizen",
"type": "control_mixed"
},
"52": {
"allowOther": "No",
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "propellerType",
"options": "None|Fixed|Folding|Feathering",
"order": "26",
"otherText": "Other",
"qid": "52",
"readonly": "No",
"required": "No",
"selected": "",
"shuffle": "No",
"special": "None",
"spreadCols": "3",
"text": "Propeller Type",
"type": "control_radio"
},
"53": {
"allowMultiple": "Yes",
"buttonStyle": "None",
"buttonText": "Browse Files",
"description": "Pictures should be at least 640 pixels wide",
"extensions": "pdf, doc, docx, xls, xlsx, csv, txt, rtf, html, zip, mp3, wma, mpg, flv, avi, jpg, jpeg, png, gif",
"fileLimit": "",
"labelAlign": "Auto",
"maxFileSize": "10854",
"minFileSize": "0",
"name": "uploadA",
"order": "5",
"qid": "53",
"required": "No",
"subLabel": "",
"text": "Upload a picture",
"type": "control_fileupload"
},
"54": {
"calcValues": "",
"description": "",
"labelAlign": "Auto",
"name": "iHave",
"options": "YES|NO",
"order": "3",
"qid": "54",
"readonly": "No",
"required": "No",
"selected": "",
"text": "I have a digital photo I took myself",
"type": "control_yesno"
},
"55": {
"description": "",
"fields": "[{\"fieldID\":1,\"type\":\"textbox\",\"row\":1,\"col\":1},{\"fieldID\":2,\"type\":\"dropdown\",\"row\":2,\"col\":1,\"options\":\"No\\nYes\",\"defaultValue\":\"No\"}]",
"labelAlign": "Auto",
"name": "iHave55",
"order": "4",
"qid": "55",
"required": "No",
"sublabels": {
"field_0": "",
"field_1": "The name of the person who took the picture (they don't have to be an OGA member)",
"field_2": "The person who took the picture is happy for it to be publicly available on the web"
},
"text": "I have a digital photo someone else took",
"type": "control_mixed"
},
"56": {
"calcValues": "",
"description": "",
"emptyText": "",
"labelAlign": "Auto",
"multipleSelections": "No",
"name": "className",
"options": "Crabber 24|Golant Gaffer",
"order": "8",
"qid": "56",
"required": "No",
"searchText": "Search",
"selected": "",
"shuffle": "No",
"size": "0",
"special": "None",
"subLabel": "",
"text": "Class Name",
"type": "control_dropdown",
"visibleOptions": "1",
"width": "150"
},
"57": {
"calcValues": "",
"description": "",
"emptyText": "",
"labelAlign": "Auto",
"multipleSelections": "No",
"name": "builder",
"options": "",
"order": "33",
"qid": "57",
"required": "No",
"searchText": "Search",
"selected": "",
"shuffle": "No",
"size": "0",
"special": "None",
"subLabel": "",
"text": "Builder",
"type": "control_dropdown",
"visibleOptions": "1",
"width": "150"
},
"58": {
"calcValues": "",
"description": "",
"emptyText": "",
"labelAlign": "Auto",
"multipleSelections": "No",
"name": "genericType",
"options": "",
"order": "39",
"qid": "58",
"required": "No",
"searchText": "Search",
"selected": "",
"shuffle": "No",
"size": "0",
"special": "None",
"subLabel": "",
"text": "Generic Type",
"type": "control_dropdown",
"visibleOptions": "1",
"width": "150"
}
},
"duration": "52ms",
"limit-left": 965
}
import requests
import os
api_key = os.environ['JOT_API_KEY']
def sortMapOfNames(l):
return sorted([o['name'] for o in l], key=str.casefold)
def getBuilders():
url = 'https://oga-boats.herokuapp.com/'
data={"query":"query{builders{name}}"}
r = requests.post(url, json=data)
return r.json()["data"]["builders"]
def getDesigners():
url = 'https://oga-boats.herokuapp.com/'
data={"query":"query{designers{name}}"}
r = requests.post(url, json=data)
return r.json()["data"]["designers"]
def getClassNames():
url = 'https://oga-boats.herokuapp.com/'
data={"query":"query{classNames}"}
r = requests.post(url, json=data)
return r.json()["data"]["classNames"]
def updateQuestion(form, qid, field, newValue):
url = "http://eu-api.jotform.com/form/%s/question/%s?apikey=%s" % (form, qid, api_key)
data = {"question["+field+"]": newValue}
return = requests.post(url, data=data)
def main():
form_id = 200321541644039
r = requests.get('https://eu-api.jotform.com/user/forms?apikey='+api_key)
forms = r.json()['content']
r = requests.get('https://eu-api.jotform.com/form/200321541644039?apikey='+api_key)
form = r.json()
r = requests.get('https://eu-api.jotform.com/form/200321541644039/questions?apikey='+api_key)
questions = r.json()['content']
bl = getBuilders()
sbl = sortMapOfNames(bl)
builders = '|'.join(sbl)
dl = getDesigners()
sdl = sortMapOfNames(dl)
designers = '|'.join(sdl)
scl = sorted(getClassNames(), key=str.casefold)
classNames = '|'.join(scl)
for qid in questions:
question = questions[qid]
if question['name'] == 'builder':
if question['options'] != builders:
print('update builders, current value is', question['options'])
print('new value is', builders)
updateQuestion(form_id, qid, 'options', builders)
elif question['name'] == 'designer':
if question['options'] != designers:
print('update designers, current value is', question['options'])
print('new value is', designers)
updateQuestion(form_id, qid, 'options', designers)
elif question['name'] == 'className':
if question['options'] != classNames:
print('update class names, current value is', question['options'])
print('new value is', classNames)
updateQuestion(form_id, qid, 'options', classNames)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment