Created
October 13, 2012 03:20
-
-
Save rrguntaka/3883094 to your computer and use it in GitHub Desktop.
Coursera Score listing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result = function(){ | |
var a = function(v){ return v.parentNode.nextSibling.nextSibling.nextSibling.nextSibling.textContent} | |
arr = $("b:contains('Total Score')").map(function(k,v){return a(v)}) | |
scores = $.map(arr, function(n, i){ | |
strs = n.split(" / ") | |
return {score:Number(strs[0]),max:Number(strs[1])} | |
}); | |
mt = 0;st = 0;$.each(scores, function(i,n){mt += n.max;st += n.score}) | |
return "Max Points: " + mt + ", Correct: " + st + ", Overall Score: " + (st/mt*100.0).toFixed(2) + " %"}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result = (function(){ | |
var getScoreElem = function(elem){return elem.nextSibling.nextSibling.textContent.replace('Explanation:',',Explanation:')} | |
arr = $("th:contains('Effective Score:')").map(function(k,v){return getScoreElem(v)}).get() | |
arr = $.grep(arr, function(n, i){ return (n != 'N/A');}); | |
scores = $.map(arr, function(n, i){ | |
strs = n.substr(0,n.indexOf(',')).split(" / ") | |
return {score:Number(strs[0]),max:Number(strs[1])} | |
}); | |
mt = 0;st = 0;$.each(scores, function(i,n){mt += n.max;st += n.score}) | |
return "Max Points: " + mt + ", Correct: " + st + ", Overall Score: " + (st/mt*100.0).toFixed(2) + " %"})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("a[data-lecture-id]").map(function(k,v){return v.textContent.trim()}).get().join('\n') | |
(function(){ | |
var f1 = function(k,v){return v.textContent} | |
return $(".item_list h4").map(f1)})() | |
// import re | |
// patt = 'Lecture (\d.\d).*\((\d+):(\d+)\)' | |
// for i in video_list.split('\n'): print(re.sub(patt,'\g<1>\t\g<2>\t\g<3>',i)) | |
/* | |
import re | |
str1 = """ | |
8.00 / 10.00, | |
10.00 / 20.00,""" ## A sample input | |
def parse_numbers(i): (l1,l2) = re.findall("(\d+.\d0)",i); return (float(l1),float(l2)) | |
print(reduce(lambda x, y: (x[0]+y[0],x[1]+y[1]), [parse_numbers(i) for i in str1.split("\n")])) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment