diff --git a/flask/testapp/static/javascript/beautyVote.js b/flask/testapp/static/javascript/beautyVote.js index bc8fc98..4c17af2 100644 --- a/flask/testapp/static/javascript/beautyVote.js +++ b/flask/testapp/static/javascript/beautyVote.js @@ -186,6 +186,7 @@ function checkAnswer(){ var j = 0;// 選択した人数が同じ数のpoint調整変数 for(var i = 0; i < CHOICE_NUMBER; i ++){ + // 各選択肢の該当人数が同じとき if (i>=1){ if(question[round].people[i]==question[round].people[i-1]){ j ++; @@ -203,6 +204,7 @@ break; } } + // round時点のスコア player.score = player.calcScore(); console.log(player.points[round]) } @@ -351,7 +353,7 @@ var round = 0; //変更 var MAX_ROUND = 3; -var CHOICE_NUMBER = 4; +var CHOICE_NUMBER = 5; var max_player = 0; // 最大のplayer数(変更不要) var current_player = 0; diff --git a/flask/testapp/static/javascript/resultScreen.js b/flask/testapp/static/javascript/resultScreen.js index cd026c1..0848308 100644 --- a/flask/testapp/static/javascript/resultScreen.js +++ b/flask/testapp/static/javascript/resultScreen.js @@ -36,13 +36,13 @@ } if(scene == ROUND_RESULT){ fText(CheckPeople(A, round) +"人", 275, 425, 50, "black"); - fText(CHOICE_NUMBER-checkOrder(A, round) + "Pt", 400, 500, 50, "black"); + fText(checkOrder(A, round) + "Pt", 400, 500, 50, "black"); fText(CheckPeople(B, round)+"人", 725, 425, 50, "black"); - fText(CHOICE_NUMBER-checkOrder(B, round) + "Pt", 850, 500, 50, "black"); + fText(checkOrder(B, round) + "Pt", 850, 500, 50, "black"); fText(CheckPeople(C, round)+"人", 275, 725, 50, "black"); - fText(CHOICE_NUMBER-checkOrder(C, round) + "Pt", 400, 800, 50, "black"); + fText(checkOrder(C, round) + "Pt", 400, 800, 50, "black"); fText(CheckPeople(D, round)+"人", 725, 725, 50, "black"); - fText(CHOICE_NUMBER-checkOrder(D, round) + "Pt", 850, 800, 50, "black"); + fText(checkOrder(D, round) + "Pt", 850, 800, 50, "black"); } if(scene == WAIT_SCENE){ setAlp(50); @@ -162,6 +162,53 @@ } } +function showOtherResult(show_click_round){ + fill("silver"); + setAlp(50); + fRect(50, 50, 855, 100, "black"); + fRect(45, 295, 860, 560, "white"); + fRect(50, 300, 400, 250, "black"); + fRect(500, 300, 400, 250, "black"); + fRect(50, 600, 400, 250, "black"); + fRect(500, 600, 400, 250, "black"); + + setAlp(100); + + fText("Q.", 110, 100, 40, "white"); + + fText("A.", 100, 425, 40, "white"); + fText("B.", 550, 425, 40, "white"); + fText("C.", 100, 725, 40, "white"); + fText("D.", 550, 725, 40, "white"); + + fText(question[show_click_round].question, 480, 100, 30, "white"); + fText(question[show_click_round].choiceA, 275, 425, 25, "white"); + fText(question[show_click_round].choiceB, 725, 425, 25, "white"); + fText(question[show_click_round].choiceC, 275, 725, 25, "white"); + fText(question[show_click_round].choiceD, 725, 725, 25, "white"); + + fText(CheckPeople(A, show_click_round) +"人", 275, 425, 50, "black"); + fText(checkOrder(A, show_click_round) + "Pt", 400, 500, 50, "black"); + fText(CheckPeople(B, show_click_round)+"人", 725, 425, 50, "black"); + fText(checkOrder(B, show_click_round) + "Pt", 850, 500, 50, "black"); + fText(CheckPeople(C, show_click_round)+"人", 275, 725, 50, "black"); + fText(checkOrder(C, show_click_round) + "Pt", 400, 800, 50, "black"); + fText(CheckPeople(D, show_click_round)+"人", 725, 725, 50, "black"); + fText(checkOrder(D, show_click_round) + "Pt", 850, 800, 50, "black"); + + fText("結果", 100, 1100, 50, "black"); + for(var i = 0; i < MAX_ROUND; i ++){ + if(i == show_click_round){ + fText((i+1), 480 + 50*i, 1100, 50, "red"); + } + else{ + fText((i+1), 480 + 50*i, 1100, 50, "black"); + } + + } +} + + function CheckPeople(i, show_round){ let question_values = [int(question[show_round].answer[0]), int(question[show_round].answer[1]), int(question[show_round].answer[2]), int(question[show_round].answer[3])] let people_values = [int(question[show_round].people[0]), int(question[show_round].people[1]), int(question[show_round].people[2]), int(question[show_round].people[3])] @@ -174,10 +221,25 @@ } function checkOrder(choice, show_round){ - for(var i = 0; i < CHOICE_NUMBER; i ++){ - if(choice == question[show_round].answer[i]){ - return i; + + var j = 0;// 選択した人数が同じ数のpoint調整変数 + for(var i = 0; i < CHOICE_NUMBER; i ++){ + // 各選択肢の該当人数が同じとき + if (i>=1){ + if(question[show_round].people[i]==question[show_round].people[i-1]){ + j ++; + } } - } - return E; + // 未選択を選んだ場合 + if(choice == question[show_round].answer[i]){ + // 未選択を選んだ場合(E==4) + if(choice == 4){ + return 0; + } + else{ + return 4-i+j; + } + } + } + return 0; } diff --git a/flask/testapp/views.py b/flask/testapp/views.py index 3be662b..d5cb00e 100644 --- a/flask/testapp/views.py +++ b/flask/testapp/views.py @@ -140,45 +140,20 @@ def calculate_majority(get_data): counter = Counter(get_data) get_frequent_table = "" - # 最も多く出現する要素を取得する - most_common = ( + # 選択肢の人数が多い順にリストを取得(選択肢、人数) + common_order = ( counter.most_common() - ) # 出現回数が多い順に要素とその出現回数のリストを取得 - - # 最も多く出現する要素 - get_most_common_option = str(most_common[0][0]) - get_most_common_count = str(most_common[0][1]) - get_frequent_table += get_most_common_option + " " + get_most_common_count + "\n" - # 2番目に多い要素 - get_second_most_common_option = ( - str(most_common[1][0]) if len(most_common) > 1 else str(4) - ) - get_second_most_common_count = ( - str(most_common[1][1]) if len(most_common) > 1 else str(0) - ) - get_frequent_table += ( - get_second_most_common_option + " " + get_second_most_common_count + "\n" - ) - # 3番目に多い要素 - get_third_most_common_option = ( - str(most_common[2][0]) if len(most_common) > 2 else str(4) - ) - get_third_most_common_count = ( - str(most_common[2][1]) if len(most_common) > 2 else str(0) - ) - get_frequent_table += ( - get_third_most_common_option + " " + get_third_most_common_count + "\n" - ) - # 4番目に多い要素 - get_fourth_most_common_option = ( - str(most_common[3][0]) if len(most_common) > 3 else str(4) - ) - get_fourth_most_common_count = ( - str(most_common[3][1]) if len(most_common) > 3 else str(0) - ) - get_frequent_table += ( - get_fourth_most_common_option + " " + get_fourth_most_common_count - ) + ) + # 文字列として保存 + for i in range(5): + get_frequent_table += str(common_order[i][0]) if len(common_order) > i else str(4) + get_frequent_table += " " + get_frequent_table += str(common_order[i][1]) if len(common_order)> i else str(0) + get_frequent_table += "\n" + + if get_frequent_table.endswith("\n"): + get_frequent_table = get_frequent_table[:-1] # 最後の改行文字を削除 + return get_frequent_table