Esempio n. 1
0
def getTeacherAssesmentConfigs(request):  #url configuraciones
    #Esta funcion entrega todas las configuraciones de evaluaciones realizadas por un profesor
    request.session.set_expiry(300)  #5 minutos de inactividad
    assesment_configs = Assesment_Config.objects.filter(
        kaid_teacher=request.user.user_profile.kaid).order_by(
            '-id_assesment_config')

    json_array = []
    for assesment_config in assesment_configs:
        #print assesment_config.id_assesment_config
        assesment_skills = Assesment_Skill.objects.filter(
            id_assesment_config_id=assesment_config.id_assesment_config
        ).values('id_skill_name')
        config_skills = Assesment_Skill.objects.filter(
            id_assesment_config_id=assesment_config.id_assesment_config
        ).values('id_subtopic_skill')
        #print assesment_skills
        skills = Skill.objects.filter(
            name__in=assesment_skills).values('name_spanish')
        #print skills
        config_json = {}
        config_json[
            "id_assesment_config"] = assesment_config.id_assesment_config
        config_json[
            "approval_percentage"] = assesment_config.approval_percentage
        config_json["top_score"] = assesment_config.top_score
        config_json["name"] = assesment_config.name
        config_json["id_subject_name_id"] = assesment_config.id_subject_name_id
        config_json["kaid_teacher_id"] = assesment_config.kaid_teacher_id
        config_json[
            "importance_skill_level"] = assesment_config.importance_skill_level
        config_json[
            "importance_completed_rec"] = assesment_config.importance_completed_rec
        config_json["applied"] = assesment_config.applied
        config_json["assesment_skills"] = []
        config_json["assesment_skills_spanish"] = []
        config_json["config_skills"] = []
        for i in range(len(assesment_skills)):
            config_json["assesment_skills"].append(assesment_skills[i])
            config_json["assesment_skills_spanish"].append(skills[i])
            config_json["config_skills"].append(config_skills[i])
        #print config_json["assesment_skills"]
        print config_json["assesment_skills_spanish"]
        json_array.append(config_json)

    json_dict = {"assesmentConfigs": json_array}
    json_data = json.dumps(json_dict)
    #print (json_data)
    topictree = getTopictree('math')
    return render_to_response('myAssesmentConfigs.html', {
        'assesment_configs': assesment_configs,
        'topictree': topictree,
        'json_data': json_data
    },
                              context_instance=RequestContext(request))
Esempio n. 2
0
def getTeacherAssesmentConfigs(request):#url configuraciones
    request.session.set_expiry(timeSleep)#5 minutos de inactividad
    assesment_configs = Assesment_Config.objects.filter(kaid_teacher=request.user.user_profile.kaid).order_by('-id_assesment_config')

    json_array=[]
    for assesment_config in assesment_configs:
        #print assesment_config.id_assesment_config
        assesment_skills = Assesment_Skill.objects.filter(id_assesment_config_id=assesment_config.id_assesment_config).values('id_skill_name_id')
        config_skills = Assesment_Skill.objects.filter(id_assesment_config_id=assesment_config.id_assesment_config).values('id_subtopic_skill_id')
        #print config_skills
        #skills = Skill.objects.filter(id_skill_name__in=assesment_skills).values('name_spanish')
        #print skills
        config_json={}
        config_json["id_assesment_config"]=assesment_config.id_assesment_config
        config_json["approval_percentage"]=assesment_config.approval_percentage
        config_json["top_score"]=assesment_config.top_score
        config_json["name"]=assesment_config.name
        config_json["id_subject_name_id"]=assesment_config.id_subject_name_id
        config_json["kaid_teacher_id"]=assesment_config.kaid_teacher_id
        config_json["importance_skill_level"]=assesment_config.importance_skill_level
        config_json["importance_completed_rec"]=assesment_config.importance_completed_rec
        config_json["applied"]=assesment_config.applied
        config_json["assesment_skills"]=[]
        config_json["assesment_skills_spanish"]=[]
        config_json["config_skills"]=[]
        for i in range(len(assesment_skills)):
            #print config_skills[i]
            #print assesment_skills[i]['id_skill_name_id']
            skills = Skill.objects.filter(id_skill_name=assesment_skills[i]['id_skill_name_id']).values('name_spanish')
            #print "abajo esta skills"
            #print skills
            #print "arriba esta skills"
            config_json["assesment_skills"].append(assesment_skills[i])
            config_json["assesment_skills_spanish"].append(skills[0]['name_spanish'])
            #config_json["config_skills"].append(config_skills[i])
        for j in range(len(config_skills)):
            #print config_skills[j]
            config_json["config_skills"].append(config_skills[j])
        #print config_json["assesment_skills"]
        json_array.append(config_json)
    
    json_dict={"assesmentConfigs":json_array}
    json_data = json.dumps(json_dict)
    #print (json_data)
    topictree= getTopictree('math')
    if (Administrator.objects.filter(kaid_administrator=request.user.user_profile.kaid) or Class_Subject.objects.filter(kaid_teacher=request.user.user_profile.kaid)):
        isTeacher = True
    else:
        isTeacher = False
    return render_to_response('myAssesmentConfigs.html', {'assesment_configs': assesment_configs, 'topictree':topictree,'json_data': json_data,'isTeacher':isTeacher}, context_instance=RequestContext(request))
