Commit b19291c6 by solashirai Committed by Piotr Mitros

removed unused funcitonality, fixed naming

parent b0d54190
<script type='x-tmpl/mustache' id='show_hint_contribution'> <script type='x-tmpl/mustache' id='show_hint_rating_ux'>
<div class='csh_hint_value' value="{{hintText}}"> <div class='csh_hint_value' value="{{hintText}}">
<div class='csh_hint_data'> <div class='csh_hint_data'>
<div class="csh_hint"><b>{{hintText}}</b></div> <div class="csh_hint"><b>{{hintText}}</b></div>
......
...@@ -37,21 +37,21 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -37,21 +37,21 @@ function CrowdsourceHinter(runtime, element, data){
} }
/** /**
* Start student hint contribution. This will allow students to contribute new hints * Start student hint rating/contribution. This will allow students to contribute new hints
* to the hinter as well as vote on the helpfulness of the first hint they received * to the hinter as well as vote on the helpfulness of the first hint they received
* for the current problem. This function is called after the student answers * for the current problem. This function is called after the student answers
* the question correctly. * the question correctly.
*/ */
function startHintContribution(){ function startHintRating(){
$('.csh_correct', element).show(); $('.csh_correct', element).show();
$(".csh_hint_reveal", element).hide(); $(".csh_hint_reveal", element).hide();
if($('.csh_hint_creation', element)){ if($('.csh_hint_creation', element)){
//send empty data for ajax call because not having a data field causes error //send empty data for ajax call because not having a data field causes error
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'get_feedback'), url: runtime.handlerUrl(element, 'get_used_hint_answer_data'),
data: JSON.stringify({}), data: JSON.stringify({}),
success: setHintContributionDivs success: setHintRatingUX
}); });
} }
} }
...@@ -60,6 +60,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -60,6 +60,7 @@ function CrowdsourceHinter(runtime, element, data){
* Check whether or not the question was correctly answered by the student. * Check whether or not the question was correctly answered by the student.
* The current method of checking the correctness of the answer is very brittle * The current method of checking the correctness of the answer is very brittle
* since we simply look for a string within the problemGradedEventData. * since we simply look for a string within the problemGradedEventData.
* HACK
* @param problemGradedEventData is the data from problem_graded event. * @param problemGradedEventData is the data from problem_graded event.
*/ */
function checkIsAnswerCorrect(problemGradedEventData){ function checkIsAnswerCorrect(problemGradedEventData){
...@@ -80,7 +81,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -80,7 +81,7 @@ function CrowdsourceHinter(runtime, element, data){
//search method of correctness of problem is brittle due to checking for a class within //search method of correctness of problem is brittle due to checking for a class within
//the problem block. //the problem block.
if (checkIsAnswerCorrect(data)){ if (checkIsAnswerCorrect(data)){
startHintContribution(); startHintRating();
} else { //if the submitted answer is incorrect } else { //if the submitted answer is incorrect
getHint(data); getHint(data);
} }
...@@ -98,15 +99,15 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -98,15 +99,15 @@ function CrowdsourceHinter(runtime, element, data){
} }
/** /**
* Called by setHintContributionDivs to append hints into divs created by * Called by setHintRatingUX to append hints into divs created by
* showStudentSubmissoinHistory, after the student answered the question correctly. * showStudentSubmissoinHistory, after the student answered the question correctly.
* Feedback on hints at this stage consists of upvote/downvote/report buttons. * Feedback on hints at this stage consists of upvote/downvote/report buttons.
* @param hint is the first hint that was shown to the student * @param hint is the first hint that was shown to the student
* @param student_answer is the first incorrect answer submitted by the student * @param student_answer is the first incorrect answer submitted by the student
*/ */
function showStudentHintContribution(hint, student_answer){ function showStudentHintRatingUX(hint, student_answer){
var hintContributionTemplate = $(Mustache.render($('#show_hint_contribution').html(), {hintText: hint})); var hintRatingUXTemplate = $(Mustache.render($('#show_hint_rating_ux').html(), {hintText: hint}));
$('.csh_answer_text', element).append(hintContributionTemplate); $('.csh_answer_text', element).append(hintRatingUXTemplate);
var hintCreationTemplate = $(Mustache.render($('#add_hint_creation').html(), {})); var hintCreationTemplate = $(Mustache.render($('#add_hint_creation').html(), {}));
$('.csh_answer_text', element).append(hintCreationTemplate); $('.csh_answer_text', element).append(hintCreationTemplate);
} }
...@@ -125,8 +126,8 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -125,8 +126,8 @@ function CrowdsourceHinter(runtime, element, data){
/** /**
* Append new divisions into html for each answer the student submitted before correctly * Append new divisions into html for each answer the student submitted before correctly
* answering the question. showStudentHintContribution appends new hints into these divs. * answering the question. showStudentHintRatingUX appends new hints into these divs.
* When the hinter is set to show best, only one div will be created. *
* @param student_answers is the text of the student's incorrect answer * @param student_answers is the text of the student's incorrect answer
*/ */
function showStudentSubmissionHistory(student_answer){ function showStudentSubmissionHistory(student_answer){
...@@ -138,11 +139,11 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -138,11 +139,11 @@ function CrowdsourceHinter(runtime, element, data){
* Set up student/staff voting on hints and contribution of new hints. The original incorrect answer and the * Set up student/staff voting on hints and contribution of new hints. The original incorrect answer and the
* the corresponding hint shown to the student is displayed. Students can upvote/downvote/report * the corresponding hint shown to the student is displayed. Students can upvote/downvote/report
* the hint or contribute a new hint for their incorrect answer. * the hint or contribute a new hint for their incorrect answer.
* Only one incorrect answer and hint will be shown when the hinter is set to show best. *
* @param result is a dictionary of incorrect answers and hints, with the index being the hint and the value * @param result is a dictionary of incorrect answers and hints, with the index being the hint and the value
* being the incorrect answer * being the incorrect answer
*/ */
function setHintContributionDivs(result){ function setHintRatingUX(result){
if(data.isStaff){ //allow staff to see and remove/return reported hints to/from the hint pool for a problem if(data.isStaff){ //allow staff to see and remove/return reported hints to/from the hint pool for a problem
$('.crowdsourcehinter_block', element).attr('class', 'crowdsourcehinter_block_is_staff'); $('.crowdsourcehinter_block', element).attr('class', 'crowdsourcehinter_block_is_staff');
$.each(result, function(index, value) { $.each(result, function(index, value) {
...@@ -164,7 +165,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -164,7 +165,7 @@ function CrowdsourceHinter(runtime, element, data){
var hintCreationTemplate = $(Mustache.render($('#add_hint_creation').html(), {})); var hintCreationTemplate = $(Mustache.render($('#add_hint_creation').html(), {}));
$('.csh_student_answer', element).append(hintCreationTemplate); $('.csh_student_answer', element).append(hintCreationTemplate);
} else { } else {
showStudentHintContribution(hint, student_answer); showStudentHintRatingUX(hint, student_answer);
} }
} }
}); });
...@@ -175,7 +176,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -175,7 +176,7 @@ function CrowdsourceHinter(runtime, element, data){
* is triggered by clicking the "contribute a new hint" button. * is triggered by clicking the "contribute a new hint" button.
* @param createTextInputButtonHTML is the "contribute a new hint" button that was clicked * @param createTextInputButtonHTML is the "contribute a new hint" button that was clicked
*/ */
function create_text_input(){ return function(createTextInputButtonHTML){ function createHintContributionTextInput(){ return function(createTextInputButtonHTML){
$('.csh_student_hint_creation', element).each(function(){ $('.csh_student_hint_creation', element).each(function(){
$(createTextInputButtonHTML.currentTarget).show(); $(createTextInputButtonHTML.currentTarget).show();
}); });
...@@ -187,11 +188,11 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -187,11 +188,11 @@ function CrowdsourceHinter(runtime, element, data){
var hintTextInputTemplate = $(Mustache.render($('#hint_text_input').html(), {student_answer: student_answer})); var hintTextInputTemplate = $(Mustache.render($('#hint_text_input').html(), {student_answer: student_answer}));
$('.csh_answer_text', element).append(hintTextInputTemplate); $('.csh_answer_text', element).append(hintTextInputTemplate);
}} }}
$(element).on('click', '.csh_student_hint_creation', create_text_input($(this))); $(element).on('click', '.csh_student_hint_creation', createHintContributionTextInput($(this)));
/** /**
* Submit a new hint created by the student to the hint pool. Hint text is in * Submit a new hint created by the student to the hint pool. Hint text is in
* the text input area created by create_text_input. Contributed hints are specific to * the text input area created by createHintContributionTextInput. Contributed hints are specific to
* incorrect answers. Triggered by clicking the "submit hint" button. * incorrect answers. Triggered by clicking the "submit hint" button.
* @param submitHintButtonHTML is the "submit hint" button clicked * @param submitHintButtonHTML is the "submit hint" button clicked
*/ */
...@@ -258,7 +259,6 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -258,7 +259,6 @@ function CrowdsourceHinter(runtime, element, data){
*/ */
function removeReportedHint(){ function removeReportedHint(){
Logger.log('crowd_hinter.staff_rate_hint.click.event', {"hint": hint, "student_answer": student_answer, "rating": rating}); Logger.log('crowd_hinter.staff_rate_hint.click.event', {"hint": hint, "student_answer": student_answer, "rating": rating});
//TODO: change if statement, just find .csh_hint_value with attribute of hint
$(".csh_hint_value[value='" + hint + "']", element).remove(); $(".csh_hint_value[value='" + hint + "']", element).remove();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment