Harshal Vhatkar commited on
Commit
5d1504a
·
2 Parent(s): 8d3a72f c787a0a

Merge branch 'main' of https://huggingface.co/spaces/SPJIMR-Internship/SPJIMR_FlipClassroom_RCopilot_ResearchInternship

Browse files
Files changed (2) hide show
  1. inclass_questions.py +39 -39
  2. session_page.py +2 -2
inclass_questions.py CHANGED
@@ -77,48 +77,48 @@ class IntervalQuestionManager:
77
  # self.questions = self._load_existing_questions()
78
  self._initialize_from_db()
79
 
80
- # def _get_start_time(self):
81
- # """Retrieve start time from database"""
82
- # try:
83
- # session_data = courses_collection.find_one(
84
- # {
85
- # "course_id": self.course_id,
86
- # "sessions.session_id": self.session_id
87
- # },
88
- # {"sessions.$": 1}
89
- # )
90
- # if session_data and session_data.get('sessions'):
91
- # session = session_data['sessions'][0]
92
- # interval_data = session.get('in_class', {}).get('interval_questions', {})
93
- # if interval_data and 'start_time' in interval_data:
94
- # return interval_data['start_time']
95
- # return None
96
- # except Exception as e:
97
- # st.error(f"Error getting start time: {e}")
98
- # return None
99
 
100
- # def _load_existing_questions(self) -> List[Dict]:
101
- # """Load existing interval questions from database"""
102
- # try:
103
- # session_data = courses_collection.find_one(
104
- # {
105
- # "course_id": self.course_id,
106
- # "sessions.session_id": self.session_id
107
- # },
108
- # {"sessions.$": 1}
109
- # )
110
 
111
- # if session_data and session_data.get('sessions'):
112
- # session = session_data['sessions'][0]
113
- # interval_data = session.get('in_class', {}).get('interval_questions', {})
114
- # if interval_data and interval_data.get('questions'):
115
- # print("Found existing questions:", len(interval_data['questions']))
116
- # return interval_data['questions']
117
- # return []
118
 
119
- # except Exception as e:
120
- # st.error(f"Error loading questions: {e}")
121
- # return []
122
 
123
  def _initialize_from_db(self):
124
  """Load existing questions and settings from database"""
 
77
  # self.questions = self._load_existing_questions()
78
  self._initialize_from_db()
79
 
80
+ def _get_start_time(self):
81
+ """Retrieve start time from database"""
82
+ try:
83
+ session_data = courses_collection.find_one(
84
+ {
85
+ "course_id": self.course_id,
86
+ "sessions.session_id": self.session_id
87
+ },
88
+ {"sessions.$": 1}
89
+ )
90
+ if session_data and session_data.get('sessions'):
91
+ session = session_data['sessions'][0]
92
+ interval_data = session.get('in_class', {}).get('interval_questions', {})
93
+ if interval_data and 'start_time' in interval_data:
94
+ return interval_data['start_time']
95
+ return None
96
+ except Exception as e:
97
+ st.error(f"Error getting start time: {e}")
98
+ return None
99
 
100
+ def _load_existing_questions(self) -> List[Dict]:
101
+ """Load existing interval questions from database"""
102
+ try:
103
+ session_data = courses_collection.find_one(
104
+ {
105
+ "course_id": self.course_id,
106
+ "sessions.session_id": self.session_id
107
+ },
108
+ {"sessions.$": 1}
109
+ )
110
 
111
+ if session_data and session_data.get('sessions'):
112
+ session = session_data['sessions'][0]
113
+ interval_data = session.get('in_class', {}).get('interval_questions', {})
114
+ if interval_data and interval_data.get('questions'):
115
+ print("Found existing questions:", len(interval_data['questions']))
116
+ return interval_data['questions']
117
+ return []
118
 
119
+ except Exception as e:
120
+ st.error(f"Error loading questions: {e}")
121
+ return []
122
 
123
  def _initialize_from_db(self):
124
  """Load existing questions and settings from database"""
session_page.py CHANGED
@@ -2355,13 +2355,13 @@ def display_in_class_content(session, user_type, course_id, user_id):
2355
  "Number of Questions",
2356
  min_value=2,
2357
  max_value=10,
2358
- value=5
2359
  )
2360
  interval = st.number_input(
2361
  "Minutes Between Questions",
2362
  min_value=5,
2363
  max_value=20,
2364
- value=10
2365
  )
2366
  if st.form_submit_button("Generate Questions"):
2367
  context = get_current_context(session)
 
2355
  "Number of Questions",
2356
  min_value=2,
2357
  max_value=10,
2358
+ # value=5
2359
  )
2360
  interval = st.number_input(
2361
  "Minutes Between Questions",
2362
  min_value=5,
2363
  max_value=20,
2364
+ # value=10
2365
  )
2366
  if st.form_submit_button("Generate Questions"):
2367
  context = get_current_context(session)