dipta007 commited on
Commit
2c9fffb
β€’
1 Parent(s): 2934c90
.gitignore ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by https://www.toptal.com/developers/gitignore/api/python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=python
3
+
4
+ ### Python ###
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/#use-with-ide
114
+ .pdm.toml
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
165
+
166
+ ### Python Patch ###
167
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168
+ poetry.toml
169
+
170
+ # ruff
171
+ .ruff_cache/
172
+
173
+ # LSP config files
174
+ pyrightconfig.json
175
+
176
+ # End of https://www.toptal.com/developers/gitignore/api/python
177
+
178
+ .streamlit/
api.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from google.cloud import firestore
3
+
4
+ # Authenticate to Firestore with the JSON account key.
5
+ db = firestore.Client.from_service_account_json("./firebase.json")
6
+
7
+ def show_likert_scale(step, type, id):
8
+ st.write("-----------------------------------")
9
+ st.subheader(f"'{type}' makes sense to me.")
10
+ scale = st.radio(
11
+ "",
12
+ ["Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly agree"],
13
+ index=None,
14
+ horizontal=True,
15
+ )
16
+ if type == 'Whole':
17
+ dependsOn = 'Whole'
18
+ else:
19
+ st.write("..................................."*10)
20
+ st.subheader(f"'{type}' is dependent on?")
21
+ dependsOn = st.radio(
22
+ "",
23
+ ["Image", "Text", "Both", "Neither"],
24
+ index=None,
25
+ horizontal=True,
26
+ )
27
+ submit = st.button('Submit', disabled=scale is None or dependsOn is None)
28
+ st.write("-----------------------------------")
29
+ if submit and scale:
30
+ st.write(f"You selected '{scale}' and {dependsOn}.")
31
+
32
+ user = st.session_state['user']
33
+ doc_ref = db.collection(step).document(id)
34
+
35
+ doc_ref.set({
36
+ user: {
37
+ 'scale': scale,
38
+ 'dependsOn': dependsOn,
39
+ },
40
+ }, merge=True)
41
+
42
+ return True
43
+
44
+ # show_likert_scale('all', 'tmp_cond', '10')
45
+
46
+
47
+
48
+ # Create a reference to the Google post.
49
+ # doc_ref = db.collection("posts").document("Google")
50
+
51
+ # # Then get the data at that reference.
52
+ # doc = doc_ref.get()
53
+
54
+ # # Let's see what we got!
55
+ # st.write("The id iss: ", doc.id)
56
+ # st.write("The contents are: ", doc.to_dict())
app.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+ from auth import check_password
5
+
6
+ if not check_password():
7
+ st.stop()
8
+
9
+ st.set_page_config(
10
+ page_title="ARL - Pilot 2a",
11
+ page_icon="πŸŽ†",
12
+ layout="wide",
13
+ )
14
+
15
+ df = pd.read_csv('./results.csv')
16
+ print(df.columns)
17
+
18
+
19
+ query = st.experimental_get_query_params()
20
+ if not query or 'id4' not in query or not query['id4']:
21
+ rnd_ind = random.randint(0, len(df) - 1)
22
+ # id = rnd_ind
23
+ id = 0
24
+ st.experimental_set_query_params(id=id)
25
+ file_id = id
26
+ else:
27
+ file_id = int(query['id4'][0])
28
+
29
+
30
+ st.experimental_set_query_params(id4=file_id)
31
+
32
+ data = df.iloc[file_id]
33
+ # st.table(data)
34
+ # print(data)
35
+
36
+ def show_story():
37
+ st.subheader('Impacted Story')
38
+ number_of_story_lines = int(data['Input.number_of_lines'])
39
+ print(number_of_story_lines)
40
+ story = data['Input.story'].split('. ')
41
+ for i in range(number_of_story_lines):
42
+ row_name = f'Answer.line{i}_changed.on'
43
+ print(row_name, data[row_name])
44
+ if data[row_name]:
45
+ st.markdown(f'**Line {i+1}:** <mark style="background-color: white">{story[i]}</mark>', unsafe_allow_html=True)
46
+ else:
47
+ st.markdown(f'**Line {i+1}:** {story[i]}')
48
+
49
+
50
+ def show_data():
51
+ col1, col2 = st.columns(2)
52
+
53
+ with col1:
54
+ img1, img2, img3 = st.columns(3)
55
+ with img1:
56
+ st.image(data['Input.image1'])
57
+ with img2:
58
+ st.image(data['Input.image2'])
59
+ with img3:
60
+ st.image(data['Input.image3'])
61
+
62
+ st.subheader('Entity')
63
+ st.write(data['Input.entity'])
64
+ st.subheader('Agent')
65
+ st.write(data['Input.agent'])
66
+ # st.subheader('Input Goal')
67
+ # st.write(data['Input.goal'])
68
+ st.subheader('Story')
69
+ st.write(data['Input.story'])
70
+
71
+ with col2:
72
+ st.subheader('Goal')
73
+ st.write(data['Answer.goal'])
74
+ st.subheader('Condition Necessary')
75
+ st.write(data['Answer.condition'])
76
+ st.subheader('Altered Condition')
77
+ st.write(data['Answer.not_condition'])
78
+ st.subheader('Lead to Altered Condition')
79
+ st.write(data['Answer.not_condition_ep'])
80
+
81
+ if data['Answer.story_impact.yes']:
82
+ show_story()
83
+ else:
84
+ st.subheader('Why no impact?')
85
+ st.text(data['Answer.why_no_impact'])
86
+ print(data)
87
+
88
+ from api import show_likert_scale
89
+ done = show_likert_scale('step_all', 'Whole', data['AssignmentId'])
90
+
91
+ if st.button("Next", disabled=not done):
92
+ id = file_id + 1
93
+ st.experimental_set_query_params(id4=id)
94
+ st.experimental_rerun()
95
+
96
+
97
+
98
+
99
+ show_data()
auth.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def check_password():
4
+ """Returns `True` if the user had the correct password."""
5
+
6
+ def password_entered():
7
+ """Checks whether a password entered by the user is correct."""
8
+ if st.session_state["password"] in st.secrets["passwords"]:
9
+ st.session_state['user'] = st.session_state["password"]
10
+ st.session_state["password_correct"] = True
11
+ else:
12
+ st.session_state["password_correct"] = False
13
+
14
+ if "password_correct" not in st.session_state:
15
+ # First run, show input for password.
16
+ st.text_input(
17
+ "Password", type="password", on_change=password_entered, key="password"
18
+ )
19
+ return False
20
+ elif not st.session_state["password_correct"]:
21
+ # Password not correct, show input + error.
22
+ st.text_input(
23
+ "Password", type="password", on_change=password_entered, key="password"
24
+ )
25
+ st.error("πŸ˜• Password incorrect")
26
+ return False
27
+ else:
28
+ # Password correct.
29
+ return True
firebase.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "b-agent-80",
4
+ "private_key_id": "f1ddcb019394eea19abe8e51f5351f9b8f5b7da0",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDWDdjCvc6otG8j\nt4G4n4wvzh7yfp9+8mqaqnljb2T6whxL3BKSLLdOZ5L0lN2lqefmGRoxbpyarY9n\n/aFlzmze8PPJQ/0JSQDnrpJDwZB0MvBAFdHX+l+v0YMaF8aT49MRFW93pCZbMgGl\nDyhYlLukFGptJTm/GKJNdUi55BXYSrf5EuGWrNFuO2Lqk4f5HrilhHkS9GsTI/rv\nyydbbBsU/rR8JGeYe7b4355f2S76Cp+sy1Sp7MctFai6woBzmFp/MpHb8bss61eA\nCueNH3TMfTlU7vfWC5GQoEnX2+JzEywhvLyx51qxoxqMSbHk/EhO7mSlwP8qXsJi\n9sDQP41fAgMBAAECggEADEt3gvJsoqamgZP8DyyYdg1Htfozuaw9fX/DZ144Txzq\nJVzqv8Glj745Clpb0GgN1vR9jo+BzqXS1Sn6ZMLlrV9RD8m1CLaZDWjeCg1ERlOM\nsCmj4XafzpUt2HuIH1BLlcrrTNRwk/YvcpmILqC9L5bKnCIYvh/kmdoqoLheNthm\njD1mSBGmCpaDBAh1p0zNxmLlKXK7PftcXVXaiZX1eS7kT+iGbPgImnNjidQ7XaXT\nc2J8Uhmkue2Qyfl+xzaULE9JbCGpnqJTNnbM7Af5uCrXdMblq973lc6B8vT32yBI\n25x1X04aidHAX7TnEo4pHqIYX1rQegiEcuKGcnELfQKBgQDrbjZn8hqRUhRYNeC9\nK7T/f0hdFS7yMMM9/74Pji1nK6iI4WKqfrgttzniu09hBOXM8PZyXKKyCoDoTd3L\nLRlcom1l9ej4LKilOXk+D0RH0+A/VAHMcvuuo6NuszSVdeSIcbPwK1fOeokSiZPo\nKZDop82cg4XuU4AeK8YoY/BY8wKBgQDowYP4Dpl3Hl2tvJ27MoyxvnijrvHMz6z4\nmc2RtYD6jD5lMXAnnvV9S4XIq/W9Q1+MMGFMYXZ515+6FZfsmwZ6DuM1SEdU8Cx7\nZPzeqhaalRuF5LhdhG/72Gw8EdPyWWW595VyLixZaYXkMag8TpJKBSdrPTXLBs05\n29gaIr8U5QKBgFrLz4m5Ekv3RsdaSAlM4OokcYkMkWVwLuwrRGaFY7dFXCMmIUI1\nytw+rMFnkc6N7/5g8/rZBRn6+QoedapVA1H5ho1rEGUd/BB0oPCxPJki+noR8Puj\nYLNSgsY/sMjvhaqlh0rZvGxyT4jprDQ+S5eel6qEAtQOOfvoz+xl1pzHAoGBAMGD\n4wziVoXLIWfJYfq51HATRIoScccvA0jN1zRGC65D27yWlgDbEI/Tsq9dCTsKQO51\nau/uOGqk84/rVBzL516j8hPivCvKY7FUDUmzcIelYPS5bO+TpOdm0NZAnE7qNMGh\nLwd3jDfqm/9VqeI6ETapglSO16KtTQPF3K4eJXBhAoGBAISVTOYUJe+wpXX2Kl17\nJ0MfzHzVsWxJL5ayAG4adCUIN9acRWNVb0YA2PQ8+Fdr388U5oU97fT8KYZtq/Yl\nY8lWu/YOgSiR5POWYODUYSsgZ6j8Px9tTdxACWzJUevlIIM6e5MHi8pIS9KHK2DN\no+9/Mmhdsa3Kh8PvyPu9VsDt\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "firebase-adminsdk-os25p@b-agent-80.iam.gserviceaccount.com",
7
+ "client_id": "108689290737260326543",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-os25p%40b-agent-80.iam.gserviceaccount.com",
12
+ "universe_domain": "googleapis.com"
13
+ }
get_data.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from google.cloud import firestore
2
+ import pandas as pd
3
+
4
+ # Authenticate to Firestore with the JSON account key.
5
+ db = firestore.Client.from_service_account_json("./firebase.json")
6
+
7
+ scale = {
8
+ "Strongly disagree": 1,
9
+ "Disagree": 2,
10
+ "Neutral": 3,
11
+ "Agree": 4,
12
+ "Strongly agree": 5,
13
+ }
14
+
15
+ def get_data():
16
+ data = {
17
+ 'id': []
18
+ }
19
+ obj = {}
20
+ for step in ["step_0", "step_1", "step_2", "step_3", "step_4", "step_all"]:
21
+ data = { **data, step: [], step + "_depends_on": [] }
22
+ collection = db.collection(step)
23
+ # print(collection)
24
+ docs = collection.stream()
25
+ for doc in docs:
26
+ if doc.id not in obj:
27
+ obj[doc.id] = {}
28
+ obj[doc.id][step] = scale[doc.to_dict()['beamlak']['scale']]
29
+ obj[doc.id][step + "_depends_on"] = doc.to_dict()['beamlak']['dependsOn']
30
+
31
+
32
+ for key in obj:
33
+ data['id'].append(key)
34
+ for step in ["step_0", "step_1", "step_2", "step_3", "step_4", "step_all"]:
35
+ data[step].append(obj[key][step])
36
+ for step in ["step_0", "step_1", "step_2", "step_3", "step_4", "step_all"]:
37
+ data[step + "_depends_on"].append(obj[key][step + "_depends_on"])
38
+ return data
39
+
40
+ data = get_data()
41
+ df = pd.DataFrame(data)
42
+ df.to_csv('./likert.csv', index=False)
pages/00_Step 0: Goal.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from auth import check_password
4
+
5
+ if not check_password():
6
+ st.stop()
7
+
8
+ st.set_page_config(
9
+ page_title="ARL - Pilot 2a",
10
+ page_icon="πŸŽ†",
11
+ layout="wide",
12
+ )
13
+
14
+ df = pd.read_csv('./results.csv')
15
+ print(df.columns)
16
+
17
+
18
+ query = st.experimental_get_query_params()
19
+ if not query or 'id0' not in query or not query['id0']:
20
+ # rnd_ind = random.randint(0, len(df) - 1)
21
+ id = 0
22
+ st.experimental_set_query_params(id0=id)
23
+ file_id = id
24
+ else:
25
+ file_id = int(query['id0'][0])
26
+
27
+
28
+ st.experimental_set_query_params(id0=file_id)
29
+
30
+ data = df.iloc[file_id]
31
+ # st.table(data)
32
+
33
+
34
+ def show_story():
35
+ st.subheader('Impacted Story')
36
+ number_of_story_lines = int(data['Input.number_of_lines'])
37
+ story = data['Input.story'].split('. ')
38
+ for i in range(number_of_story_lines):
39
+ st.markdown(f'**Line {i+1}:** {story[i]}')
40
+ row_name = f'Answer.line{i}_changed.on'
41
+ print(row_name, data[row_name])
42
+ if data[row_name]:
43
+ st.markdown(f'<mark style="background-color: white">{data[f"Answer.story_text_{i}_changed"]}</mark>', unsafe_allow_html=True)
44
+ # st.text_area(
45
+ # '',
46
+ # value=data[f'Answer.story_text_{i}_changed'],
47
+ # height=20,
48
+ # disabled=True,
49
+ # label_visibility='hidden'
50
+ # )
51
+
52
+
53
+ def show_data():
54
+ col1, col2 = st.columns(2)
55
+
56
+ with col1:
57
+ img1, img2, img3 = st.columns(3)
58
+ with img1:
59
+ st.image(data['Input.image1'])
60
+ with img2:
61
+ st.image(data['Input.image2'])
62
+ with img3:
63
+ st.image(data['Input.image3'])
64
+
65
+ st.subheader('Entity')
66
+ st.write(data['Input.entity'])
67
+ st.subheader('Agent')
68
+ st.write(data['Input.agent'])
69
+ # st.subheader('Input Goal')
70
+ # st.write(data['Input.goal'])
71
+ st.subheader('Story')
72
+ st.write(data['Input.story'])
73
+
74
+ with col2:
75
+ st.subheader('Goal')
76
+ st.write(data['Answer.goal'])
77
+ # st.subheader('Condition Necessary')
78
+ # st.write(data['Answer.condition'])
79
+ # st.subheader('Altered Condition')
80
+ # st.write(data['Answer.not_condition'])
81
+ # st.subheader('Lead to Altered Condition')
82
+ # st.write(data['Answer.not_condition_ep'])
83
+
84
+ # if data['Answer.story_impact.yes'] == True:
85
+ # show_story()
86
+ # else:
87
+ # st.subheader('Why no impact?')
88
+ # st.text(data['Answer.why_no_impact'])
89
+ # print(data)
90
+
91
+ from api import show_likert_scale
92
+ done = show_likert_scale('step_0', 'Goal', data['AssignmentId'])
93
+
94
+ if st.button("Next", disabled=not done):
95
+ id = file_id + 1
96
+ st.experimental_set_query_params(id0=id)
97
+ st.experimental_rerun()
98
+
99
+
100
+ # st.table(data)
101
+
102
+ show_data()
pages/01_Step 1: Condition Necesssary.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from auth import check_password
4
+
5
+ if not check_password():
6
+ st.stop()
7
+
8
+ st.set_page_config(
9
+ page_title="ARL - Pilot 2a",
10
+ page_icon="πŸŽ†",
11
+ layout="wide",
12
+ )
13
+
14
+ df = pd.read_csv('./results.csv')
15
+ print(df.columns)
16
+
17
+
18
+ query = st.experimental_get_query_params()
19
+ if not query or 'id1' not in query or not query['id1']:
20
+ # rnd_ind = random.randint(0, len(df) - 1)
21
+ id = 0
22
+ st.experimental_set_query_params(id1=id)
23
+ file_id = id
24
+ else:
25
+ file_id = int(query['id1'][0])
26
+
27
+
28
+ st.experimental_set_query_params(id1=file_id)
29
+
30
+ data = df.iloc[file_id]
31
+ # st.table(data)
32
+
33
+
34
+ def show_story():
35
+ st.subheader('Impacted Story')
36
+ number_of_story_lines = int(data['Input.number_of_lines'])
37
+ story = data['Input.story'].split('. ')
38
+ for i in range(number_of_story_lines):
39
+ st.markdown(f'**Line {i+1}:** {story[i]}')
40
+ row_name = f'Answer.line{i}_changed.on'
41
+ print(row_name, data[row_name])
42
+ if data[row_name]:
43
+ st.markdown(f'<mark style="background-color: white">{data[f"Answer.story_text_{i}_changed"]}</mark>', unsafe_allow_html=True)
44
+ # st.text_area(
45
+ # '',
46
+ # value=data[f'Answer.story_text_{i}_changed'],
47
+ # height=20,
48
+ # disabled=True,
49
+ # label_visibility='hidden'
50
+ # )
51
+
52
+
53
+ def show_data():
54
+ col1, col2 = st.columns(2)
55
+
56
+ with col1:
57
+ img1, img2, img3 = st.columns(3)
58
+ with img1:
59
+ st.image(data['Input.image1'])
60
+ with img2:
61
+ st.image(data['Input.image2'])
62
+ with img3:
63
+ st.image(data['Input.image3'])
64
+
65
+ st.subheader('Entity')
66
+ st.write(data['Input.entity'])
67
+ st.subheader('Agent')
68
+ st.write(data['Input.agent'])
69
+ # st.subheader('Input Goal')
70
+ # st.write(data['Input.goal'])
71
+ st.subheader('Story')
72
+ st.write(data['Input.story'])
73
+
74
+ with col2:
75
+ st.subheader('Goal')
76
+ st.write(data['Answer.goal'])
77
+ st.subheader('Condition Necessary')
78
+ st.write(data['Answer.condition'])
79
+ # st.subheader('Altered Condition')
80
+ # st.write(data['Answer.not_condition'])
81
+ # st.subheader('Lead to Altered Condition')
82
+ # st.write(data['Answer.not_condition_ep'])
83
+
84
+ # if data['Answer.story_impact.yes'] == True:
85
+ # show_story()
86
+ # else:
87
+ # st.subheader('Why no impact?')
88
+ # st.text(data['Answer.why_no_impact'])
89
+ # print(data)
90
+
91
+ from api import show_likert_scale
92
+ done = show_likert_scale('step_1', 'Necessary Condition', data['AssignmentId'])
93
+
94
+ if st.button("Next", disabled=not done):
95
+ id = file_id + 1
96
+ st.experimental_set_query_params(id1=id)
97
+ st.experimental_rerun()
98
+
99
+
100
+ # st.table(data)
101
+
102
+ show_data()
pages/02_Step 2: Altered Condition.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+ from auth import check_password
5
+
6
+ if not check_password():
7
+ st.stop()
8
+
9
+ st.set_page_config(
10
+ page_title="ARL - Pilot 2a",
11
+ page_icon="πŸŽ†",
12
+ layout="wide",
13
+ )
14
+
15
+ df = pd.read_csv('./results.csv')
16
+ print(df.columns)
17
+
18
+
19
+ query = st.experimental_get_query_params()
20
+ if not query or 'id2' not in query or not query['id2']:
21
+ rnd_ind = random.randint(0, len(df) - 1)
22
+ # id = rnd_ind
23
+ id = 0
24
+ st.experimental_set_query_params(id2=id)
25
+ file_id = id
26
+ else:
27
+ file_id = int(query['id2'][0])
28
+
29
+
30
+ st.experimental_set_query_params(id2=file_id)
31
+
32
+ data = df.iloc[file_id]
33
+ # st.table(data)
34
+
35
+
36
+ def show_story():
37
+ st.subheader('Impacted Story')
38
+ number_of_story_lines = int(data['Input.number_of_lines'])
39
+ story = data['Input.story'].split('. ')
40
+ for i in range(number_of_story_lines):
41
+ st.markdown(f'**Line {i+1}:** {story[i]}')
42
+ row_name = f'Answer.line{i}_changed.on'
43
+ print(row_name, data[row_name])
44
+ if data[row_name]:
45
+ st.markdown(f'<mark style="background-color: white">{data[f"Answer.story_text_{i}_changed"]}</mark>', unsafe_allow_html=True)
46
+ # st.text_area(
47
+ # '',
48
+ # value=data[f'Answer.story_text_{i}_changed'],
49
+ # height=20,
50
+ # disabled=True,
51
+ # label_visibility='hidden'
52
+ # )
53
+
54
+
55
+ def show_data():
56
+ col1, col2 = st.columns(2)
57
+
58
+ with col1:
59
+ img1, img2, img3 = st.columns(3)
60
+ with img1:
61
+ st.image(data['Input.image1'])
62
+ with img2:
63
+ st.image(data['Input.image2'])
64
+ with img3:
65
+ st.image(data['Input.image3'])
66
+
67
+ st.subheader('Entity')
68
+ st.write(data['Input.entity'])
69
+ st.subheader('Agent')
70
+ st.write(data['Input.agent'])
71
+ # st.subheader('Input Goal')
72
+ # st.write(data['Input.goal'])
73
+ st.subheader('Story')
74
+ st.write(data['Input.story'])
75
+
76
+ with col2:
77
+ st.subheader('Goal')
78
+ st.write(data['Answer.goal'])
79
+ st.subheader('Condition Necessary')
80
+ st.write(data['Answer.condition'])
81
+ st.subheader('Altered Condition')
82
+ st.write(data['Answer.not_condition'])
83
+ # st.subheader('Lead to Altered Condition')
84
+ # st.write(data['Answer.not_condition_ep'])
85
+
86
+ # if data['Answer.story_impact.yes'] == True:
87
+ # show_story()
88
+ # else:
89
+ # st.subheader('Why no impact?')
90
+ # st.text(data['Answer.why_no_impact'])
91
+ # print(data)
92
+
93
+ from api import show_likert_scale
94
+ done = show_likert_scale('step_2', 'Altered Condition', data['AssignmentId'])
95
+
96
+ if st.button("Next", disabled=not done):
97
+ id = file_id + 1
98
+ st.experimental_set_query_params(id2=id)
99
+ st.experimental_rerun()
100
+
101
+
102
+ # st.table(data)
103
+
104
+ show_data()
pages/03_Step 3: Lead to Altered Condition.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+ from auth import check_password
5
+
6
+ if not check_password():
7
+ st.stop()
8
+
9
+ st.set_page_config(
10
+ page_title="ARL - Pilot 2a",
11
+ page_icon="πŸŽ†",
12
+ layout="wide",
13
+ )
14
+
15
+ df = pd.read_csv('./results.csv')
16
+ print(df.columns)
17
+
18
+
19
+ query = st.experimental_get_query_params()
20
+ if not query or 'id3' not in query or not query['id3']:
21
+ rnd_ind = random.randint(0, len(df) - 1)
22
+ # id = rnd_ind
23
+ id = 0
24
+ st.experimental_set_query_params(id3=id)
25
+ file_id = id
26
+ else:
27
+ file_id = int(query['id3'][0])
28
+
29
+
30
+ st.experimental_set_query_params(id3=file_id)
31
+
32
+ data = df.iloc[file_id]
33
+ # st.table(data)
34
+
35
+
36
+ def show_story():
37
+ st.subheader('Impacted Story')
38
+ number_of_story_lines = int(data['Input.number_of_lines'])
39
+ story = data['Input.story'].split('. ')
40
+ for i in range(number_of_story_lines):
41
+ st.markdown(f'**Line {i+1}:** {story[i]}')
42
+ row_name = f'Answer.line{i}_changed.on'
43
+ print(row_name, data[row_name])
44
+ if data[row_name]:
45
+ st.markdown(f'<mark style="background-color: white">{data[f"Answer.story_text_{i}_changed"]}</mark>', unsafe_allow_html=True)
46
+ # st.text_area(
47
+ # '',
48
+ # value=data[f'Answer.story_text_{i}_changed'],
49
+ # height=20,
50
+ # disabled=True,
51
+ # label_visibility='hidden'
52
+ # )
53
+
54
+
55
+ def show_data():
56
+ col1, col2 = st.columns(2)
57
+
58
+ with col1:
59
+ img1, img2, img3 = st.columns(3)
60
+ with img1:
61
+ st.image(data['Input.image1'])
62
+ with img2:
63
+ st.image(data['Input.image2'])
64
+ with img3:
65
+ st.image(data['Input.image3'])
66
+
67
+ st.subheader('Entity')
68
+ st.write(data['Input.entity'])
69
+ st.subheader('Agent')
70
+ st.write(data['Input.agent'])
71
+ # st.subheader('Input Goal')
72
+ # st.write(data['Input.goal'])
73
+ st.subheader('Story')
74
+ st.write(data['Input.story'])
75
+
76
+ with col2:
77
+ st.subheader('Goal')
78
+ st.write(data['Answer.goal'])
79
+ st.subheader('Condition Necessary')
80
+ st.write(data['Answer.condition'])
81
+ st.subheader('Altered Condition')
82
+ st.write(data['Answer.not_condition'])
83
+ st.subheader('Lead to Altered Condition')
84
+ st.write(data['Answer.not_condition_ep'])
85
+
86
+ # if data['Answer.story_impact.yes'] == True:
87
+ # show_story()
88
+ # else:
89
+ # st.subheader('Why no impact?')
90
+ # st.text(data['Answer.why_no_impact'])
91
+ # print(data)
92
+
93
+ from api import show_likert_scale
94
+ done = show_likert_scale('step_3', 'Lead to Altered Condition', data['AssignmentId'])
95
+
96
+ if st.button("Next", disabled=not done):
97
+ id = file_id + 1
98
+ st.experimental_set_query_params(id3=id)
99
+ st.experimental_rerun()
100
+
101
+
102
+ # st.table(data)
103
+
104
+ show_data()
pages/04_Step 4: Story.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+ from auth import check_password
5
+
6
+ if not check_password():
7
+ st.stop()
8
+
9
+ st.set_page_config(
10
+ page_title="ARL - Pilot 2a",
11
+ page_icon="πŸŽ†",
12
+ layout="wide",
13
+ )
14
+
15
+ df = pd.read_csv('./results.csv')
16
+ print(df.columns)
17
+
18
+
19
+ query = st.experimental_get_query_params()
20
+ if not query or 'id4' not in query or not query['id4']:
21
+ rnd_ind = random.randint(0, len(df) - 1)
22
+ # id = rnd_ind
23
+ id = 0
24
+ st.experimental_set_query_params(id4=id)
25
+ file_id = id
26
+ else:
27
+ file_id = int(query['id4'][0])
28
+
29
+
30
+ st.experimental_set_query_params(id4=file_id)
31
+
32
+ data = df.iloc[file_id]
33
+ # st.table(data)
34
+
35
+
36
+ def show_story():
37
+ st.subheader('Impacted Story')
38
+ number_of_story_lines = int(data['Input.number_of_lines'])
39
+ print(number_of_story_lines)
40
+ story = data['Input.story'].split('. ')
41
+ for i in range(number_of_story_lines):
42
+ row_name = f'Answer.line{i}_changed.on'
43
+ print(row_name, data[row_name])
44
+ if data[row_name]:
45
+ st.markdown(f'**Line {i+1}:** <mark style="background-color: white">{story[i]}</mark>', unsafe_allow_html=True)
46
+ else:
47
+ st.markdown(f'**Line {i+1}:** {story[i]}')
48
+
49
+
50
+ def show_data():
51
+ col1, col2 = st.columns(2)
52
+
53
+ with col1:
54
+ img1, img2, img3 = st.columns(3)
55
+ with img1:
56
+ st.image(data['Input.image1'])
57
+ with img2:
58
+ st.image(data['Input.image2'])
59
+ with img3:
60
+ st.image(data['Input.image3'])
61
+
62
+ st.subheader('Entity')
63
+ st.write(data['Input.entity'])
64
+ st.subheader('Agent')
65
+ st.write(data['Input.agent'])
66
+ # st.subheader('Input Goal')
67
+ # st.write(data['Input.goal'])
68
+ st.subheader('Story')
69
+ st.write(data['Input.story'])
70
+
71
+ with col2:
72
+ st.subheader('Goal')
73
+ st.write(data['Answer.goal'])
74
+ st.subheader('Condition Necessary')
75
+ st.write(data['Answer.condition'])
76
+ st.subheader('Altered Condition')
77
+ st.write(data['Answer.not_condition'])
78
+ st.subheader('Lead to Altered Condition')
79
+ st.write(data['Answer.not_condition_ep'])
80
+
81
+ print("*****", data['Answer.story_impact.yes'])
82
+
83
+ if data['Answer.story_impact.yes']:
84
+ print("*****", data['Answer.story_impact.yes'])
85
+ show_story()
86
+ else:
87
+ st.subheader('Why no impact?')
88
+ st.text(data['Answer.why_no_impact'])
89
+ print(data)
90
+
91
+ from api import show_likert_scale
92
+ done = show_likert_scale('step_4', 'Rewritten Story', data['AssignmentId'])
93
+
94
+ if st.button("Next", disabled=not done):
95
+ id = file_id + 1
96
+ st.experimental_set_query_params(id4=id)
97
+ st.experimental_rerun()
98
+
99
+
100
+ # st.table(data)
101
+
102
+ show_data()
pages/results.csv ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ google-cloud-firestore
2
+ path
results.csv ADDED
The diff for this file is too large to render. See raw diff