def photo_flash_card(request, year=None): """ Simple flash card game """ students = Student.objects.filter(inactive=False) grade_levels = GradeLevel.objects.all() try: if request.POST: form = StudentLookupForm(request.POST, request.FILES) if form.is_valid(): student_id = form.cleaned_data['student'] else: student_id = students.order_by('?')[0].pk else: form = StudentLookupForm() if year: student_id = students.filter(year=GradeLevel.objects.get( id=year)).order_by('?')[0].pk else: student_id = students.order_by('?')[0].pk student = Student.objects.filter(inactive=False).get(pk=student_id) except: messages.error(request, 'Student not found') return HttpResponseRedirect(reverse('admin:index')) return render_to_response( 'sis/flashcard.html', { 'form': form, 'student_name': student, 'grade_levels': grade_levels, 'student_img': student.pic.url_530x400, 'request': request }, RequestContext(request, {}))
def photo_flash_card(request, year=None): """ Simple flash card game """ students = Student.objects.filter(is_active=True) grade_levels = GradeLevel.objects.all() try: if request.POST: form = StudentLookupForm(request.POST, request.FILES) if form.is_valid(): student_id = form.cleaned_data['student'] else: student_id = students.order_by('?')[0].pk else: form = StudentLookupForm() if year: student_id = students.filter(year=GradeLevel.objects.get(id=year)).order_by('?')[0].pk else: student_id = students.order_by('?')[0].pk student = Student.objects.filter(is_active=True).get(pk=student_id) except: messages.error(request, 'Student not found') return HttpResponseRedirect(reverse('admin:index')) return render_to_response('sis/flashcard.html', {'form': form, 'student_name': student, 'grade_levels':grade_levels, 'student_img': student.pic.url_530x400, 'request': request}, RequestContext(request, {}))
def view_student(request, id=None): """ Lookup all student information """ if request.method == "GET": if id and 'next' in request.GET or 'previous' in request.GET: current_student = get_object_or_404(Student, pk=id) found = False preference = UserPreference.objects.get_or_create( user=request.user)[0] if 'next' in request.GET: if preference.include_deleted_students: students = Student.objects.order_by('lname', 'fname') else: students = Student.objects.filter(inactive=False).order_by( 'lname', 'fname') elif 'previous' in request.GET: if preference.include_deleted_students: students = Student.objects.order_by('-lname', '-fname') else: students = Student.objects.filter(inactive=False).order_by( '-lname', '-fname') for student in students: if found: return HttpResponseRedirect('/sis/view_student/' + str(student.id)) if student == current_student: found = True if request.method == 'POST': form = StudentLookupForm(request.POST) if form.is_valid(): return HttpResponseRedirect('/sis/view_student/' + str(form.cleaned_data['student'].id)) profile = UserPreference.objects.get_or_create(user=request.user)[0] if id: student = get_object_or_404(Student, pk=id) else: messages.warning(request, 'No Student Selected') return render_to_response( 'sis/view_student.html', { 'include_inactive': profile.include_deleted_students, }, RequestContext(request, {}), ) today = date.today() emergency_contacts = student.emergency_contacts.all() siblings = student.siblings.all() numbers = student.studentnumber_set.all() # Schedule cal = Calendar() try: location = cal.find_student(student) except: location = None print >> sys.stderr, str(sys.exc_info()[0]) # Guess the mp desired (current or next coming) schedule_days = None periods = None # look for the current mp first current_mp = MarkingPeriod.objects.filter( start_date__lte=today, end_date__gte=today).order_by('-start_date') # nada? get the next mp (soonest-starting mp ending today or in the future) if not current_mp: current_mp = MarkingPeriod.objects.filter( end_date__gte=today).order_by('start_date') if current_mp: current_mp = current_mp[0] schedule_days, periods = cal.build_schedule(student, current_mp, include_asp=True) else: schedule_days = None periods = None # Discipline if 'ecwsp.discipline' in settings.INSTALLED_APPS: disciplines = student.studentdiscipline_set.all() else: disciplines = None #### CWSP related try: clientvisits = student.studentworker.clientvisit_set.all() except: clientvisits = None try: company_histories = student.studentworker.companyhistory_set.all() except: company_histories = None try: timesheets = student.studentworker.timesheet_set.exclude( Q(performance__isnull=True) | Q(performance__exact='')) except: timesheets = None try: if request.user.has_perm("sis.view_mentor_student"): student_interactions = student.studentworker.studentinteraction_set.all( ) else: student_interactions = None except: student_interactions = None try: supervisors = student.studentworker.placement.contacts.all() except: supervisors = None ######################################################################## #Grades years = SchoolYear.objects.filter( markingperiod__course__courseenrollment__user=student).distinct() from ecwsp.grades.models import Grade for year in years: year.mps = MarkingPeriod.objects.filter( course__courseenrollment__user=student, school_year=year).distinct().order_by("start_date") year.courses = Course.objects.filter( courseenrollment__user=student, graded=True, marking_period__school_year=year).distinct() for course in year.courses: # Too much logic for the template here, so just generate html. course.grade_html = "" for marking_period in year.mps: try: course.grade_html += '<td> %s </td>' % (Grade.objects.get( student=student, course=course, marking_period=marking_period).get_grade(), ) except: course.grade_html += '<td> </td>' course.grade_html += '<td> %s </td>' % (unicode( course.get_final_grade(student)), ) # Attendance if 'ecwsp.attendance' in settings.INSTALLED_APPS: attendances = student.student_attn.filter( date__range=(year.start_date, year.end_date)) year.attendances = attendances year.attendance_tardy = attendances.filter( status__tardy=True).count() year.attendance_absense = attendances.filter( status__absent=True).count() year.attendance_absense_with_half = year.attendance_absense + float( attendances.filter(status__half=True).count()) / 2 year.total = year.get_number_days() year.present = year.total - year.attendance_tardy - year.attendance_absense_with_half #Standard Tests from ecwsp.administration.models import Configuration if 'ecwsp.standard_test' in settings.INSTALLED_APPS: from ecwsp.standard_test.models import StandardCategory, StandardCategoryGrade, StandardTest, StandardTestResult standard_tests = StandardTestResult.objects.filter(student=student) else: standard_tests = None return render_to_response( 'sis/view_student.html', { 'date': today, 'student': student, 'emergency_contacts': emergency_contacts, 'siblings': siblings, 'numbers': numbers, 'location': location, 'disciplines': disciplines, 'student_interactions': student_interactions, 'clientvisits': clientvisits, 'supervisors': supervisors, 'company_histories': company_histories, 'timesheets': timesheets, 'years': years, 'current_mp': current_mp, 'schedule_days': schedule_days, 'periods': periods, 'include_inactive': profile.include_deleted_students, 'tests': standard_tests }, RequestContext(request, {}), )
def view_student(request, id=None): """ Lookup all student information """ if request.method == "GET": if id and 'next' in request.GET or 'previous' in request.GET: current_student = get_object_or_404(Student, pk=id) found = False preference = UserPreference.objects.get_or_create(user=request.user)[0] if 'next' in request.GET: if preference.include_deleted_students: students = Student.objects.order_by('last_name','first_name') else: students = Student.objects.filter(is_active=True).order_by('last_name','first_name') elif 'previous' in request.GET: if preference.include_deleted_students: students = Student.objects.order_by('-last_name','-first_name') else: students = Student.objects.filter(is_active=True).order_by('-last_name','-first_name') for student in students: if found: return HttpResponseRedirect('/sis/view_student/' + str(student.id)) if student == current_student: found = True if request.method == 'POST': form = StudentLookupForm(request.POST) if form.is_valid(): return HttpResponseRedirect('/sis/view_student/' + str(form.cleaned_data['student'].id)) profile = UserPreference.objects.get_or_create(user=request.user)[0] if id: student = get_object_or_404(Student, pk=id) else: messages.warning(request, 'No Student Selected') return render_to_response('sis/view_student.html', { 'include_inactive': profile.include_deleted_students, }, RequestContext(request, {}),) today = date.today() emergency_contacts = student.emergency_contacts.all() siblings = student.siblings.all() numbers = student.studentnumber_set.all() # Schedule cal = Calendar() try: location = cal.find_student(student) except: location = None print >> sys.stderr, str(sys.exc_info()[0]) # Guess the mp desired (current or next coming) schedule_days = None periods = None # look for the current mp first current_mp = MarkingPeriod.objects.filter(start_date__lte=today, end_date__gte=today).order_by('-start_date') # nada? get the next mp (soonest-starting mp ending today or in the future) if not current_mp: current_mp = MarkingPeriod.objects.filter(end_date__gte=today).order_by('start_date') if current_mp: current_mp = current_mp[0] schedule_days, periods = cal.build_schedule(student, current_mp, include_asp=True) else: schedule_days = None periods = None # Discipline if 'ecwsp.discipline' in settings.INSTALLED_APPS: disciplines = student.studentdiscipline_set.all() else: disciplines = None #### CWSP related try: clientvisits = student.studentworker.clientvisit_set.all() except: clientvisits = None try: company_histories = student.studentworker.companyhistory_set.all() except: company_histories = None try: timesheets = student.studentworker.timesheet_set.exclude(Q(performance__isnull=True) | Q(performance__exact='')) except: timesheets = None try: if request.user.has_perm("sis.view_mentor_student"): student_interactions = student.studentworker.studentinteraction_set.all() else: student_interactions = None except: student_interactions = None try: supervisors = student.studentworker.placement.contacts.all() except: supervisors = None ######################################################################## #Grades years = SchoolYear.objects.filter(markingperiod__course__courseenrollment__user=student).distinct() from ecwsp.grades.models import Grade for year in years: year.mps = MarkingPeriod.objects.filter(course__courseenrollment__user=student, school_year=year).distinct().order_by("start_date") year.courses = Course.objects.filter(courseenrollment__user=student, graded=True, marking_period__school_year=year).distinct() for course in year.courses: # Too much logic for the template here, so just generate html. course.grade_html = "" for marking_period in year.mps: try: course.grade_html += '<td> %s </td>' % ( Grade.objects.get(student=student, course=course, marking_period=marking_period).get_grade(),) except: course.grade_html += '<td> </td>' course.grade_html += '<td> %s </td>' % (unicode(course.get_final_grade(student)),) # Attendance if 'ecwsp.attendance' in settings.INSTALLED_APPS: attendances = student.student_attn.filter(date__range=(year.start_date, year.end_date)) year.attendances = attendances year.attendance_tardy = attendances.filter(status__tardy=True).count() year.attendance_absense = attendances.filter(status__absent=True).count() year.attendance_absense_with_half = year.attendance_absense + float(attendances.filter(status__half=True).count()) / 2 year.total = year.get_number_days() year.present = year.total - year.attendance_tardy - year.attendance_absense_with_half #Standard Tests from ecwsp.administration.models import Configuration if 'ecwsp.standard_test' in settings.INSTALLED_APPS: from ecwsp.standard_test.models import StandardCategory, StandardCategoryGrade, StandardTest, StandardTestResult standard_tests = StandardTestResult.objects.filter(student=student) else: standard_tests = None return render_to_response('sis/view_student.html', { 'date':today, 'student':student, 'emergency_contacts': emergency_contacts, 'siblings': siblings, 'numbers':numbers, 'location':location, 'disciplines':disciplines, 'student_interactions': student_interactions, 'clientvisits':clientvisits, 'supervisors':supervisors, 'company_histories':company_histories, 'timesheets':timesheets, 'years': years, 'current_mp': current_mp, 'schedule_days':schedule_days, 'periods': periods, 'include_inactive': profile.include_deleted_students, 'tests': standard_tests }, RequestContext(request, {}),)