コード例 #1
0
def student_management(request, module_id):
    """
    View to dsplay all the students enrolled.
    It is used by the instructor to filter the 
    accounts he wants to be shown in the class spreadsheet
    """
    course_module = CourseModule.objects.get(id=module_id)
    book = None
    for i_bk in Books.objects.filter(courses=course_module.course_instance):
        book = i_bk
    if is_authorized(request.user, book.book_name, course_module.course_instance.instance_name):
        return class_students(request, module_id)
    return HttpResponseForbidden("<h1>No class activity</h1>")
コード例 #2
0
ファイル: views.py プロジェクト: OpenDSA/OpenDSA-devserver
def student_management(request, module_id):
    """
    View to dsplay all the students enrolled.
    It is used by the instructor to filter the 
    accounts he wants to be shown in the class spreadsheet
    """
    course_module = CourseModule.objects.get(id=module_id)
    book = None
    for i_bk in  Books.objects.filter(courses=course_module.course_instance):
        book = i_bk
    if is_authorized(request.user, book.book_name, \
                     course_module.course_instance.instance_name): 
        return class_students(request, module_id)
    return HttpResponseForbidden('<h1>No class activity</h1>')
コード例 #3
0
def exercise_summary(request, book, course):
    """
    View creating the data displayed in the class activity spreadsheet
    """
    if is_authorized(request.user, book, course):
        obj_book = Books.objects.get(book_name=book)
        udata_list = []
        udata_list1 = []
        columns_list = []
        columns_list1 = []
        columns_list_exe = []  # for exercises
        columns_list.append({"sTitle": "Id"})
        columns_list.append({"sTitle": "Username"})
        columns_list.append({"sTitle": "Email"})
        columns_list.append({"sTitle": "Score(%)"})
        columns_list1.append({"sTitle": "Id"})
        columns_list1.append({"sTitle": "Username"})
        columns_list1.append({"sTitle": "Email"})
        columns_list1.append({"sTitle": "Score(%)"})
        # get list of book assignments
        assignments_list = (
            Assignments.objects.select_related()
            .filter(assignment_book=obj_book)
            .order_by("course_module__closing_time")
        )
        max_assignments_points = 0
        students_assignment_points = []
        u_book = UserBook.objects.filter(book=obj_book)
        exe_bme = {}
        assign_exe = {}
        for assignment in assignments_list:
            columns_list.append({"sTitle": str(assignment.course_module.name)})
            columns_list1.append({"sTitle": str(assignment.course_module.name)})
            assign_exe[assignment.course_module.name] = assignment.get_exercises()
            for exercise in assign_exe[assignment.course_module.name]:
                if BookModuleExercise.components.filter(book=obj_book, exercise=exercise).count() == 0:
                    continue
                bexe = BookModuleExercise.components.filter(book=obj_book, exercise=exercise)[0]
                exe_bme[exercise.name] = bexe

                max_assignments_points += Decimal(bexe.points)

                columns_list.append(
                    {
                        "sTitle": str(exercise.name)
                        + "("
                        + str(bexe.points)
                        + ")"
                        + '<span class="details" \
                                         style="display:inline;" \
                                         data-type="'
                        + str(exercise.description)
                        + '"></span>',
                        "sClass": "center",
                    }
                )
        userData = UserData.objects.select_related().filter(book=obj_book, user__is_staff=0).order_by("user")

        users = []
        for userdata in userData:
            if not userdata.user.is_staff and display_grade(userdata.user, obj_book):
                u_points = 0
                u_data = []
                u_data.append(0)
                u_data.append(str(userdata.user.username))
                u_data.append(str(userdata.user.email))
                u_data.append(0)
                u_data1 = []
                u_data1.append(0)
                u_data1.append(str(userdata.user.username))
                u_data1.append(str(userdata.user.email))
                u_data1.append(0)

                for assignment in assignments_list:
                    # get points of exercises
                    assignment_points = 0
                    students_assignment_points = 0
                    u_assign = []
                    u_assign1 = []
                    u_assign.append(0)

                    for exercise in assign_exe[assignment.course_module.name]:
                        bexe = exe_bme[exercise.name]
                        u_ex = None
                        user_exe = UserExercise.objects.filter(user=userdata.user, exercise=exercise)
                        if not user_exe and (not exercise.id in userdata.get_prof_list()):
                            exe_str = ""
                            # continue
                        else:
                            user_exe = user_exe[0]
                            u_ex = user_exe
                            assignment_points += Decimal(bexe.points)
                            exe_str = ""
                            if exercise.id in userdata.get_prof_list():
                                u_points += Decimal(bexe.points)
                                students_assignment_points += Decimal(bexe.points)
                                if u_ex.proficient_date <= assignment.course_module.closing_time:
                                    exe_str = (
                                        '<span class="details" \
                                          style="display:inline;" \
                                          data-type="First done:%s, \
                                          Last done:%s, Total done:%i, \
                                          Total correct:%i, \
                                          Proficiency date:%s">Done</span>'
                                        % (
                                            str(u_ex.first_done),
                                            str(u_ex.last_done),
                                            int(u_ex.total_done),
                                            int(u_ex.total_correct),
                                            str(u_ex.proficient_date),
                                        )
                                    )
                                else:
                                    exe_str = (
                                        '<span class="details" \
                                          style="display:inline;" \
                                          data-type="First done:%s, \
                                          Last done:%s, Total done:%i, \
                                          Total correct:%i, \
                                          Proficiency date:%s">Late</span>'
                                        % (
                                            str(u_ex.first_done),
                                            str(u_ex.last_done),
                                            int(u_ex.total_done),
                                            int(u_ex.total_correct),
                                            str(u_ex.proficient_date),
                                        )
                                    )
                            if (
                                exercise.id in userdata.get_started_list()
                                and exercise.id not in userdata.get_prof_list()
                            ):
                                exe_str = (
                                    '<span class="details" \
                                      style="visibility: hidden; \
                                      display:inline;" \
                                      data-type="First done:%s, \
                                      Last done:%s, Total done:%i, \
                                      Total correct:%i, \
                                      Proficiency date:%s">Started</span>'
                                    % (
                                        str(u_ex.first_done),
                                        str(u_ex.last_done),
                                        int(u_ex.total_done),
                                        int(u_ex.total_correct),
                                        str(u_ex.proficient_date),
                                    )
                                )

                        u_assign.append(exe_str)
                    u_assign[0] = str(students_assignment_points)
                    u_data = u_data + u_assign
                    u_data1.append(str(students_assignment_points))

                u_points = (u_points * 100) / max_assignments_points
                u_data[3] = str("%.2f" % round(u_points, 2))
                udata_list.append(u_data)
                u_data1[3] = str("%.2f" % round(u_points, 2))
                udata_list1.append(u_data1)

        context = RequestContext(
            request,
            {
                "book": book,
                "max_points": max_assignments_points,
                "course": course,
                "udata_list": udata_list,
                "columns_list": columns_list,
                "udata_list1": udata_list1,
                "columns_list1": columns_list1,
            },
        )
        return render_to_response("opendsa/class_summary.html", context)
    else:
        return HttpResponseForbidden("<h1>Page Forbidden</h1>")
