@@ -876,7 +876,7 @@ defmodule Cadet.Assessments do
876876 SubmissionVotes
877877 |> where ( question_id: ^ question . id )
878878 |> where ( voter_id: ^ submission . student_id )
879- |> where ( [ sv ] , is_nil ( sv . rank ) )
879+ |> where ( [ sv ] , is_nil ( sv . score ) )
880880 |> Repo . exists? ( )
881881
882882 unless has_nil_entries do
@@ -921,7 +921,7 @@ defmodule Cadet.Assessments do
921921 |> where ( [ v ] , v . voter_id == ^ voter_id and v . question_id == ^ question_id )
922922 |> join ( :inner , [ v ] , s in assoc ( v , :submission ) )
923923 |> join ( :inner , [ v , s ] , a in assoc ( s , :answers ) )
924- |> select ( [ v , s , a ] , % { submission_id: v . submission_id , answer: a . answer , rank : v . rank } )
924+ |> select ( [ v , s , a ] , % { submission_id: v . submission_id , answer: a . answer , score : v . score } )
925925 |> Repo . all ( )
926926 end
927927
@@ -1026,17 +1026,17 @@ defmodule Cadet.Assessments do
10261026 """
10271027 def compute_relative_score ( contest_voting_question_id ) do
10281028 # query all records from submission votes tied to the question id ->
1029- # map rank to user id ->
1029+ # map score to user id ->
10301030 # store as grade ->
10311031 # query grade for contest question id.
10321032 eligible_votes =
10331033 SubmissionVotes
10341034 |> where ( question_id: ^ contest_voting_question_id )
1035- |> where ( [ sv ] , not is_nil ( sv . rank ) )
1035+ |> where ( [ sv ] , not is_nil ( sv . score ) )
10361036 |> join ( :inner , [ sv ] , ans in Answer , on: sv . submission_id == ans . submission_id )
10371037 |> select (
10381038 [ sv , ans ] ,
1039- % { ans_id: ans . id , rank : sv . rank , ans: ans . answer [ "code" ] }
1039+ % { ans_id: ans . id , score : sv . score , ans: ans . answer [ "code" ] }
10401040 )
10411041 |> Repo . all ( )
10421042
@@ -1060,15 +1060,14 @@ defmodule Cadet.Assessments do
10601060 defp map_eligible_votes_to_entry_score ( eligible_votes ) do
10611061 # converts eligible votes to the {total cumulative score, number of votes, tokens}
10621062 entry_vote_data =
1063- Enum . reduce ( eligible_votes , % { } , fn % { ans_id: ans_id , rank: rank , ans: ans } , tracker ->
1063+ Enum . reduce ( eligible_votes , % { } , fn % { ans_id: ans_id , score: score , ans: ans } , tracker ->
10641064 { prev_score , prev_count , _ans_tokens } = Map . get ( tracker , ans_id , { 0 , 0 , 0 } )
10651065
10661066 Map . put (
10671067 tracker ,
10681068 ans_id ,
10691069 # assume each voter is assigned 10 entries which will make it fair.
1070- { prev_score + convert_vote_rank_to_score ( rank , 10 ) , prev_count + 1 ,
1071- Lexer . count_tokens ( ans ) }
1070+ { prev_score + score , prev_count + 1 , Lexer . count_tokens ( ans ) }
10721071 )
10731072 end )
10741073
@@ -1081,11 +1080,6 @@ defmodule Cadet.Assessments do
10811080 )
10821081 end
10831082
1084- # implementation detail assuming to calculate scores out of 10 for rank [1, num_voted_entries]
1085- defp convert_vote_rank_to_score ( rank , num_voted_entries ) do
1086- 11 - 10 * rank / num_voted_entries
1087- end
1088-
10891083 # Calculate the score based on formula
10901084 # score(v,t) = v - 2^(t/50) where v is the normalized_voting_score
10911085 # normalized_voting_score = sum_of_scores / number_of_voters / 10 * 100
@@ -1549,13 +1543,13 @@ defmodule Cadet.Assessments do
15491543 end
15501544
15511545 def insert_or_update_voting_answer ( submission_id , course_reg_id , question_id , answer_content ) do
1552- set_rank_to_nil =
1546+ set_score_to_nil =
15531547 SubmissionVotes
15541548 |> where ( voter_id: ^ course_reg_id , question_id: ^ question_id )
15551549
15561550 voting_multi =
15571551 Multi . new ( )
1558- |> Multi . update_all ( :set_rank_to_nil , set_rank_to_nil , set: [ rank : nil ] )
1552+ |> Multi . update_all ( :set_score_to_nil , set_score_to_nil , set: [ score : nil ] )
15591553
15601554 answer_content
15611555 |> Enum . with_index ( 1 )
@@ -1567,7 +1561,7 @@ defmodule Cadet.Assessments do
15671561 voter_id: course_reg_id ,
15681562 submission_id: entry . submission_id
15691563 )
1570- |> SubmissionVotes . changeset ( % { rank : entry . rank } )
1564+ |> SubmissionVotes . changeset ( % { score : entry . score } )
15711565 |> Repo . insert_or_update ( )
15721566 end )
15731567 end )
0 commit comments