Esempio n. 3
0
def getGroups(request, id_class):
    request.session.set_expiry(timeSleep)
    topictree=getTopictree('math')
    g = Master_Group.objects.filter(id_class=id_class)
    data = serializers.serialize('json', g)
    struct = json.loads(data)
    groups = json.dumps(struct)#arreglo en json con los master de las agrupaciones.
    if request.method == 'POST':
        args = request.POST
        skills_selected = eval(args['skills'])
        if args["student_groups"]:#si se ha seleccionado la opcion guardar agrupacion.
            tutors = eval(args['tutors'])
            #provisorio: si no ha escogido un alumno tutor, se asigna uno arbitrario. finalmente se debe asignar el kaid profesor
            if tutors[0]['kaid_tutor_reforzamiento'] == '3':
                tutors[0]['kaid_tutor_reforzamiento'] = request.user.user_profile.kaid
            if tutors[0]['kaid_tutor_intermedios'] =='2':
                tutors[0]['kaid_tutor_intermedios'] = request.user.user_profile.kaid
            tutors[0]['kaid_tutor_avanzados'] = request.user.user_profile.kaid 
            master = Master_Group()
            master.name = 'test'
            #master.date = timezone.now()
            #print master.date
            fecha = time.time()
            print fecha
            hoy= datetime.datetime.fromtimestamp(fecha).strftime('%Y-%m-%d %H:%M:%S')
            print hoy
            #t = time.mktime(time.strptime(hoy, "%Y-%m-%d %H:%M:%S"))
            master.date_int = int(fecha)
            master.kaid_teacher = request.user.user_profile.kaid
            master.id_class = id_class
            master.date = hoy

            master.save()
            print master.date_int
            new_Avanzados = Group()
            new_Avanzados.type = 'Avanzados'
            new_Avanzados.kaid_student_tutor_id = tutors[0]['kaid_tutor_avanzados']
            new_Avanzados.master = master.id
            new_Avanzados.save()
            new_Intermedios = Group()
            new_Intermedios.type = 'Intermedios'
            new_Intermedios.kaid_student_tutor_id = tutors[0]['kaid_tutor_intermedios']
            new_Intermedios.master = master.id
            new_Intermedios.save()
            new_Reforzamiento = Group()
            new_Reforzamiento.type = 'Reforzamiento'
            new_Reforzamiento.kaid_student_tutor_id = tutors[0]['kaid_tutor_reforzamiento']
            new_Reforzamiento.master = master.id
            new_Reforzamiento.save()
            new_SinGrupo = Group()
            new_SinGrupo.type = 'SinGrupo'
            new_SinGrupo.kaid_student_tutor_id = tutors[0]['kaid_tutor_reforzamiento']
            new_SinGrupo.master = master.id
            new_SinGrupo.save()
            for skills in skills_selected:
                Group_Skill(id_group_id=master.id,
                    id_skill_id=skills).save()
            groups = eval(args['student_groups'])

            subGroups = eval(args['subGroups'])

            dicSub = {
                'SinGrupo' : new_SinGrupo.id_group,
                'Avanzados' : new_Avanzados.id_group,
                'Intermedios' : new_Intermedios.id_group,
                'Reforzamiento' : new_Reforzamiento.id_group
            }

            #print dicSub
            for sub in subGroups:
                if "kaid_" not in sub['tutor']: 
                    new_group = Group(type=sub['name'],master=master.id,kaid_student_tutor_id=request.user.user_profile.kaid)
                else:
                    new_group = Group(type=sub['name'],master=master.id,kaid_student_tutor_id=sub['tutor'])
                new_group.save()
                dicSub[sub['name']] = new_group.id_group

            

            for g in groups:#guarda el estududiante el en respectivo grupo avanzados, intermedio o reforzamiento.
                #print 
                #print dicSub[str(g['group'])]
                Group_Student(id_group_id=dicSub[str(g['group'])],
                                  kaid_student_id=g['kaid_student']).save()
                
            students = Student.objects.filter(kaid_student__in=Student_Class.objects.filter(id_class_id=id_class).values('kaid_student'))
            for s in students:
                s.type = 'SinGrupo'
        students = makeGroups(id_class,skills_selected)
        return HttpResponse(students)
    else:
        students = Student.objects.filter(kaid_student__in=Student_Class.objects.filter(id_class_id=id_class).values('kaid_student'))
        for s in students:
            s.type = 'SinGrupo'
    classroom = Class.objects.filter(id_class=id_class)
    N = ['kinder','1ro basico','2do basico','3ro basico','4to basico','5to basico','6to basico','7mo basico','8vo basico','1ro medio','2do medio','3ro medio','4to medio']
    spanish_classroom = N[int(classroom[0].level)] +' '+ classroom[0].letter
    if (Class_Subject.objects.filter(kaid_teacher=request.user.user_profile.kaid,id_class_id=id_class)):
        isTeacher = True
    else:
        isTeacher = False
    kaid_teacher_object=Class_Subject.objects.filter(id_class_id=id_class).values('kaid_teacher')
    kaid_teacher = kaid_teacher_object[0]['kaid_teacher']
    return render_to_response('groups.html',{'students': students,'topictree':topictree,'id_class':id_class,'groups':groups,'spanish_classroom':spanish_classroom,'isTeacher':isTeacher,'kaid_teacher':kaid_teacher},context_instance=RequestContext(request))
