CSC/ECE 517 Fall 2015/oss E1550 KMM: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 7: Line 7:


==== Rubric type checking via message to ResponseMap ====
==== Rubric type checking via message to ResponseMap ====
[[File:response1.JPG‎  |frame|center|Auto selected Reviewing]]
[[File:response2.JPG‎  |frame|center|Auto selected Reviewing]]
[[File:response3.JPG‎  |frame|center|Auto selected Reviewing]]
[[File:response4.JPG‎  |frame|center|Auto selected Reviewing]]
[[File:response5.png |frame|center|Auto selected Reviewing]]
[[File:response6.png |frame|center|Auto selected Reviewing]]


==== Ensure score calculations utilize the weight of questions ====
==== Ensure score calculations utilize the weight of questions ====
Line 33: Line 42:


==== Relocate/Refactor code for sending emails to app/mailers ====
==== Relocate/Refactor code for sending emails to app/mailers ====
All the email code has been shifted to the mailers


==== Remove comments in lines 25-27 ====
==== Remove comments in lines 25-27 ====
Comments have been removed.
Comments have been removed.
[[File:Comments.JPG‎  |frame|center|Auto selected Reviewing]]


== response_helper.rb ==
== response_helper.rb ==
Line 46: Line 61:
Method is no longer being used in Expertiza and has been removed.
Method is no longer being used in Expertiza and has been removed.


 
[[File:response_helper.png‎ |frame|center|Auto selected Reviewing]]
<syntaxhighlight lang="ruby" line="1">
-  def construct_table(parameters)
-    table_hash = {"table_title" => nil, "table_headers" => nil, "start_table" => false, "start_col" => false, "end_col" => false, "end_table" => false}
-
-    #we need to check if these parameters use tables
-    parameters = parameters.last(3)
-    if parameters[2].nil?
-      return table_hash
-    end
-    current_ques = parameters[2].split("|")[0]
-    total_col_ques = parameters[2].split("|")[1]
-    current_col = parameters[2].split("|")[2]
-    total_col = parameters[2].split("|")[3]
-
-    #since it's first item in a column we need to start a new column
-    if current_ques.to_i == 1
-      table_hash["start_col"] = true
-      #if it's the first column we need to send the title and headers
-      if current_col.to_i == 1
-        if parameters[0].length > 0
-          table_hash["table_title"] = parameters[0]
-        end
-        table_hash["start_table"] = true
-        if parameters[1].length > 0
-          table_hash["table_headers"] = parameters[1]
-        end
-      end
-    end
-    #end of column, we need to close column
-    if current_ques == total_col_ques
-      table_hash["end_col"] = true
-      #end of table we need to close table
-      if total_col == current_col
-        table_hash["end_table"] = true
-      end
-    end
-    table_hash
- end
-
-  # Rearrange questions shown to a reviewer based on response count
-  # for each question and accordion panel of previous reviews for that submission
-  def rearrange_questions(questions)
-    if (check_threshold)
-      return questions
-    end
-
-    # Initialize local variables
-    panel_questions=Hash.new
-    panel_scores=Hash.new
-    questions_response_count=Hash.new
-    sorted_panel_questions=Array.new
-    prev_topic=nil
-    current_topic=nil
-    primary_response_count=0
-    sorted_questions=Array.new
-    grouped_questions=Array.new
-
-    # Loop through questions array and store in a hash with its response counts
-    questions.each {
-        |question|
-      question_type=question.question_type
-      current_topic = question_type.parameters.split("::")[0]
-      grouping_position= question_type.parameters.split("::").length==1 ? nil : question_type.parameters.split("::").last.split("|")[0]
-      grouping_count= question_type.parameters.split("::").length==1 ? nil : question_type.parameters.split("::").last.split("|")[1].to_i
-      # grouping_position > 1 implies secondary questions among questions grouped by 1|2 logic
-      # we need to call to_i method on grouping_position if it is a string
-      if grouping_position.to_i<=1
-        # create new hash set for new accordion panel
-        unless (!current_topic.nil? && (current_topic==prev_topic || prev_topic.nil?))
-          panel_score, sorted_panel_questions = process_panel(questions, questions_response_count)
-          panel_questions[prev_topic]=sorted_panel_questions
-          panel_scores[prev_topic]=panel_score/sorted_panel_questions.length
-
-          questions_response_count=Hash.new
-        end
-        # calculate response count when first checkbox type question comes
-        # for the rest of the checkbox questions; assign the same calculated response count
-        if question_type.q_type.eql? 'Checkbox'
-          unless (!current_topic.eql? prev_topic)
-            checkbox_questions=questions.select { |checkbox_question| checkbox_question.question_type.parameters.split("::")[0].eql?(current_topic) }
-            primary_response_count= find_number_of_responses_for_checkbox(checkbox_questions)
-          end
-        # calculate response count for corresponding comment for Rating type of questions
-        elsif (question_type.q_type.eql? 'Rating') && (grouping_position.to_i==1)
-          current_question_index=questions.index(question)
-          curr_question=questions.fetch(current_question_index+1)
-          primary_response_count= find_number_of_responses(curr_question)
-        else # ungrouped questions
-          primary_response_count= find_number_of_responses(question)
-        end
-      end
-      questions_response_count[question.id]= primary_response_count
-      prev_topic=current_topic
-    }
-
-    # Ensure last hash of questions is also included in the final rearranged question array
-    unless (questions_response_count.empty?)
-      panel_score, sorted_panel_questions = process_panel(questions, questions_response_count)
-      panel_questions[prev_topic]=sorted_panel_questions
-      panel_scores[prev_topic]=panel_score/questions_response_count.length
-    end
-
-    # Create final array of rearranged questions by sorting hash of each panel
-    panel_scores=Hash[panel_scores.sort_by { |k, v| v }]
-    panel_scores.each {
-        |key, value|
-      panel_questions.fetch(key).each { |question| sorted_questions << question }
-    }
-    return sorted_questions
-  end
-
</syntaxhighlight>

