|
import streamlit as st |
|
import pandas as pd |
|
import random |
|
from auth import check_password |
|
|
|
if not check_password(): |
|
st.stop() |
|
|
|
st.set_page_config( |
|
page_title="ARL - Pilot 2a", |
|
page_icon="π", |
|
layout="wide", |
|
) |
|
|
|
df = pd.read_csv('./results.csv') |
|
print(df.columns) |
|
|
|
|
|
query = st.experimental_get_query_params() |
|
if not query or 'id2' not in query or not query['id2']: |
|
rnd_ind = random.randint(0, len(df) - 1) |
|
|
|
id = 0 |
|
st.experimental_set_query_params(id2=id) |
|
file_id = id |
|
else: |
|
file_id = int(query['id2'][0]) |
|
|
|
|
|
st.experimental_set_query_params(id2=file_id) |
|
|
|
data = df.iloc[file_id] |
|
|
|
|
|
|
|
def show_story(): |
|
st.subheader('Impacted Story') |
|
number_of_story_lines = int(data['Input.number_of_lines']) |
|
story = data['Input.story'].split('. ') |
|
for i in range(number_of_story_lines): |
|
st.markdown(f'**Line {i+1}:** {story[i]}') |
|
row_name = f'Answer.line{i}_changed.on' |
|
print(row_name, data[row_name]) |
|
if data[row_name]: |
|
st.markdown(f'<mark style="background-color: white">{data[f"Answer.story_text_{i}_changed"]}</mark>', unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_data(): |
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
img1, img2, img3 = st.columns(3) |
|
with img1: |
|
st.image(data['Input.image1']) |
|
with img2: |
|
st.image(data['Input.image2']) |
|
with img3: |
|
st.image(data['Input.image3']) |
|
|
|
st.subheader('Entity') |
|
st.write(data['Input.entity']) |
|
st.subheader('Agent') |
|
st.write(data['Input.agent']) |
|
st.subheader('Input Goal') |
|
st.write(data['Input.goal']) |
|
st.subheader('Story') |
|
st.write(data['Input.story']) |
|
|
|
with col2: |
|
st.subheader('Goal') |
|
st.write(data['Answer.goal']) |
|
st.subheader('Condition Necessary') |
|
st.write(data['Answer.condition']) |
|
st.subheader('Altered Condition') |
|
st.write(data['Answer.not_condition']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from api import show_likert_scale |
|
done = show_likert_scale('step_2', 'Altered Condition', data['AssignmentId']) |
|
|
|
if st.button("Next", disabled=not done): |
|
id = file_id + 1 |
|
st.experimental_set_query_params(id2=id) |
|
st.experimental_rerun() |
|
|
|
|
|
|
|
|
|
show_data() |