Esempio n. 4
0
def getTeacherAssesmentConfigs(request):  #url configuraciones
    assesment_configs = Assesment_Config.objects.filter(
        kaid_teacher=request.user.user_profile.kaid).order_by(
            '-id_assesment_config')

    json_array = []
    for assesment_config in assesment_configs:
        #print assesment_config.id_assesment_config
        assesment_skills = Assesment_Skill.objects.filter(
            id_assesment_config_id=assesment_config.id_assesment_config
        ).values('id_skill_name_id')
        config_skills = Assesment_Skill.objects.filter(
            id_assesment_config_id=assesment_config.id_assesment_config
        ).values('id_subtopic_skill_id')
        #print config_skills
        #skills = Skill.objects.filter(id_skill_name__in=assesment_skills).values('name_spanish')
        #print skills
        config_json = {}
        config_json[
            "id_assesment_config"] = assesment_config.id_assesment_config
        config_json[
            "approval_percentage"] = assesment_config.approval_percentage
        config_json["top_score"] = assesment_config.top_score
        config_json["name"] = assesment_config.name
        config_json["id_subject_name_id"] = assesment_config.id_subject_name_id
        config_json["kaid_teacher_id"] = assesment_config.kaid_teacher_id
        config_json[
            "importance_skill_level"] = assesment_config.importance_skill_level
        config_json[
            "importance_completed_rec"] = assesment_config.importance_completed_rec
        config_json["applied"] = assesment_config.applied
        config_json["assesment_skills"] = []
        config_json["assesment_skills_spanish"] = []
        config_json["config_skills"] = []

        for i in range(len(assesment_skills)):
            #print config_skills[i]
            skills = Skill.objects.filter(
                id_skill_name=assesment_skills[i]['id_skill_name_id']).values(
                    'name_spanish')
            config_json["assesment_skills"].append(assesment_skills[i])
            config_json["assesment_skills_spanish"].append(
                skills[0]['name_spanish'])

        for j in range(len(config_skills)):
            config_json["config_skills"].append(config_skills[j])

        json_array.append(config_json)

    json_dict = {"assesmentConfigs": json_array}
    json_data = json.dumps(json_dict)
    #print (json_data)
    topictree = getTopictree('math')

    curriculum_list = Chapter_Mineduc.objects.all().values(
        'id_chapter_mineduc', 'level', 'year').order_by('-year', 'level')

    if (Class_Subject.objects.filter(
            kaid_teacher=request.user.user_profile.kaid)):
        isTeacher = True
        class_list = Class.objects.filter(
            class_subject__kaid_teacher=request.user.user_profile.kaid).values(
                'level', 'letter', 'year',
                'class_subject__id_class_subject').order_by(
                    '-year', 'level',
                    'letter').exclude(class_subject__curriculum__isnull=True)
    else:
        isTeacher = False

    N = [
        'Kinder', 'Primero Básico', 'Segundo Básico', 'Tercero Básico',
        'Cuarto Básico', 'Quinto Básico', 'Sexto Básico', 'Septimo Básico',
        'Octavo Básico', 'Primero Medio', 'Segundo Medio', 'Tercero Medio',
        'Cuarto Medio'
    ]
    for i in range(len(class_list)):
        class_list[i]['level'] = N[int(class_list[i]['level'])]

    for i in range(len(curriculum_list)):
        curriculum_list[i]['level'] = N[int(curriculum_list[i]['level'])]

    return render_to_response('myAssesmentConfigs.html', {
        'assesment_configs': assesment_configs,
        'topictree': topictree,
        'json_data': json_data,
        'isTeacher': isTeacher,
        'class_list': class_list,
        'curriculum_list': curriculum_list
    },
                              context_instance=RequestContext(request))