File size: 3,016 Bytes
2c9fffb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1359365
 
 
2c9fffb
1359365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c9fffb
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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 'id4' not in query or not query['id4']:
    rnd_ind = random.randint(0, len(df) - 1)
    # id = rnd_ind
    id = 0
    st.experimental_set_query_params(id4=id)
    file_id = id
else:
    file_id = int(query['id4'][0])


st.experimental_set_query_params(id4=file_id)

data = df.iloc[file_id]
# st.table(data)


def show_story():
    st.subheader('Impacted Story')
    number_of_story_lines = int(data['Input.number_of_lines'])
    print(number_of_story_lines)
    story = data['Input.story'].split('. ')
    for i in range(number_of_story_lines):
        row_name = f'Answer.line{i}_changed.on'
        print(row_name, data[row_name])
        if data[row_name]:
            st.markdown(f'**Line {i+1}:** <mark style="background-color: white">{story[i]}</mark>', unsafe_allow_html=True)
        else:
            st.markdown(f'**Line {i+1}:** {story[i]}')


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:
        if data['Answer.agent_makes_no_sense.on']:
            st.subheader('Agent Makes No Sense')
            st.write("Proposed Agent: " + data['Answer.agent_makes_no_sense_text'])
        else:
            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'])
            st.subheader('Lead to Altered Condition')
            st.write(data['Answer.not_condition_ep'])

            print("*****", data['Answer.story_impact.yes'])

            if data['Answer.story_impact.yes']:
                print("*****", data['Answer.story_impact.yes'])
                show_story()
            else:
                st.subheader('Why no impact?')
                st.text(data['Answer.why_no_impact'])
                print(data)

    from  api import show_likert_scale
    done = show_likert_scale('step_4', 'Rewritten Story', data['AssignmentId'])

    if st.button("Next", disabled=not done):
        id = file_id + 1
        st.experimental_set_query_params(id4=id)
        st.experimental_rerun()


    # st.table(data)

show_data()