Exemplo n.º 1
0
def student_Team(requests):
    context = {}
    # Redirect user to login page if not authorized and student
    try:
        processLogin.studentVerification(requests)
    except:
        logout(requests)
        return render(requests, 'Module_Account/login.html', context)

    context = {"student_Team": "active", 'course': {}}
    studentList = []
    module = requests.GET.get('module')
    student_email = requests.user.email

    if student_email == None:
        context['message'] = 'Please specify a username'
        return render(requests,
                      "Module_TeamManagement/Student/studentTeam.html",
                      context)

    studentObj = Student.objects.get(email=student_email)
    classObj = Class.objects.all().filter(
        student=studentObj, course_section=module
    )  #Will return queryset containing 1 row unless has multiple teams in same class

    for enrolled_class in classObj:  #Should contain 1 row
        if enrolled_class.team_number != None:
            team_list = Class.objects.all().filter(
                team_number=enrolled_class.team_number).filter(
                    course_section=enrolled_class.course_section)
            for student_class_model in team_list:
                studentList.append(student_class_model.student
                                   )  #List containing student models

            context['team'] = studentList
            context['teamno'] = enrolled_class.team_number

    # Reads web scrapper results
    trailResults = utilities.populateTrailheadInformation(
        requests, student_email)
    context.update(trailResults)

    context['module'] = classObj[0].course_section.course_section_id
    context['user'] = studentObj
    context['message'] = 'Successful retrieval of student\'s team'
    #print(context)
    return render(requests, "Module_TeamManagement/Student/studentTeam.html",
                  context)
Exemplo n.º 2
0
def home(requests):
    context = {}
    # Redirect user to login page if not authorized and student
    try:
        processLogin.studentVerification(requests)
    except:
        logout(requests)
        return render(requests, 'Module_Account/login.html', context)
    context["home"] = "active"
    requests.session['userType'] = "Student"

    student_email = requests.user.email
    all_SocialAccount = SocialAccount.objects.all()

    for each_SocialAccount in all_SocialAccount:
        data = each_SocialAccount.extra_data
        if data['email'] == student_email:
            requests.session['user_picture'] = data['picture']
            requests.session['user_name'] = data['name'].replace('_',
                                                                 '').strip()

    # Populates the info for the side nav bar for instructor
    utilities.populateRelevantCourses(requests, studentEmail=student_email)

    # Reads web scrapper results
    trailResults = utilities.populateTrailheadInformation(
        requests, student_email)
    context.update(trailResults)

    # Get number of weeks since school term start and reamining weeks till school term ends
    past_weeks, remaining_weeks = utilities.getRemainingWeeks()

    if past_weeks != None and remaining_weeks != None:
        context['past_weeks'] = past_weeks
        context['remaining_weeks'] = remaining_weeks
        context['progress'] = (past_weeks /
                               (past_weeks + remaining_weeks)) * 100
    else:
        context['past_weeks'] = 0
        context['remaining_weeks'] = 0
        context['progress'] = 0

    return render(requests, "Module_TeamManagement/Student/studentHome.html",
                  context)
Exemplo n.º 3
0
def faculty_Overview(requests):

    context = {}
    # Redirect user to login page if not authorized and faculty
    try:
        processLogin.InstructorVerification(requests)
    except:
        logout(requests)
        return render(requests, 'Module_Account/login.html', context)

    context = {"faculty_Overview": "active", 'course': {}}

    faculty_email = requests.user.email

    if requests.method == "GET":
        course_section = requests.GET.get('module')
        course_title = requests.GET.get('course_title')
        section_number = requests.GET.get('section_number')
    else:
        course_section = requests.POST.get('course_section')
        course_title = course_section[:-2]
        section_number = course_section[-2:]

    # Return sections that's related to the course
    courseList_updated = requests.session['courseList_updated']
    context['course_sectionList'] = courseList_updated[course_title]

    facultyObj = Faculty.objects.get(email=faculty_email)
    classObj_list = Class.objects.all().filter(course_section=course_section)

    trailResults = utilities.populateTrailheadInformation(
        requests, instructorEmail=requests.user.email)

    context.update(trailResults)
    if len(classObj_list) > 0:
        classList = []  # Containing student class objects
        for enrolled_class in classObj_list:
            studentInfo = {}
            studentInfo['team'] = enrolled_class.team_number
            studentInfo[
                'info'] = enrolled_class.student  #Obtains student model from Foreign key
            studentUserName = enrolled_class.student.email.split("@")[0]
            try:
                studentInfo['link'] = Cloud_Learning_Tools.objects.get(
                    id=studentUserName + "_Trailhead").website_link
                studentPointsPosition = trailResults['CourseTrailResults'][
                    'class']['Students_Information']['students'].index(
                        studentUserName)
                studentInfo['points'] = trailResults['CourseTrailResults'][
                    'class']['Students_Information']['points'][
                        studentPointsPosition]
                studentInfo['badges'] = trailResults['CourseTrailResults'][
                    'class']['Students_Information']['badges'][
                        studentPointsPosition]
            except:
                studentInfo[
                    'link'] = "No link"  #Exception which is caused by no cle linked
                studentInfo['points'] = 0
                studentInfo['badges'] = 0
            classList.append(studentInfo)
        context['course']['classList'] = classList

    course_section = Course_Section.objects.get(
        course_section_id=course_section)
    if course_section.section_number == 'G0':
        context['module'] = course_section.course.course_title
    else:
        context[
            'module'] = course_section.course.course_title + " " + course_section.section_number

    context['course_section'] = Course_Section.objects.get(
        course=course_title, section_number=section_number)
    context['user'] = facultyObj
    context['message'] = 'Successful retrieval of faculty\'s profile'

    return render(requests,
                  "Module_TeamManagement/Instructor/instructorOverview.html",
                  context)
