Exemplo n.º 1
0
def submit_ranking():

    # get the username and their dataset
    username = request.form['username']
    number_counter = int(request.form['number_counter'])

    if number_counter < len(NUMBERS):

        # get the ranking the user submitted
        ranking = np.fromstring(request.form['rankingResult'], sep=',', dtype=np.int)

        new_number = NUMBERS[number_counter]

        number_counter += 1

        return render_template("query_ranking_tutorial.html", username=username, numbers_unranked=[new_number],
                               numbers_ranked=ranking, number_counter=number_counter)

    else:

        # update the tutorial stats of the user
        utils_users.update_tutorial_status('ranking', username)

        # get the user's status on the tutorials
        tutorial_status = utils_users.get_tutorial_status(username)

        return render_template("navi_tutorial.html", username=username, pairwise_fin=tutorial_status[0],
                               clustering_fin=tutorial_status[1], ranking_fin=tutorial_status[2])
def choose_pairwise():

    # get current user
    username = request.form['username']

    # find out whether user clicked left or right button (0=left, 1=right)
    winner = request.form['winner']
    number_clicked = request.form['number_clicked']
    number_counter = int(request.form['number_counter'])

    button_type = request.form['buttonType']

    if number_counter < len(NUMBERS) and button_type == 'next':

        # sort according to what user did last round
        if number_clicked == "1":
            number1 = winner
            number2 = NUMBERS[number_counter]
        else:
            number1 = NUMBERS[number_counter]
            number2 = winner

        number_counter += 1

        return render_template("query_pairwise_tutorial_traffic.html",
                               username=username,
                               number1=number1,
                               number2=number2,
                               number_counter=number_counter,
                               number_clicked=number_clicked,
                               side_clicked=number_clicked)

    else:

        # update the tutorial stats of the user
        utils_users.update_tutorial_status('pairwise', username)

        # get the user's status on the tutorials
        tutorial_status = utils_users.get_tutorial_status(username)

        return render_template("navi_tutorial_traffic.html",
                               username=username,
                               pairwise_fin=tutorial_status[0],
                               clustering_fin=tutorial_status[1],
                               ranking_fin=tutorial_status[2])
Exemplo n.º 3
0
def submit_clustering_tutorial():

    # get the username and their dataset
    username = request.form['username']
    number_counter = int(request.form['number_counter'])

    if number_counter < len(NUMBERS):

        # get the clusters the user submitted
        top_number = [int(request.form['top-cluster'])]
        good_numbers = np.fromstring(request.form['good-cluster'],
                                     sep=',',
                                     dtype=int)
        bad_numbers = np.fromstring(request.form['bad-cluster'],
                                    sep=',',
                                    dtype=int)

        new_number = NUMBERS[number_counter]

        number_counter += 1

        # save
        return render_template('query_clustering_tutorial.html',
                               username=username,
                               numbers_unranked=[new_number],
                               top_number=top_number,
                               good_numbers=good_numbers,
                               bad_numbers=bad_numbers,
                               number_counter=number_counter)

    else:

        # update the tutorial stats of the user
        utils_users.update_tutorial_status('clustering', username)

        # get the user's status on the tutorials
        tutorial_status = utils_users.get_tutorial_status(username)

        return render_template("navi_tutorial.html",
                               username=username,
                               pairwise_fin=tutorial_status[0],
                               clustering_fin=tutorial_status[1],
                               ranking_fin=tutorial_status[2])