Skip to content

Commit a4468e2

Browse files
committed
import CEUK question weighting import
make sure we strip and lower case, plus warn if it's not a string
1 parent 4305018 commit a4468e2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

crowdsourcer/management/commands/ceuk_import_questions.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,21 @@ def handle(self, quiet: bool = False, *args, **kwargs):
192192
question_type = "select_one"
193193

194194
row = row.fillna("")
195+
weighting = "low"
196+
if type(row["weighting"]) == str:
197+
weighting = row["weighting"].strip().lower()
198+
else:
199+
print(
200+
f"bad weighting for {section.title}, {q_no}{q_part}: {row['weighting']}"
201+
)
195202
defaults = {
196203
"description": row["question"],
197204
"criteria": row["criteria"],
198205
"question_type": question_type,
199206
"how_marked": how_marked,
200207
"clarifications": row["clarifications"],
201208
"topic": row["topic"],
202-
"weighting": row["weighting"],
209+
"weighting": weighting,
203210
}
204211

205212
if kwargs["text_only"] or kwargs["weighting_only"]:

crowdsourcer/management/commands/import_combined_authority_questions.py

+9
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,29 @@ def handle(self, quiet: bool = False, *args, **kwargs):
208208
)
209209
continue
210210

211+
weighting = "low"
212+
if type(row["weighting"]) == str:
213+
weighting = row["weighting"].strip().lower()
214+
else:
215+
print(
216+
f"bad weighting for {section.title}, {q_no}{q_part}: {row['weighting']}"
217+
)
211218
defaults = {
212219
"description": row["question"],
213220
"criteria": row["criteria"],
214221
"question_type": question_type,
215222
"how_marked": how_marked,
216223
"clarifications": row["clarifications"],
217224
"topic": row["topic"],
225+
"weighting": weighting,
218226
}
219227

220228
if kwargs["text_only"]:
221229
for default in [
222230
"question_type",
223231
"how_marked",
224232
"topic",
233+
"weighting",
225234
]:
226235
del defaults[default]
227236

0 commit comments

Comments
 (0)