Skip to content

Commit

Permalink
fixed prob updating issue, related sub issue, attempts at reording is…
Browse files Browse the repository at this point in the history
…sue not done
  • Loading branch information
kkatzen committed Apr 29, 2015
1 parent 306531a commit 9823c08
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
1 change: 1 addition & 0 deletions api/controllers/ProblemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ module.exports = {
},

reorder: function (req, res) {
console.log("reorder" + req.param("folder"));
Problem.find({folder: req.param("folder")})
.sort({"num": 1})
.exec(function(err, problems) {
Expand Down
43 changes: 26 additions & 17 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ function wrong(){
return $("<span class='glyphicon glyphicon-remove'></span>").css("color", "red").css("margin-right", "5px");
}


function fillProblemEdit(problem) {
$("#edit").removeClass("hidden");
$("#editPlaceholder").addClass("hidden");
$("#editType").val(problem.type);
$("#editPhase").val(problem.phase);
$("#editProblemName").val(problem.name);
$("#editfolderDropdown").val(problem.folder);
$("#editFolderDropdown").val(problem.folder);
$("#editLanguageDropdown").val(problem.language);
$("#editDescription").val(problem.text);
$("#editStylePoints").val(problem.value.style),
Expand All @@ -23,7 +22,9 @@ function fillProblemEdit(problem) {
$( "#deleteProblem" ).click(function() {
if (confirm('Are you sure you wish to delete this problem ?')) {
$.post("/problem/delete", {id: problem.id}, function () {
emptyProblem();
$.post("/problem/reorder", {folder: problem.folder}, function () {
emptyProblem();
});
});
}
});
Expand Down Expand Up @@ -227,16 +228,13 @@ function getSubmission(submission,user,problem) {
$("#submissionProblem").empty().append(b);
$("#submissionCreatedBy").empty().append(a);
$("#relatedSubmissions").empty();
$("#ISL" + folder.id).append("<li>" + '<div class="problem-name-first left">' + "<a data-toggle='collapse' data-parent='#accordian' href='#ISL" + problem.id + "' >" + problem.name + "</a></div><span id='ipPoints" + problem.id + "'></span><span id='ipCount" + problem.id + "'></span><ul id='ISL" + problem.id + "' class='panel-collapse collapse'></ul></li>");
console.log(submission.code);

$("#submissionPoints").html("Style pts:" + submission.value.style + "/" + problem.value.style + "<br/>Func Points: " + submission.value.correct + "/" + problem.value.correct);
editor.setValue(submission.code);
console.log("refresh editor");

$("#submissionMessage").empty().html(submission.message);
$("#submissionTitle").html(problem.name);
$.post("/folder/read/", {id: problem.folder}, function(folder){
console.log(folder.name);
$("#submissionTitle").html(problem.name + "<i> in " + folder.name + "</i>");
});

Expand Down Expand Up @@ -267,7 +265,6 @@ function getSubmission(submission,user,problem) {
}

function getIndividual(user, refresh) {
console.log("getIndividual called");
//Generate page for particular individual student
if(curStudent == user.id && refresh == false){
return;
Expand Down Expand Up @@ -301,13 +298,15 @@ function getIndividual(user, refresh) {
if(!problem){
console.log("no problem");
$.post("/submission/delete", {id: submission.id}, function (submission) {
///OLD CODE: IF YOU WANT TO USE THIS, YOU MUST CALL REORDER WITHIN THIS DELETE
console.log("deleted submission" + submission.id);
});
}
$.post("/folder/read", {id: problem.folder}, function (folder) {
if(!folder){
console.log("no folder");
$.post("/problem/delete", {id: problem.id}, function (problem) {
///OLD CODE: IF YOU WANT TO USE THIS, YOU MUST CALL REORDER WITHIN THIS DELETE
console.log("deleted problem " + problem.id);
});
Expand Down Expand Up @@ -339,7 +338,6 @@ function getIndividual(user, refresh) {
$("#ISL" + folder.id).append("<li>" + "<div class='problem-name-first left'><a data-toggle='collapse' data-parent='#accordian' href='#ISL" + problem.id + "' >" + problem.name + "</a></div><span id='ipPoints" + problem.id + "'></span><span id='ipCount" + problem.id + "'></span><ul id='ISL" + problem.id + "' class='panel-collapse collapse'></ul></li>");
submissions.forEach( function (submission) {
submissionCount++;
console.log(user.displayName + " " + submissionCount + "/" + totalSubmissionNumber);
if(totalSubmissionNumber == submissionCount){
$("#studentRefresh").removeAttr('disabled');
}
Expand Down Expand Up @@ -420,9 +418,14 @@ function reloadFolders() {
$("#folderDropdown").empty();
$("#editFolderDropdown").empty();
numpoints = 0;
console.log("");
console.log("");
console.log("");
console.log("");
$.post("/folder/read", null, function (folders) {
folders.forEach(function (folder) {
addFolder(folder);
console.log(folder.name + " num:" + folder.num);
addFolder(folder)
});
});
}
Expand All @@ -431,10 +434,10 @@ function addFolder(folder) {

$("#folderDropdown").append($("<option></option>").attr("value",folder.id).html(folder.name));
$("#problemsfolderDropdown").append($("<option></option>").attr("value",folder.id).html(folder.name));
$("#editfolderDropdown").append($("<option></option>").attr("value",folder.id).html(folder.name));
$("#editFolderDropdown").append($("<option></option>").attr("value",folder.id).html(folder.name));

if(curProblem) {
$("#editfolderDropdown").val(curProblem.folder);
$("#editFolderDropdown").val(curProblem.folder);
}
if(curFolder) {
$("#problemsfolderDropdown").val(curFolder);
Expand All @@ -448,6 +451,7 @@ function addFolder(folder) {
$("#" + accordianFolderId).empty();
$.post("/problem/read", {folder: folder.id}, function (problems) {
problems.forEach( function (problem) {
// console.log(problem.name + " num:" + problem.num);
numpoints += parseInt(problem.value.style) + parseInt(problem.value.correct);
var link = addProblemToAccordian(problem, accordianFolderId);
$("#" + accordianFolderId).append(link);
Expand Down Expand Up @@ -505,8 +509,6 @@ function reloadSortableFolders() {
$("#leftSideFolders").append('<ul id="sortable" class="panel-default"></ul>');
$.post("/folder/read", null, function (folders) {
folders.forEach(function (folder) {


var expandButton = $("<a href='#accoridanFolder" + folder.id + "'></a>")
.attr("data-parent","#accordion")
.attr("data-toggle","collapse")
Expand Down Expand Up @@ -558,7 +560,9 @@ function reloadSortableFolders() {
.click(function () {
if (confirm('Are you sure you wish to delete this problem ?')) {
$.post("/problem/delete", {id: problem.id}, function () {
console.log('reloadSortableFolders();')
$.post("/problem/reorder", {folder: problem.folder}, function () {
console.log('reloadSortableFolders();')
});
});
}
reloadSortableFolders();
Expand Down Expand Up @@ -606,6 +610,9 @@ function reloadSortableFolders() {
var id = ui.item.attr('id');
var difference = oldIndex - newIndex;
$.post("/folder/update", {id: id, num: oldIndex, dir: difference}, function (folder) {
$.post("/folder/reorder", {}, function () {
alert("hi");
});
});
}
});
Expand Down Expand Up @@ -731,7 +738,9 @@ window.onload = function () {
} else {
console.dir(opts);
$.post("/problem/create", opts, function (problem) {
reloadFolders();
$.post("/problem/reorder", {folder: problem.folder}, function () {
reloadFolders();
});
});
}
});
Expand All @@ -744,7 +753,7 @@ window.onload = function () {
type: $("#editType").val(),
phase: $("#editPhase").val(),
name: $("#editProblemName").val(),
folder: $("#editfolderDropdown").val(),
folder: $("#editFolderDropdown").val(),
language: $("#editLanguageDropdown").val(),
text: $("#editDescription").val(),
correct: $("#editCorrectPoints").val(),
Expand Down
10 changes: 5 additions & 5 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ function addProblemToAccordian(problem,folderName){

var currentEarned = $(earnedPointsDiv).text();
var availablePoints = $(availPointsDiv).text();
console.log("currentEarnedPre" +currentEarned);
console.log("maxScore" +maxScore);
// console.log("currentEarnedPre" +currentEarned);
// console.log("maxScore" +maxScore);
currentEarned = Number(currentEarned);
currentEarned = currentEarned + maxScore;
console.log("currentEarnedPost" +currentEarned);
// console.log("currentEarnedPost" +currentEarned);
$(earnedPointsDiv).empty().append(currentEarned);
console.log("check a" + availablePoints + " e" + currentEarned);
// console.log("check a" + availablePoints + " e" + currentEarned);

if(availablePoints == currentEarned){
console.log("check is yes");
Expand Down Expand Up @@ -370,7 +370,7 @@ window.onload = function () {
var AST = acorn.parse(code); // return an abstract syntax tree structure
// var types = pnut.listTopLevelTypes(AST);
var ssOb = pnut.collectStructureStyleFacts(AST); // return a analysis of style grading by checking AST

console.log("ssOb" + ssOb.numDeclVar);
$.post("/submission/create", {problem: problem, code: code, style: JSON.stringify(ssOb)}, function (submission) {
addSubmission(submission);
foldersReload();
Expand Down
2 changes: 1 addition & 1 deletion views/home/admin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ ul {
</div>
<div class="col-md-6">
<label name="editFolder" class="control-label" for="folder">Folder</label>
<select id="editFolderDropdown" class="form-control"> </select>
<select id="eFolderDropdown" class="form-control"> </select>
</div>
</div>
</div>
Expand Down

0 comments on commit 9823c08

Please sign in to comment.