revisit 0.0.24__py2.py3-none-any.whl → 0.0.25__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
revisit/revisit.py
CHANGED
@@ -45,6 +45,7 @@ class _WrappedResponse(_JSONableBaseModel):
|
|
45
45
|
self.root = self.root.root
|
46
46
|
|
47
47
|
def set(self, overwrite=True, **kwargs) -> _WrappedResponse:
|
48
|
+
print('but I got here')
|
48
49
|
for key, value in kwargs.items():
|
49
50
|
# Disallow changing type
|
50
51
|
if key == 'type':
|
@@ -53,7 +54,7 @@ class _WrappedResponse(_JSONableBaseModel):
|
|
53
54
|
elif key != 'base':
|
54
55
|
if overwrite is True or (overwrite is False and getattr(self.root, key) is None):
|
55
56
|
setattr(self.root, key, value)
|
56
|
-
|
57
|
+
print('do I get here???')
|
57
58
|
# Re-validates the model. Returns the new model.
|
58
59
|
self.root = _validate_response(self.root.__dict__)
|
59
60
|
return self
|
@@ -509,8 +510,8 @@ def widget(study: _WrappedStudyConfig, revisitPath: str):
|
|
509
510
|
uiConfig.logoPath = newPath
|
510
511
|
|
511
512
|
# Copy all files
|
512
|
-
for item in extracted_paths:
|
513
|
-
|
513
|
+
# for item in extracted_paths:
|
514
|
+
# _copy_file(item['src'], item['dest'])
|
514
515
|
|
515
516
|
w = _widget.Widget()
|
516
517
|
w.config = json.loads(study.__str__())
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: revisit
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.25
|
4
4
|
Requires-Dist: anywidget
|
5
5
|
Requires-Dist: pandas
|
6
6
|
Requires-Dist: pydantic>=2.10.5
|
@@ -236,7 +236,201 @@ print(component_two)
|
|
236
236
|
'''
|
237
237
|
```
|
238
238
|
|
239
|
+
#### `clone(component_name__) -> Component`
|
239
240
|
|
241
|
+
**Description**:
|
242
|
+
Clones the component with the given new component name.
|
243
|
+
|
244
|
+
**Parameters**:
|
245
|
+
| Parameter | Type | Description | Default Value |
|
246
|
+
|-------------|----------|-------------------------------------|---------------|
|
247
|
+
| `component_name__` | `str` | New component name to assign to cloned component. | _None_ |
|
248
|
+
|
249
|
+
**Returns**:
|
250
|
+
- `self`: Returns self for method chaining.
|
251
|
+
|
252
|
+
#### **Examples**:
|
253
|
+
```python
|
254
|
+
test_response = rvt.response(
|
255
|
+
id='test_response',
|
256
|
+
type='shortText',
|
257
|
+
prompt='Original Prompt:',
|
258
|
+
required=True
|
259
|
+
)
|
260
|
+
|
261
|
+
component_one = rvt.component(
|
262
|
+
component_name__='component_one',
|
263
|
+
type='questionnaire',
|
264
|
+
response=[test_response]
|
265
|
+
)
|
266
|
+
|
267
|
+
component_two = component_one.clone(component_name__='component_two').edit_response(id='test_response', prompt='New Prompt', required=False)
|
268
|
+
|
269
|
+
print(component_one)
|
270
|
+
'''
|
271
|
+
Expected Output:
|
272
|
+
{
|
273
|
+
"response": [
|
274
|
+
{
|
275
|
+
"id": "test_response",
|
276
|
+
"prompt": "Original Prompt:",
|
277
|
+
"required": true,
|
278
|
+
"type": "shortText"
|
279
|
+
}
|
280
|
+
],
|
281
|
+
"type": "questionnaire"
|
282
|
+
}
|
283
|
+
'''
|
284
|
+
print(component_two)
|
285
|
+
'''
|
286
|
+
{
|
287
|
+
"response": [
|
288
|
+
{
|
289
|
+
"id": "test_response",
|
290
|
+
"prompt": "New Prompt",
|
291
|
+
"required": false,
|
292
|
+
"type": "shortText"
|
293
|
+
}
|
294
|
+
],
|
295
|
+
"type": "questionnaire"
|
296
|
+
}
|
297
|
+
'''
|
298
|
+
```
|
299
|
+
|
300
|
+
#### `Response`
|
301
|
+
|
302
|
+
**Description**:
|
303
|
+
A brief summary of the class's purpose and functionality.
|
304
|
+
|
305
|
+
#### **Attributes**:
|
306
|
+
| Attribute | Type | Description | Default Value |
|
307
|
+
|-------------|----------|-------------------------------------|---------------|
|
308
|
+
| `component_name__` | `type` | Description of attribute 1. | `default` |
|
309
|
+
| `base__` | `type` | Description of attribute 2. | _None_ |
|
310
|
+
|
311
|
+
|
312
|
+
#### **Methods**:
|
313
|
+
|
314
|
+
#### `set(**kwargs: dict) -> self`
|
315
|
+
|
316
|
+
**Description**:
|
317
|
+
|
318
|
+
Sets the values of the response to the input dictionary. The `type` cannot be changed and would require creating a new response
|
319
|
+
|
320
|
+
**Parameters**:
|
321
|
+
| Parameter | Type | Description | Default Value |
|
322
|
+
|-------------|----------|-------------------------------------|---------------|
|
323
|
+
| `**kwargs` | `dict` | Dictionary containing valid values for the current response type. | _None_ |
|
324
|
+
|
325
|
+
**Returns**:
|
326
|
+
- `self`: Returns self for method chaining.
|
327
|
+
|
328
|
+
#### **Raises**:
|
329
|
+
- `RevisitError`: If the user attempts to change the `type` attribute of the response, an exception will be raised. Any invalid inputs for the instantiated response type will also raise an exception.
|
330
|
+
|
331
|
+
#### **Examples**:
|
332
|
+
```python
|
333
|
+
response_one = rvt.response(
|
334
|
+
id='r-1',
|
335
|
+
type='shortText',
|
336
|
+
required=False,
|
337
|
+
location='belowStimulus',
|
338
|
+
prompt=''
|
339
|
+
)
|
340
|
+
|
341
|
+
response_one.set(prompt='New Prompt')
|
342
|
+
print(response_one)
|
343
|
+
'''
|
344
|
+
Expected Output
|
345
|
+
{
|
346
|
+
"id": "r-1",
|
347
|
+
"location": "belowStimulus",
|
348
|
+
"prompt": "New Prompt",
|
349
|
+
"required": false,
|
350
|
+
"type": "shortText"
|
351
|
+
}
|
352
|
+
'''
|
353
|
+
|
354
|
+
response_one.set(type='longText')
|
355
|
+
# Raises Exception: 'Cannot change type from shortText to longText'
|
356
|
+
|
357
|
+
response_one.set(options=[1,2,3])
|
358
|
+
|
359
|
+
```
|
360
|
+
|
361
|
+
#### `clone() -> Response`
|
362
|
+
|
363
|
+
**Description**:
|
364
|
+
Clones the response.
|
365
|
+
|
366
|
+
**Parameters**:
|
367
|
+
_No parameters_
|
368
|
+
|
369
|
+
**Returns**:
|
370
|
+
- `self`: Returns self for method chaining.
|
371
|
+
|
372
|
+
#### **Examples**:
|
373
|
+
```python
|
374
|
+
import random
|
375
|
+
question_1 = rvt.response(
|
376
|
+
id='q-1',
|
377
|
+
type='shortText',
|
378
|
+
prompt='What is 4 - 2?',
|
379
|
+
required=True,
|
380
|
+
location='belowStimulus'
|
381
|
+
)
|
382
|
+
|
383
|
+
# Initialize a list with first question
|
384
|
+
final_responses = [question_1]
|
385
|
+
|
386
|
+
# Randomly generate different arithmetic questions by cloning original question.
|
387
|
+
for i in range(2, 21):
|
388
|
+
curr_response = question_1.clone().set(
|
389
|
+
id=f'q-{i}',
|
390
|
+
prompt=f'What is {random.randint(1, 10)} - {random.randint(1, 10)}'
|
391
|
+
)
|
392
|
+
final_responses.append(curr_response)
|
393
|
+
|
394
|
+
component_one = rvt.component(
|
395
|
+
component_name__='component_one',
|
396
|
+
type='questionnaire',
|
397
|
+
response=final_responses
|
398
|
+
)
|
399
|
+
|
400
|
+
print(component_one)
|
401
|
+
'''
|
402
|
+
Expected Output:
|
403
|
+
{
|
404
|
+
"response": [
|
405
|
+
{
|
406
|
+
"id": "q-1",
|
407
|
+
"location": "belowStimulus",
|
408
|
+
"prompt": "What is 4 - 2?",
|
409
|
+
"required": true,
|
410
|
+
"type": "shortText"
|
411
|
+
},
|
412
|
+
{
|
413
|
+
"id": "q-2",
|
414
|
+
"location": "belowStimulus",
|
415
|
+
"prompt": "What is 10 - 4",
|
416
|
+
"required": true,
|
417
|
+
"type": "shortText"
|
418
|
+
},
|
419
|
+
|
420
|
+
...
|
421
|
+
|
422
|
+
{
|
423
|
+
"id": "q-20",
|
424
|
+
"location": "belowStimulus",
|
425
|
+
"prompt": "What is 2 - 5",
|
426
|
+
"required": true,
|
427
|
+
"type": "shortText"
|
428
|
+
}
|
429
|
+
],
|
430
|
+
"type": "questionnaire"
|
431
|
+
}
|
432
|
+
'''
|
433
|
+
```
|
240
434
|
|
241
435
|
## Development
|
242
436
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
revisit/StudyConfigSchema.json,sha256=xtzwZifuPJoiHASx0o8PHqBuh5L30mjBlhQ5eqsYm10,132168
|
2
2
|
revisit/__init__.py,sha256=QCvYt8m9QwpjcK4dv6GlLMUDCzRXGy16cua1r2biNCg,255
|
3
3
|
revisit/models.py,sha256=FRy8IlUAtDS3gdmZwwvqR935lbViTPnnr7k0CAkDkzI,134084
|
4
|
-
revisit/revisit.py,sha256=
|
4
|
+
revisit/revisit.py,sha256=VaHcbySp18VjpIJ3z-_XfQN93RbS4_ZMQs50Vs7feuA,27776
|
5
5
|
revisit/widget.py,sha256=VvFqRvvvn86fW8ASe1pxaAvh5ZLvvSRThI5XtlCdgcg,915
|
6
6
|
revisit/static/widget.css,sha256=TLu5F6k0CvowQtmApPswG-JZUXYszo7a10dVWKnZsIg,647
|
7
7
|
revisit/static/widget.js,sha256=jjc-RvauEnU8dHCR7oGSjg0y1CRXtAlw1-4yDeSbdKE,186472
|
8
|
-
revisit-0.0.
|
9
|
-
revisit-0.0.
|
10
|
-
revisit-0.0.
|
8
|
+
revisit-0.0.25.dist-info/METADATA,sha256=nsZQ-i0vAB_kwBEMV4YbaF6W4F1k0s5XsY0p-KltFf0,13510
|
9
|
+
revisit-0.0.25.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
10
|
+
revisit-0.0.25.dist-info/RECORD,,
|
File without changes
|