Latest revision as of 23:49, 6 November 2015

E1550: Refactoring response.rb and response_helper.rb

response.rb

response.rb is the class that manages the response to all rubrics in Expertiza. if someone fills out a review form, the instance of the review form is a Response. If someone gives feedback (a “rejoinder”) to an author, that is a Response too. Or if someone evaluates a teammate contribution, fills out a survey, or takes a quiz, they are creating a Response.

Note: Method display_as_html writes the HTML for displaying a rubric.  This would ordinarily be view code, but it is used by so many different views that it is done here.  Questions are written out in the order of their sequence number (anyone who creates a rubric can specify sequence numbers for questions).  After all questions are displayed, there is a blank for an additional comment.

Rubric type checking via message to ResponseMap

Auto selected Reviewing
Auto selected Reviewing
Auto selected Reviewing
Auto selected Reviewing
Auto selected Reviewing
Auto selected Reviewing


Ensure score calculations utilize the weight of questions

When the get_maximum_score() function is called it takes care of the weight of the question. It multiplies the weight to the score and adds it to the final score.

def get_maximum_score()
    # only count the scorable questions, only when the answer is not nil (we accept nil as answer for scorable questions, and they will not be counted towards the total score)
    total_weight = 0
    scores.each do |s|
      question = Question.find(s.question_id)
      if !s.answer.nil? && question.is_a?(ScoredQuestion)
        total_weight+=question.weight
      end
    end
    if scores.empty?
      questionnaire = questionnaire_by_answer(nil)
    else
      questionnaire = questionnaire_by_answer(scores.first)
    end
    total_weight*questionnaire.max_question_score
  end

Relocate/Refactor code for sending emails to app/mailers

All the email code has been shifted to the mailers

Remove comments in lines 25-27

Comments have been removed.


Auto selected Reviewing

response_helper.rb

response_helper.rb contains helper methods that display the questionnaires and rearrange questions so that the most frequently answered questions are at the bottom while the less frequently answered questions are at the top.

Refactor construct_table method

Method is no longer being used in Expertiza and has been removed.

Refactor rearrange_questions method

Method is no longer being used in Expertiza and has been removed.

Auto selected Reviewing