]> code.communitydata.science - coldcallbot-discord.git/commitdiff
Merge remote-tracking branch 'flask_repo/main' into flask flask
authorBenjamin Mako Hill <mako@atdot.cc>
Sat, 28 Sep 2024 19:38:06 +0000 (12:38 -0700)
committerBenjamin Mako Hill <mako@atdot.cc>
Sat, 28 Sep 2024 19:38:06 +0000 (12:38 -0700)
1  2 
.gitignore
flask_app/app.py
flask_app/static/process_button.js
flask_app/templates/cold_caller.html

diff --combined .gitignore
index 9b5e2e844964d81839c3a08e41fd6ac395a1187f,b04e7204108eab27a947f4a9bb353458dc0f4454..9b00fb85fc7a432256854cca19f30bb5d9803120
@@@ -1,2 -1,3 +1,3 @@@
 -config.py
 -__pycache__/
 +*~
 +__pycache__
+ *.pyc
diff --combined flask_app/app.py
index c113e450e76c18c58e188e6813dffcd572e17c19,d484b45dd9d9f1e31dcdf6465d63b8f737467aa9..d484b45dd9d9f1e31dcdf6465d63b8f737467aa9
--- 2/app.py
@@@ -19,6 -19,7 +19,7 @@@ def response_quality()
      student_name = request.form['studentName']
      button_value = request.form['buttonValue']
      course = request.form['course']
+     print(button_value)
  
      fn = f'../assessments/{course}/{course}.csv'
  
      else:
          answered = 'T'
  
-     write_to_file(student_name, fn,
-             answered=answered,
-             assessment=button_value)
-     return 'Received feedback from ' + student_name + ': ' + button_value
+     if button_value != 'get_next':
+         write_to_file(student_name, fn,
+                 answered=answered,
+                 assessment=button_value)
+     student = coldcall_student(course)
+     print(f'Sending {student}')
+     return student
  
  @app.route("/coldcaller/<course>", methods=['POST','GET'])
  def coldcaller(course):
-     if course not in ["com_304","com_411","com_674"]:
-         abort(404)
+     public = request.args.get('public')
+     print(public)
+     if request.method == "POST":
+         student = coldcall_student(course)
+         if not student:
+             abort(404)
+     else:
+         student = ''
+     return render_template('cold_caller.html', student=student, public=public)
+ def coldcall_student(course):
+     if course not in ["com_304","com_411","com_674", "amap"]:
+         return None
      weight = 2
      students = pd.read_csv(f'../assessments/{course}/{course}_students.csv').Name
-     student = ''
      out_fn = f'../assessments/{course}/{course}.csv'
      caller = Caller(out_fn, students, weight)
-     if request.method == "POST":
-         student = caller.get_random_student()
-     return render_template('cold_caller.html', student=student)
+     student = caller.get_random_student()
+     return student
  
  @app.route("/shuffler", methods=['POST','GET']) 
  def shuffler():
@@@ -112,6 -124,7 +124,7 @@@ class Caller
              self.absent_today = df.loc[(df.date==self.today) & (df.answered.isin(['F', 'FALSE'])), 'name']
          except FileNotFoundError or IndexError:
              times_called = pd.DataFrame()
+             self.absent_today = pd.DataFrame()
          return times_called
  
      def update_weight(self, student):
          else:
              curr_weights = self.weights_dict
          for student in set(self.absent_today):
-             print(curr_weights.keys())
-             print(student in curr_weights)
              if student != self.last_chosen:
                  del curr_weights[student]
          rand_student = choices(list(curr_weights.keys()), weights=list(curr_weights.values()), k=1)[0]
index 6bea8a241759e944750a1ca8fc816425cc20c58a,150f8d2cc894dec387d484aed9bf2a14c164bf29..150f8d2cc894dec387d484aed9bf2a14c164bf29
@@@ -1,5 -1,5 +1,5 @@@
  $(document).ready(function() {
-    $('#goodButton, #badButton, #neutralButton, #absentButton').on('click', function() {
+    $('#goodButton, #badButton, #neutralButton, #absentButton, #nextButton').on('click', function() {
         var studentName = $('#studentName').text();
         console.log(studentName);
         var buttonValue = $(this).val();
@@@ -13,7 -13,7 +13,7 @@@
                course: courseCode
             },
             success: function(response) {
-               console.log(response);
+               $('#studentName').text(response);
             },
             error: function(error) {
                console.log(error);
index 0a149fd09d2e0b2c8bfd96dd77f89ffb38d60974,d05f17aa8e38cba2e21ee98270625bf41894ee1e..d05f17aa8e38cba2e21ee98270625bf41894ee1e
@@@ -13,17 -13,29 +13,29 @@@ The next student is
  
  <h2 id='studentName' name='studentName'>{{student}}</h2>
  
- <form method="post" id="todo-form">
-         <button class='rand-button' type="submit">Get random student</button>
  
- </form>
+ {% if student != '' %}
  
  
+   {% if public is none %}
  <button class='assessment' id="goodButton" value="G">Good</button>
  <button class='assessment' id="badButton" value="B">Bad</button>
  <button class='assessment' id="neutralButton" value="M">Neutral</button>
  <button class='assessment' id="absentButton" value="absent">Absent</button>
+ <button class='assessment' id="nextButton" value="get_next">Skip</button>
+   {% else %}
+ <button class='assessment' id="neutralButton" value="?">Next Student</button>
+ <button class='assessment' id="absentButton" value="absent">Absent</button>
+   {% endif %}
  
+ {% else %}
+ <form method="post" id="todo-form">
+         <button class='rand-button' type="submit">Get random student</button>
+ </form>
+ {% endif %}
  
  </body>
  </html>

Community Data Science Collective || Want to submit a patch?