コード例 #4
0
ファイル: views.py プロジェクト: OpenDSA/OpenDSA-devserver
def exercise_summary(request, book, course):
    """
    View creating the data displayed in the class assignments activity spreadsheet
    """
    if is_authorized(request.user, book, course):
        obj_book = Books.objects.get(book_name = book)
        udata_list = []
        udata_list1 = []
        wrong_exe = []
        columns_list = []
        columns_list1 = []
        columns_list_exe = []  #for exercises
        columns_list.append({"sTitle":"Id"})
        columns_list.append({"sTitle":"Username"})
        columns_list.append({"sTitle":"Email"})
        columns_list.append({"sTitle":"Score(%)"})
        columns_list1.append({"sTitle":"Id"})
        columns_list1.append({"sTitle":"Username"})
        columns_list1.append({"sTitle":"Email"})
        columns_list1.append({"sTitle":"Score(%)"})
        #get list of book assignments
        assignments_list = Assignments.objects.select_related().filter( \
                           assignment_book=obj_book).order_by( \
                                'course_module__closing_time')
        max_assignments_points = 0
        students_assignment_points = []
        u_book = UserBook.objects.filter(book = obj_book)
        exe_bme = {}
        assign_exe = {}
        assignments_list_tmp = []
        for assignment in assignments_list:
            if assignment.course_module.course_instance.instance_name == course:
                assignments_list_tmp.append(assignment)
                columns_list.append({"sTitle":str(assignment.course_module.name)})
                columns_list1.append({"sTitle":str(assignment.course_module.name)})
                assign_exe[assignment.course_module.name] = assignment.get_exercises()
                for exercise in assign_exe[assignment.course_module.name]:
                    if BookModuleExercise.components.filter( \
                                             book = obj_book, \
                                             exercise = exercise).count() == 0:
                        continue
                    bexe = BookModuleExercise.components.filter( \
                                               book = obj_book, \
                                               exercise = exercise)[0]
                    exe_bme[exercise.name] = bexe
  
                    max_assignments_points += Decimal(bexe.points)
  
                    columns_list.append({"sTitle":str(exercise.name)+ \
                                         '('+str(bexe.points)+')'+ \
                                         '<span class="details" \
                                         style="display:inline;" \
                                         data-type="' + \
                                         str(exercise.description) + \
                                         '"></span>',"sClass": "center" })

        #we only work assignments relevants to this course instance
        assignments_list = assignments_list_tmp
        userData = UserData.objects.select_related().filter( \
                                                     book = obj_book, \
                                                     user__is_staff = 0 \
                                                     ).order_by('user')
        
        users = []
        for userdata in userData:
            if not userdata.user.is_staff and display_grade( \
                                              userdata.user, obj_book):
                u_points = 0
                u_data = []
                u_data.append(0)
                u_data.append(str(userdata.user.username))
                u_data.append(str(userdata.user.email))
                u_data.append(0)
                u_data1 = []
                u_data1.append(0)
                u_data1.append(str(userdata.user.username))
                u_data1.append(str(userdata.user.email))
                u_data1.append(0)

                for assignment in assignments_list:
                    #get points of exercises
                    assignment_points = 0
                    students_assignment_points = 0
                    u_assign = []
                    u_assign1 = []
                    u_assign.append(0)

                    for exercise in assign_exe[assignment.course_module.name]:
                        if exercise.name not in  exe_bme:
                            if exercise.name not in wrong_exe:
                                wrong_exe.append(str(exercise.name))
                            continue

                        bexe = exe_bme[exercise.name]
                        u_ex = None
                        user_exe = UserExercise.objects.filter( \
                                                user = userdata.user, \
                                                exercise = exercise)
                        if not user_exe and (not exercise.id in userdata.get_prof_list()):
                            exe_str = ''
                            #continue 
                        else:
                            user_exe = user_exe[0]
                            u_ex = user_exe
                            assignment_points += Decimal(bexe.points)
                            exe_str = ''
                            if exercise.id in userdata.get_prof_list():
                                #u_points += Decimal(bexe.points) 
                                #students_assignment_points += Decimal(bexe.points) 
                                if u_ex.proficient_date <= \
                                    assignment.course_module.closing_time:
                                    u_points += Decimal(bexe.points)
                                    students_assignment_points += Decimal(bexe.points)
                                    exe_str = '<span class="details" \
                                          style="display:inline;" \
                                          data-type="First done:%s, \
                                          Last done:%s, Total done:%i, \
                                          Total correct:%i, \
                                          Proficiency date:%s">Done</span>' \
                                          %(str(u_ex.first_done), \
                                          str(u_ex.last_done), \
                                          int(u_ex.total_done), \
                                          int(u_ex.total_correct), \
                                          str(u_ex.proficient_date))
                                else:
                                    penalty = Decimal(bexe.points) * (Decimal(1)-Decimal(assignment.course_module.late_submission_penalty))
                                    u_points += Decimal(penalty)
                                    students_assignment_points += Decimal(penalty)
                                    exe_str = '<span class="details" \
                                          style="display:inline;" \
                                          data-type="First done:%s, \
                                          Last done:%s, Total done:%i, \
                                          Total correct:%i, \
                                          Proficiency date:%s">Late</span>' \
                                          %(str(u_ex.first_done), \
                                          str(u_ex.last_done), \
                                          int(u_ex.total_done), \
                                          int(u_ex.total_correct), \
                                          str(u_ex.proficient_date))
                            if exercise.id in userdata.get_started_list() and \
                                          exercise.id not in \
                                          userdata.get_prof_list():    
                                exe_str = '<span class="details" \
                                      style="visibility: hidden; \
                                      display:inline;" \
                                      data-type="First done:%s, \
                                      Last done:%s, Total done:%i, \
                                      Total correct:%i, \
                                      Proficiency date:%s">Started</span>' \
                                      %(str(u_ex.first_done), \
                                      str(u_ex.last_done), \
                                      int(u_ex.total_done), \
                                      int(u_ex.total_correct), \
                                      str(u_ex.proficient_date))  
                    
                        u_assign.append(exe_str)
                    u_assign[0] =  str(students_assignment_points)
                    u_data = u_data + u_assign
                    u_data1.append(str(students_assignment_points))
               
                if max_assignments_points == 0:
                    max_assignments_points = 1 
                u_points = (u_points * 100) / max_assignments_points 
                u_data[3] = str("%.2f" % round(u_points,2))
                udata_list.append(u_data)
                u_data1[3] = str("%.2f" % round(u_points,2))
                udata_list1.append(u_data1) 


        context = RequestContext(request, {'book':book, \
                                           'max_points':max_assignments_points, \
                                           'course':course, \
                                           'udata_list': udata_list, \
                                           'wrong_exe': str(wrong_exe).strip('[]'), \
                                           'columns_list':columns_list, \
                                           'udata_list1': udata_list1, \
                                           'columns_list1':columns_list1}) 
        return render_to_response("opendsa/class_summary.html", context)
    else:
        return  HttpResponseForbidden('<h1>Page Forbidden</h1>')
