def report_student(request): group = getGroupNameByRequest(request) if group != 'students': return redirect('student_index') form = PaperSearchForm() return render_to_response('report_paper.html', {'form': form}, context_instance=RequestContext(request))
def index(request): group = getGroupNameByRequest(request) logger.debug("user group:%s" % group) if group == 'teachers': return redirect('teacher_index') if group == 'students': return redirect('student_index') messages.add_message( request, messages.INFO, 'User has no permission for broswering, please contact admin') return redirect('login')
def report_teacher(request): group = getGroupNameByRequest(request) if group != 'teachers': return redirect('teacher_index') form = PaperSearchForm() if request.method == 'POST': pids = request.POST.get('paperids') return render_to_response('report_paper.html', { 'form': form, 'pids': pids, 'group': group }, context_instance=RequestContext(request)) else: return render_to_response('report_teacher.html', {'form': form}, context_instance=RequestContext(request))
def student_getall(request): group = getGroupNameByRequest(request) if group == "teachers": tp = TProfile.objects.get(user=request.user) logger.debug(tp) students = SProfile.objects.filter(teacher=tp) if students: if len(students) == 0: #queryset is lazy. so if it's empty, it will crash json students = [] else: students = [] response = render_to_response('student_all.json', {"students": students}, context_instance=RequestContext(request)) response['Content-Type'] = 'text/plain; charset=utf-8' response['Cache-Control'] = 'no-cache' return response
def report_studentanswer(request): form = [] group = getGroupNameByRequest(request) #pids = [int(id) for id in request.POST.get('pids')] #stuids = [int(id) for id in request.POST.get('stuids')] if request.method == "POST": logger.debug("request.POST: %s" % request.POST) #get table list of all found papers after select table step 1 paperids = request.POST.get('paperids') pids = [] stuids = [] if paperids: try: paper_stu = re.findall(r'\{pid\:(\d+)\,\sstuid\:(\d+)\}', paperids) except Exception, e: logger.error(e) for pid, stuid in paper_stu: pids.append(int(pid)) stuids.append(int(stuid)) form = DetailSearchForm(paper=pids, student=stuids) return render_to_response('report_studentanswer.html', { 'form': form, 'group': group, 'pids': json.dumps(pids), 'stuids': json.dumps(stuids), 'student_id': stuids[0] if stuids else None, 'paper_id': pids[0] if pids else None, }, context_instance=RequestContext(request)) else: #get specified papers of students after select table step 2 try: pids = [ int(id) for id in request.POST.get('pids').strip('[]').split(',') ] stuids = [ int(id) for id in request.POST.get('stuids').strip('[]').split(',') ] form = DetailSearchForm(request.POST, paper=pids, student=stuids) except Exception, e: logger.error(e) if form and form.is_valid(): student = form.cleaned_data['student'] paper = form.cleaned_data['paper'] else: if not stuids or not pids: return HttpResponse("students or papers do not exist") logger.info("stuids[0]:%s,pids[0]:%s ok!" % (stuids[0], pids[0])) try: student = SProfile.objects.get(user__id=stuids[0]) paper = Paper.objects.get(id=pids[0]) except Exception, e: logger.error(e) student = None paper = None
def feedback_popup(request, pid, stuid): group = getGroupNameByRequest(request) qid = request.GET.get("question_id") if group != 'students': paper = Paper.objects.get(id=pid) s_profile = SProfile.objects.get(user=stuid) fb, s = StudentAnswer.objects.get_or_create(question=qid, student=s_profile) if request.method == 'POST': form = FeedbackForm(request.POST) if form.is_valid(): fback = request.POST['Add_Feedback'] fb_code = request.POST['Add_Feedback_Code'] fb.feedback = fback fb.feedback_code = fb_code fb.save() return HttpResponse(json.dumps({"success": True})) else: return HttpResponse( json.dumps({ "success": False, "errors": form.errors })) form = FeedbackForm() return render_to_response('fb_popup.html', { 'form': form, 'pid': pid, 'stuid': stuid, 'fb': fb, 'qid': qid }, context_instance=RequestContext(request)) else: """ The else part is user for show the student report and able to print that report """ qset = [] student = request.user paper = Paper.objects.get(id=pid) questionseq = pickle.loads(str( paper.questionseq)) #question sequence are added into this part print "paper question sequence", paper.questionseq print "question sequence", questionseq for q in questionseq: qset.append(Question.objects.get(id=q)) # print "qset" , qset stuanswer_set = getTakedStuanswers(qset, student) video_set = get_videoForQuestion(qset) print "video SETTTTTT", video_set # print "stu_answer set" , stuanswer_set total_mark = 0 stud_mark = 0 for q in stuanswer_set: marks = q.question.markscheme.split(",") marks = [mark.strip() for mark in marks] mark_set = int(marks[marks.index("all") + 1]) mark_set = actual_mark(q) total_mark = total_mark + mark_set stud_mark = stud_mark + q.mark # print "marks", marks # print "mark_set", mark_set # print "total_mark", total_mark # print "stud_mark", stud_mark #try: # fb = AssignmentFeedback.objects.get(Assignment = paper.assignment, # Student = student # ) common_student_video = map(None, stuanswer_set, video_set) # print "studend answer set" , stuanswer_set # print "stu_answer_set *** ", stuanswer_set # return render_to_response('report_feedback_report.html', # {'user':student,'paper':paper,'stu':stuanswer_set, # 'sum':total_mark,'smark':stud_mark, # 'print': True if request.is_ajax() else False,'len':len(questionseq), # }) print "******** zipped List ********", common_student_video return render_to_response( 'report_feedback_report.html', { 'user': student, 'paper': paper, 'stu': common_student_video, 'sum': total_mark, 'smark': stud_mark, 'print': True if request.is_ajax() else False, 'len': len(questionseq), })