Exemplo n.º 4
0
def faculty_Dashboard(requests):
    context = {"faculty_Dashboard": "active"}

    # Redirect user to login page if not authorized and faculty
    try:
        processLogin.InstructorVerification(requests)
    except:
        logout(requests)
        return render(requests, 'Module_Account/login.html', context)

    requests.session['userType'] = "Instructor"
    faculty_username = requests.user.email.split('@')[0]
    all_SocialAccount = SocialAccount.objects.all()

    for each_SocialAccount in all_SocialAccount:
        data = each_SocialAccount.extra_data
        if data['email'] == requests.user.email:
            requests.session['user_picture'] = data['picture']
            requests.session['user_name'] = data['name'].replace('_',
                                                                 '').strip()

    try:
        courseStudents = []

        #Populates the info for the side nav bar for instructor
        utilities.populateRelevantCourses(requests,
                                          instructorEmail=requests.user.email)
        facultyObj = Faculty.objects.get(email=requests.user.email)
        registered_course_section = facultyObj.course_section.all()
        courses = {}
        students = []
        tele_data = {}
        previouscourse = "a"  #filler

        for course_section in registered_course_section:
            course_title = course_section.course.course_title

            if "G0" in (course_section.course_section_id):
                courses[course_title] = {"count": 0, "sectionCount": 0}
            else:
                if course_title not in courses:
                    courses[course_title] = {}
                    if previouscourse != "a":
                        courses[previouscourse]["count"] = len(courseStudents)
                        courses[previouscourse][
                            "sectionCount"] = sectionCounter
                        courses[previouscourse]["toolImage_list"] = toolsList

                    courseStudents = []
                    previoussection = "a"
                    previouscourse = course_title
                    sectionCounter = 0
                    toolsList = []
                if previoussection != course_section:
                    sectionCounter += 1

                classObj = Class.objects.all().filter(
                    course_section=course_section)

                for student in classObj:
                    students.append(student)
                    courseStudents.append(student)
                try:
                    currentCourseTools = course_section.learning_tools.split(
                        "_")
                    for tools in currentCourseTools:
                        if tools not in toolsList:
                            toolsList.append(tools)
                except:
                    pass
                previoussection = course_section

        if previouscourse != "a":
            courses[previouscourse]["count"] = len(courseStudents)
            courses[previouscourse]["sectionCount"] = sectionCounter
            courses[previouscourse]["toolImage_list"] = toolsList

        context['section_count'] = len(registered_course_section)
        context['course_count'] = len(courses)
        context['course_list'] = courses
        context['student_count'] = len(students)

    except:
        traceback.print_exc()
        context = {'messages': ['Invalid user account']}
        return render(requests, 'Module_Account/login.html', context)

    context["courses"] = requests.session['courseList_updated']

    # Get number of weeks since school term start and reamining weeks till school term ends
    past_weeks, remaining_weeks = utilities.getRemainingWeeks()

    if past_weeks != None and remaining_weeks != None:
        context['past_weeks'] = past_weeks
        context['remaining_weeks'] = remaining_weeks
        context['progress'] = (past_weeks /
                               (past_weeks + remaining_weeks)) * 100
    else:
        context['past_weeks'] = 0
        context['remaining_weeks'] = 0
        context['progress'] = 0

    # Reads web scrapper results
    trailResults = utilities.populateTrailheadInformation(
        requests, instructorEmail=requests.user.email)
    context.update(trailResults)
    context[
        'message'] = 'Successful retrieval of faculty\'s overview information'
    #print(context)
    return render(requests,
                  "Module_TeamManagement/Instructor/instructorHome.html",
                  context)