Commit abae7d6c by solashirai Committed by Piotr Mitros

variable fixes and beginnings of Mustache templating

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