Skip to content

Commit

Permalink
Issue #203 fixing indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohab authored and Mohab committed Apr 23, 2014
1 parent 19a0adb commit 2038533
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 72 deletions.
142 changes: 71 additions & 71 deletions tutor/app/assets/javascripts/tracks.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
// [Recommendation to students]
// Shows the dialog containing names of students
// who can recieve recommendation and a button to send recommendation
// Parameters:
// problem_id : id of problem
// recommender_id : id of student recommending the problem
// Returns: calls the function which fills the dialog with student names
// Author: Mohab Ghanim
function showdialog(problem_id, recommender_id){
$.ajax({
type: "GET",
url: '/tracks/show_classmates/' + problem_id,
datatype: 'json',
success: function(json){
fill(json, problem_id, recommender_id)}
});
}
// [Recommendation to students]
// Shows the dialog containing names of students
// who can recieve recommendation and a button to send recommendation
// Parameters:
// problem_id : id of problem
// recommender_id : id of student recommending the problem
// Returns: calls the function which fills the dialog with student names
// Author: Mohab Ghanim
function showdialog(problem_id, recommender_id){
$.ajax({
type: "GET",
url: '/tracks/show_classmates/' + problem_id,
datatype: 'json',
success: function(json){
fill(json, problem_id, recommender_id)}
});
}

// [Recommendation to students]
// Fills the dialog with student names and recommend buttons
// Parameters:
// problem_id : id of problem
// recommender_id : id of student recommending the problem
// data : data returned from the above method
// Returns: appends html in /tracks/id
// Author: Mohab Ghanim
function fill(data, problem_id, recommender_id){
elem = $('#container');
elem.html("");
if(Object.keys(data).length == 0){
elem.html("<div align='center'>No classmates to recommend this problem to</div>");
$('.classmates_list').bPopup();
return;
}
elem.html("<h2> Recommend this problem to </h2>")
elem.append("<ul class ='list-group'>");
$.each(data, function (i , datum){
datum = data[i];
temp = "<li class='list-group-item'>" + datum['student_name'] +
"<button type='button' class='recommend btn btn-xs'"+
"onclick='recommend(" + problem_id + "," + recommender_id + "," + i + ")'";
if (datum['recommended_before'] == 'true' ){
temp += "disabled";
temp += ">recommended before"
}else {
temp += ">recommend";
}
temp += "</button>" +
"</li>"
elem.append(temp);
});
elem.append("</ul>");
// [Recommendation to students]
// Fills the dialog with student names and recommend buttons
// Parameters:
// problem_id : id of problem
// recommender_id : id of student recommending the problem
// data : data returned from the above method
// Returns: appends html in /tracks/id
// Author: Mohab Ghanim
function fill(data, problem_id, recommender_id){
elem = $('#container');
elem.html("");
if(Object.keys(data).length == 0){
elem.html("<div align='center'>No classmates to recommend this problem to</div>");
$('.classmates_list').bPopup();
return;
}
elem.html("<h2> Recommend this problem to </h2>")
elem.append("<ul class ='list-group'>");
$.each(data, function (i , datum){
datum = data[i];
temp = "<li class='list-group-item'>" + datum['student_name'] +
"<button type='button' class='recommend btn btn-xs'"+
"onclick='recommend(" + problem_id + "," + recommender_id + "," + i + ")'";
if (datum['recommended_before'] == 'true' ){
temp += "disabled";
temp += ">recommended before"
}else {
temp += ">recommend";
}
temp += "</button>" +
"</li>"
elem.append(temp);
});
elem.append("</ul>");
$('.classmates_list').bPopup();
}

// [Recommendation to students]
// sends problem id , recommender id, student getting recommendation id
// to the controller to be inserted in the database
// Parameters:
// problem_id : id of problem
// recommender_id : id of student recommending the problem
// student_id : id of student recieving the problem
// Returns: none
// Author: Mohab Ghanim
function recommend(problem_id, recommender_id, student_id){
// [Recommendation to students]
// sends problem id , recommender id, student getting recommendation id
// to the controller to be inserted in the database
// Parameters:
// problem_id : id of problem
// recommender_id : id of student recommending the problem
// student_id : id of student recieving the problem
// Returns: none
// Author: Mohab Ghanim
function recommend(problem_id, recommender_id, student_id){

$.ajax({
type: "POST",
url: '/tracks/insert_recommendation/',
data: { p_id : problem_id,
r_id : recommender_id,
s_id : student_id
}
});
showdialog(problem_id, recommender_id);
$.ajax({
type: "POST",
url: '/tracks/insert_recommendation/',
data: { p_id : problem_id,
r_id : recommender_id,
s_id : student_id
}
});
showdialog(problem_id, recommender_id);

}
}
2 changes: 1 addition & 1 deletion tutor/app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def show_classmates
render json: students_receiving_recommendation
end

# [Recommendatio to students - Story 5.7]
# [Recommendation to students - Story 5.7]
# Inserts a record in the recommendation table containing the id of the problem,
# the id of the students recommending the problem, the id of the student recieving
# the recommendation
Expand Down

0 comments on commit 2038533

Please sign in to comment.