@@ -171,13 +171,13 @@ def practice():
171171 course_start_date = course .term_start_date
172172
173173 start_date = course_start_date + datetime .timedelta (days = 13 )
174- end_date = ""
174+ end_date = start_date + datetime . timedelta ( weeks = 12 ) # provide a reasonable default
175175 max_practice_days = 50
176176 max_practice_questions = 500
177177 day_points = 2
178178 question_points = 0.2
179179 questions_to_complete_day = 10
180- flashcard_creation_method = 0
180+ flashcard_creation_method = 2
181181 graded = 1
182182 spacing = 0
183183 interleaving = 0
@@ -192,25 +192,39 @@ def practice():
192192 error_graded = 0
193193
194194 already_exists = 0
195- any_practice_settings = db (db .course_practice .auth_user_id == auth .user .id )
195+ any_practice_settings = db (
196+ (db .course_practice .auth_user_id == auth .user .id )
197+ | (db .course_practice .course_name == course .course_name )
198+ )
199+
196200 practice_settings = any_practice_settings (
197201 db .course_practice .course_name == course .course_name
198202 )
199203 # If the instructor has created practice for other courses, don't randomize spacing and interleaving for the new
200204 # course.
201205 if not any_practice_settings .isempty ():
202- any_practice_settings = any_practice_settings .select ().first ()
206+ any_practice_settings = any_practice_settings .select (
207+ orderby = ~ db .course_practice .id
208+ ).first ()
203209 spacing = any_practice_settings .spacing
204210 interleaving = any_practice_settings .interleaving
205211
206212 # Now checking to see if there are practice settings for this course.
207213 # If not, stick with the defaults.
208214 if (
209215 not practice_settings .isempty ()
210- and practice_settings .select ().first ().end_date is not None
211- and practice_settings .select ().first ().end_date != ""
216+ and practice_settings .select (orderby = ~ db .course_practice .id )
217+ .first ()
218+ .end_date
219+ is not None
220+ and practice_settings .select (orderby = ~ db .course_practice .id )
221+ .first ()
222+ .end_date
223+ != ""
212224 ):
213- practice_setting = practice_settings .select ().first ()
225+ practice_setting = practice_settings .select (
226+ orderby = ~ db .course_practice .id
227+ ).first ()
214228 start_date = practice_setting .start_date
215229 end_date = practice_setting .end_date
216230 max_practice_days = practice_setting .max_practice_days
@@ -228,7 +242,7 @@ def practice():
228242 spacing = 1
229243 if randint (0 , 1 ) == 1 :
230244 interleaving = 1
231- if practice_settings .isempty ():
245+ if practice_settings .isempty (): # If there are no settings for THIS course
232246 db .course_practice .insert (
233247 auth_user_id = auth .user .id ,
234248 course_name = course .course_name ,
0 commit comments