コード例 #5
0
ファイル: views.py プロジェクト: OpenDSA/OpenDSA-devserver
def class_summary(request, book, course):
    """
    View creating the data displayed in the class activity spreadsheet
    """
    if is_authorized(request.user, book, course):
        exe_bme = []
        obj_book = Books.objects.get(book_name = book)
        max_book_points = 0
        udata_list = []
        udata_list1 = []
        columns_list = []
        columns_list1 = []
        columns_list_exe = []  #for exercises
        columns_list.append({"sTitle":"Id"})
        columns_list.append({"sTitle":"Username"})
        columns_list.append({"sTitle":"Email"})
        columns_list.append({"sTitle":"Score(%)"})
        #get book instances required exercises
        for bexe in BookModuleExercise.components.filter( \
                                         book = obj_book):
            if Decimal(bexe.points) > Decimal(0):
                exe_bme.append(bexe)

                max_book_points += Decimal(bexe.points)

                columns_list.append({"sTitle":str(bexe.exercise.name)+ \
                                         '('+str(bexe.points)+')'+ \
                                         '<span class="details" \
                                         style="display:inline;" \
                                         data-type="' + \
                                         str(bexe.exercise.description) + \
                                         '"></span>',"sClass": "center" })
        userData = UserData.objects.select_related().filter( \
                                                     book = obj_book, \
                                                     user__is_staff = 0 \
                                                     ).order_by('user')


        users = []
        for userdata in userData:
            if not userdata.user.is_staff and display_grade( \
                                              userdata.user, obj_book):
                u_points = 0
                u_data = []
                u_data.append(0)
                u_data.append(str(userdata.user.username))
                u_data.append(str(userdata.user.email))
                u_data.append(0)
                u_assign = []
                for bexe in exe_bme:
                        u_ex = None
                        user_exe = UserExercise.objects.filter( \
                                                user = userdata.user, \
                                                exercise = bexe.exercise)
                        if not user_exe and (not bexe.exercise.id in userdata.get_prof_list()):
                            exe_str = ''
                            #continue 
                        else:
                            user_exe = user_exe[0]
                            u_ex = user_exe
                            #assignment_points += Decimal(bexe.points)
                            exe_str = ''
                            if bexe.exercise.id in userdata.get_prof_list():
                                u_points += Decimal(bexe.points)
                                #students_assignment_points += Decimal(bexe.points)
                                #if u_ex.proficient_date <= \
                                #    assignment.course_module.closing_time:
                                exe_str = '<span class="details" \
                                      style="display:inline;" \
                                      data-type="First done:%s, \
                                      Last done:%s, Total done:%i, \
                                      Total correct:%i, \
                                      Proficiency date:%s">Done</span>' \
                                      %(str(u_ex.first_done), \
                                      str(u_ex.last_done), \
                                      int(u_ex.total_done), \
                                      int(u_ex.total_correct), \
                                      str(u_ex.proficient_date))
                                #else:
                                #    exe_str = '<span class="details" \
                                #          style="display:inline;" \
                                #          data-type="First done:%s, \
                                #          Last done:%s, Total done:%i, \
                                #          Total correct:%i, \
                                #          Proficiency date:%s">Late</span>' \
                                #          %(str(u_ex.first_done), \
                                #          str(u_ex.last_done), \
                                #          int(u_ex.total_done), \
                                #          int(u_ex.total_correct), \
                                #          str(u_ex.proficient_date))
                            if bexe.exercise.id in userdata.get_started_list() and \
                                          bexe.exercise.id not in \
                                          userdata.get_prof_list():
                                exe_str = '<span class="details" \
                                      style="visibility: hidden; \
                                      display:inline;" \
                                      data-type="First done:%s, \
                                      Last done:%s, Total done:%i, \
                                      Total correct:%i, \
                                      Proficiency date:%s">Started</span>' \
                                      %(str(u_ex.first_done), \
                                      str(u_ex.last_done), \
                                      int(u_ex.total_done), \
                                      int(u_ex.total_correct), \
                                      str(u_ex.proficient_date))

                        u_assign.append(exe_str)
                    #u_assign[0] =  str(students_assignment_points)
                u_data = u_data + u_assign

                if max_book_points == 0:
                    max_book_points = 1
                u_points = (u_points * 100) / max_book_points
                u_data[3] = str("%.2f" % round(u_points,2))
                udata_list.append(u_data)


        context = RequestContext(request, {'book':book, \
                                           'max_points':max_book_points, \
                                           'course':course, \
                                           'udata_list': udata_list, \
                                           'columns_list':columns_list})
        return render_to_response("opendsa/all_summary.html", context)
    else:
        return  HttpResponseForbidden('<h1>Page Forbidden</h1>')