Skip to content

Instantly share code, notes, and snippets.

@yjlcoder
Last active November 9, 2017 11:37
Show Gist options
  • Select an option

  • Save yjlcoder/6b8c0cd62940a5805d9c163b90197a5e to your computer and use it in GitHub Desktop.

Select an option

Save yjlcoder/6b8c0cd62940a5805d9c163b90197a5e to your computer and use it in GitHub Desktop.
Get students who don't submit homeworks
var table = $("#main_content").children("table").children("tbody");
var grade = {};
var grade_length = table.children().first().children().length - 3;
var children_number = table.children().length;
var number_index = 1;
table.children().each(function(index){
var grade_str = "";
var base = 3;
var i = 0;
while(i < grade_length){
grade_str += ($.trim($(this).children().eq(i+base).children().first().text()) + "-");
i += 1
}
if(!(grade_str in grade)){
grade[grade_str] = [];
}
grade[grade_str].push($.trim($(this).children().eq(number_index).text()));
});
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}
})(console)
console.save(grade)
#!/usr/bin/env python3
import json
def isGood(grade_str):
problem_grade = grade_str.split('-')
problem_grade = problem_grade[:-1]
for i in problem_grade:
try:
a = int(i)
except:
return False
if a >= 100:
continue
else:
return False
return True
origin = set()
with open("number", 'r') as f:
origin = set([line.strip() for line in f])
with open("console.json", 'r') as f:
grade = json.load(f)
print(origin)
whole_number = 0
for key in grade.keys():
if isGood(key):
print(key, "GOOD")
for value in grade[key]:
try:
origin.remove(value)
whole_number += 1
except:
continue
print(origin)
#!/usr/bin/env python3
import os
origin = set()
with open("number", 'r') as f:
origin = set([line.strip() for line in f])
assignment_path = os.path.join(os.getcwd(), "assignments")
folders = [x[0] for x in os.walk(assignment_path)]
name = [x.split('/')[-1] for x in folders]
result = set()
for i in origin:
if i not in name:
result.add(i)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment