Commit
·
f7f3eab
1
Parent(s):
19201aa
update
Browse files- app.py +19 -1
- templates/index.html +1 -1
- templates/subjective.html +2 -9
app.py
CHANGED
@@ -224,6 +224,24 @@ Will it predict the statement as TRUE or FALSE?
|
|
224 |
logger.exception(f"An error occurred in the experiment route: {e}")
|
225 |
return "An error occurred", 500
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
@app.route('/feedback', methods=['POST'])
|
228 |
def feedback():
|
229 |
try:
|
@@ -245,7 +263,7 @@ def feedback():
|
|
245 |
logger.info(f"Prediction saved for session {session_id}, sample {session_data['current_index'] - 1}")
|
246 |
|
247 |
if session_data['current_index'] >= len(session_data['selected_samples']):
|
248 |
-
return redirect(url_for('
|
249 |
|
250 |
return redirect(url_for('experiment', session_id=session_id))
|
251 |
except Exception as e:
|
|
|
224 |
logger.exception(f"An error occurred in the experiment route: {e}")
|
225 |
return "An error occurred", 500
|
226 |
|
227 |
+
|
228 |
+
@app.route('/subjective/<session_id>', methods=['GET', 'POST'])
|
229 |
+
def subjective(session_id):
|
230 |
+
if request.method == 'POST':
|
231 |
+
understanding = request.form.get('understanding')
|
232 |
+
|
233 |
+
session_data = load_session_data(session_id)
|
234 |
+
if not session_data:
|
235 |
+
logger.error(f"No session data found for session: {session_id}")
|
236 |
+
return redirect(url_for('index'))
|
237 |
+
|
238 |
+
session_data['subjective_feedback'] = understanding
|
239 |
+
save_session_data(session_id, session_data, is_update=True)
|
240 |
+
|
241 |
+
return redirect(url_for('completed', session_id=session_id))
|
242 |
+
|
243 |
+
return render_template('subjective.html', session_id=session_id)
|
244 |
+
|
245 |
@app.route('/feedback', methods=['POST'])
|
246 |
def feedback():
|
247 |
try:
|
|
|
263 |
logger.info(f"Prediction saved for session {session_id}, sample {session_data['current_index'] - 1}")
|
264 |
|
265 |
if session_data['current_index'] >= len(session_data['selected_samples']):
|
266 |
+
return redirect(url_for('subjective', session_id=session_id))
|
267 |
|
268 |
return redirect(url_for('experiment', session_id=session_id))
|
269 |
except Exception as e:
|
templates/index.html
CHANGED
@@ -133,7 +133,7 @@
|
|
133 |
</head>
|
134 |
<body>
|
135 |
<div class="container">
|
136 |
-
<h1>Let's get started! Please input your name, a random number, and select one of the
|
137 |
<!-- <div class="instruction">-->
|
138 |
<!-- Let's get started! Please input your name, enter a random number as your seed, and select one of the explanation methods for your experiment.-->
|
139 |
<!-- </div>-->
|
|
|
133 |
</head>
|
134 |
<body>
|
135 |
<div class="container">
|
136 |
+
<h1>Let's get started! Please input your name, a random number, and select one of the below explanation methods for your experiment.</h1>
|
137 |
<!-- <div class="instruction">-->
|
138 |
<!-- Let's get started! Please input your name, enter a random number as your seed, and select one of the explanation methods for your experiment.-->
|
139 |
<!-- </div>-->
|
templates/subjective.html
CHANGED
@@ -52,7 +52,7 @@
|
|
52 |
<body>
|
53 |
<h1>Feedback on Table QA Explanations</h1>
|
54 |
|
55 |
-
<form id="feedbackForm">
|
56 |
<div class="question">
|
57 |
<p>After using the explanations, how much do you think they helped you understand the reasoning process of the Table QA model?</p>
|
58 |
<div class="likert">
|
@@ -82,13 +82,6 @@
|
|
82 |
<button type="submit">Submit Feedback</button>
|
83 |
</form>
|
84 |
|
85 |
-
|
86 |
-
document.getElementById('feedbackForm').addEventListener('submit', function(e) {
|
87 |
-
e.preventDefault();
|
88 |
-
var selectedValue = document.querySelector('input[name="understanding"]:checked').value;
|
89 |
-
alert('Thank you for your feedback! You selected: ' + selectedValue);
|
90 |
-
// Here you can add code to send this data to your server
|
91 |
-
});
|
92 |
-
</script>
|
93 |
</body>
|
94 |
</html>
|
|
|
52 |
<body>
|
53 |
<h1>Feedback on Table QA Explanations</h1>
|
54 |
|
55 |
+
<form id="feedbackForm" action="{{ url_for('subjective', session_id=session_id) }}" method="post">
|
56 |
<div class="question">
|
57 |
<p>After using the explanations, how much do you think they helped you understand the reasoning process of the Table QA model?</p>
|
58 |
<div class="likert">
|
|
|
82 |
<button type="submit">Submit Feedback</button>
|
83 |
</form>
|
84 |
|
85 |
+
<!-- Remove the JavaScript event listener as we're now submitting to the server -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</body>
|
87 |
</html>
|