Commit abae7d6c by solashirai Committed by Piotr Mitros

variable fixes and beginnings of Mustache templating

parent a8e14d11
...@@ -327,7 +327,7 @@ class CrowdsourceHinter(XBlock): ...@@ -327,7 +327,7 @@ class CrowdsourceHinter(XBlock):
del self.Flagged[flagged_answer] del self.Flagged[flagged_answer]
return {'rating': 'removed'} return {'rating': 'removed'}
if data['student_rating'] == 'flag': if data['student_rating'] == 'flag':
# add hint to # add hint to Flagged dictionary
self.Flagged[str(answer_data)] = data_hint self.Flagged[str(answer_data)] = data_hint
return {"rating": 'flagged', 'hint': data_hint} return {"rating": 'flagged', 'hint': data_hint}
if str(data_hint) not in self.Voted: if str(data_hint) not in self.Voted:
......
/* CSS for CrowdsourceHinter */ /* CSS for CrowdsourceHinter */
.crowdsourcehinter_block .count { .crowdsourcehinter_block .csh_feedback {
font-weight: bold;
}
.crowdsourcehinter_block .feedback {
border-style: solid; border-style: solid;
border-width: thin; border-width: thin;
border-color: rgb(200,200,200); border-color: rgb(200,200,200);
} }
.crowdsourcehinter_block .vote { .crowdsourcehinter_block .csh_vote {
padding-top: 0px !important; padding-top: 0px !important;
padding-bottom: 0px !important; padding-bottom: 0px !important;
} }
.hint_value{ .csh_hint_value{
display: flex; display: flex;
margin-left: 10px; margin-left: 10px;
flex-flow: column; flex-flow: column;
} }
.hint_used{ .csh_hint_used{
flex-direction: row; flex-direction: row;
} }
.crowdsourcehinter_block .HintsToUse { .crowdsourcehinter_block .csh_HintsToUse {
background-color: #FF8; background-color: #FF8;
} }
.rate_hint { .csh_rate_hint {
width: 100%; width: 100%;
margin-left:auto; margin-left:auto;
margin-right:auto; margin-right:auto;
...@@ -50,23 +46,23 @@ div[data-rate="downvote"] { ...@@ -50,23 +46,23 @@ div[data-rate="downvote"] {
font-weight: bold; font-weight: bold;
} }
[csh_isStaff="false"] .csh_flagged_hints { .crowdsourcehinter_block .csh_flagged_hints {
visibility: hidden; visibility: hidden;
display: none; display: none;
} }
[csh_isStaff="true"] .csh_flagged_hints { .crowdsourcehinter_block_is_staff .csh_flagged_hints {
visibility: visible; visibility: visible;
} }
.rating{ .csh_rating{
margin-right: 10px; margin-right: 10px;
} }
.rate_hint{ cursor: pointer } .csh_rate_hint{ cursor: pointer }
.rate_hint{ color: #948f8f; } .csh_rate_hint{ color: #948f8f; }
.hintsarea { .csh_hintsarea {
display: flex; display: flex;
flex-direction: colomn; flex-direction: colomn;
} }
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
</div> </div>
</script> </script>
<script id="personTpl" type="text/template">
<h1>{{firstName}} {{lastName}}</h1>
<p>Blog URL: <a href="{{blogURL}}">{{blogURL}}</a></p>
</script>
<script type="x-tmpl-mustache" id="show_answer_feedback"> <script type="x-tmpl-mustache" id="show_answer_feedback">
<div class="csh_student_answer"> <div class="csh_student_answer">
<span><b> {{answer}}</b></span> <span><b> {{answer}}</b></span>
...@@ -36,10 +41,11 @@ ...@@ -36,10 +41,11 @@
</div> </div>
</script> </script>
<div class="crowdsourcehinter_block" csh_isStaff= false> <div class="crowdsourcehinter_block">
<p> <span class='csh_HintsToUse'></span> <p> <span class='csh_HintsToUse'></span>
</p> </p>
<div id="sampleArea"></div>
<div class="crowdsourcehinter_block"> <div class="crowdsourcehinter_block">
......
function CrowdsourceHinter(runtime, element){ function CrowdsourceHinter(runtime, element){
//use executionFunctions to prevent old initializations of hinter from working after switching units //executeHinter is used to disable the hinter after switching units in an edX course
var executeFunctions = true; //If the code is not made to stop running, the hinter will act up after switching from and back to
if(executeFunctions){ //a certain unit.
var executeHinter = true;
if(executeHinter){
var isShowingHintFeedback = false; var isShowingHintFeedback = false;
var isStaff = false; var isStaff = false;
$(".HintsToUse", element).text(""); $(".csh_HintsToUse", element).text("");
function stopScript(){ function stopScript(){
//This function is used to prevent a particular instance of the hinter from acting after //This function is used to prevent a particular instance of the hinter from acting after
//switching between edX course's units. //switching between edX course's units.
executionFunctions = false; executeHinter = false;
} }
Logger.listen('seq_next', null, stopScript); Logger.listen('seq_next', null, stopScript);
Logger.listen('seq_prev', null, stopScript); Logger.listen('seq_prev', null, stopScript);
Logger.listen('seq_goto', null, stopScript); Logger.listen('seq_goto', null, stopScript);
//read the data from the problem_graded event here //read the data from the problem_graded event here
//function get_event_data(event_type, data, element){ function get_event_data(event_type, data, element){
// console.log("is this still changing"); console.log("is this changing");
// onStudentSubmission(data); /*below is minimal mustache template usage attempt
//} $.get('crowdsourcehinter.html', function(data) {
//Logger.listen('problem_graded', null, get_event_data); var template = $('#personTpl').html();
var html = Mustache.to_html(template, data);
$('#sampleArea').html(html);
});
*/
onStudentSubmission(data);
}
Logger.listen('problem_graded', null, get_event_data);
function onStudentSubmission(event_type, problem_graded_event_data, element){ function onStudentSubmission(problem_graded_event_data){
//This function will determine whether or not the student correctly answered the question. //This function will determine whether or not the student correctly answered the question.
//If it was correctly answered it will begin the process for giving feedback on hints. //If it was correctly answered it will begin the process for giving feedback on hints.
if (problem_graded_event_data[1].search(/class="correct/) === -1){ if (problem_graded_event_data[1].search(/class="correct/) === -1){
...@@ -44,7 +54,6 @@ function CrowdsourceHinter(runtime, element){ ...@@ -44,7 +54,6 @@ function CrowdsourceHinter(runtime, element){
success: function(result) { success: function(result) {
if (result['is_user_staff']) { if (result['is_user_staff']) {
isStaff = true; isStaff = true;
$('.crowdsourcehinter_block').attr('csh_isStaff', true);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'get_feedback'), url: runtime.handlerUrl(element, 'get_feedback'),
...@@ -63,7 +72,6 @@ function CrowdsourceHinter(runtime, element){ ...@@ -63,7 +72,6 @@ function CrowdsourceHinter(runtime, element){
}); });
} }
} }
Logger.listen('problem_graded', null, onStudentSubmission);
function seehint(result){ function seehint(result){
//Show a hint to the student after an incorrect answer is submitted. //Show a hint to the student after an incorrect answer is submitted.
...@@ -124,6 +132,9 @@ function CrowdsourceHinter(runtime, element){ ...@@ -124,6 +132,9 @@ function CrowdsourceHinter(runtime, element){
function getFeedback(result){ function getFeedback(result){
//Set up the student feedback stage. Each student answer and all answer-specific hints for that answer are shown //Set up the student feedback stage. Each student answer and all answer-specific hints for that answer are shown
//to the student, as well as an option to create a new hint for an answer. //to the student, as well as an option to create a new hint for an answer.
if(isStaff){
$('.crowdsourcehinter_block').attr('class', 'crowdsourcehinter_block_is_staff');
}
if(!isShowingHintFeedback){ if(!isShowingHintFeedback){
var student_answers = []; var student_answers = [];
$.each(result, function(index, value) { $.each(result, function(index, value) {
......
setup.py setup.py
crowdsourcehinter/__init__.py crowdsourcehinter/__init__.py
crowdsourcehinter/crowdsourcehinter.py crowdsourcehinter/crowdsourcehinter.py
crowdsourcehinter/public/3rdParty/mustache.js
crowdsourcehinter/static/README.txt crowdsourcehinter/static/README.txt
crowdsourcehinter/static/css/crowdsourcehinter.css crowdsourcehinter/static/css/crowdsourcehinter.css
crowdsourcehinter/static/css/crowdsourcehinter.css~
crowdsourcehinter/static/html/crowdsourcehinter.html crowdsourcehinter/static/html/crowdsourcehinter.html
crowdsourcehinter/static/html/crowdsourcehinter.html~
crowdsourcehinter/static/html/crowdsourcehinterstudio.html crowdsourcehinter/static/html/crowdsourcehinterstudio.html
crowdsourcehinter/static/js/src/crowdsourcehinter.js crowdsourcehinter/static/js/src/crowdsourcehinter.js
crowdsourcehinter/static/js/src/crowdsourcehinter.js~ crowdsourcehinter/static/js/src/crowdsourcehinter.js~
......
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