Beispiel #1
0
def view_matches(request):
    """Generic view for serving a list of projects and potential teammate matches for each
    project."""
    project_match_list = []
    course_set = []

    page_name = "View Matches"
    page_description = "View Matching Students"
    title = "View Matches"

    if request.user.profile.isProf:
        courses = get_user_active_courses(request.user)
        for course in courses:
            for project in course.projects.all():
                p_match = po_match(project)
                project_match_list.extend([(course, project, p_match)])
            course_set.append(course)
    else:
        my_projects = Project.get_my_active_projects(request.user)

        for project in my_projects:
            p_match = po_match(project)
            project_match_list.extend([(project, p_match)])

    if request.POST.get('matchstats'):
        matches = request.POST.get('matchstats')

    return render(
        request, 'core/view_matches.html', {
            'project_match_list': project_match_list,
            'course_set': course_set,
            'page_name': page_name,
            'page_description': page_description,
            'title': title
        })
Beispiel #2
0
def matchstats(request, slug):
    """
        Displays why a user was matched with said project.
        Returns two dicts:
            -- skill_match:
                stores a user's skills that are similar with said projects'
                desired skills with their username as the key
            -- interest_match:
                Stores a users interest value and their reasoning for said project
                as a tuple with their username as the key

        TODO: could combine the two dicts if wanted.
    """

    # Page Information
    page_name = "Matchstats"
    page_description = "Stats on your matches"
    title = "Matchstats"

    matched_students = []
    skill_match = {}
    interest_match = {}

    cur_project = get_object_or_404(Project, slug=slug)
    cur_desiredSkills = cur_project.desired_skills.all()
    matched_students = po_match(cur_project)

    # find each students' known_skills that are desired by cur_project
    for stud, values in matched_students:

        student = get_object_or_404(User, username=stud)
        profile = Profile.objects.get(user=student)
        similar_skills = []

        for k_skill in profile.known_skills.all():

            for d_skill in cur_desiredSkills:

                if (k_skill == d_skill):
                    similar_skills.append(k_skill)

        all_interests = cur_project.interest.all()
        interests = all_interests.filter(user=student)

        for interest in interests:
            interest_match[stud] = ([interest, interest.interest_reason])

        if (len(similar_skills) > 0):
            skill_match[stud] = similar_skills
        else:
            skill_match[stud] = ["No similar skills"]

    user = request.user

    return render(request, 'core/matchstats.html',{
        'page_name':page_name,'page_description':page_description,
        'title':title,'skill_match':skill_match, 'cur_project' : cur_project,
        'interest_match':interest_match
        })
Beispiel #3
0
    def testMatchWithProjectDesiringSkills(self):
        """
        Runs po_match, with the project desiring the skill User3 knows. Users schedules are NOT set.
        """
        # Add user3's skill as a desired skill
        self.project.desired_skills.add(self.skill2)

        matchesList = po_match(self.project)

        # Assert User3 is the first choice over User2
        self.assertTrue(matchesList[0][0] == self.user3)

        # Remove the project desired_skill we added
        self.project.desired_skills.remove(self.skill2)
Beispiel #4
0
    def testMatchWithoutScheduleBonus(self):
        """
        Runs po_match, with User2 showing interest 5, and User3 showing interest 4. Users schedules are NOT set.
        """
        matchesList = po_match(self.project)

        # Assert User2 is the first (Gave a interest of 5)
        self.assertTrue(matchesList[0][0] == self.user2)

        # Assert User3 is the second (Gave an interest of 4)
        self.assertTrue(matchesList[1][0] == self.user3)

        # Assert User2's score is greater than User3's
        self.assertTrue(matchesList[0][1][0] > matchesList[1][1][0])