diff --git a/admin/static/js/main.js b/admin/static/js/main.js
index a782969..50022d4 100644
--- a/admin/static/js/main.js
+++ b/admin/static/js/main.js
@@ -59,7 +59,7 @@ angular.module("easylearncode.admin.core", ["ngRoute", "ngResource", "services.u
]);
;
angular.module("easylearncode.admin.home", ["easylearncode.admin.core"]);
-angular.module("easylearncode.admin.course", ["easylearncode.admin.core"])
+angular.module("easylearncode.admin.course", ["easylearncode.admin.core", "com.2fdevs.videogular", "com.2fdevs.videogular.plugins.controls", "com.2fdevs.videogular.plugins.overlayplay", "com.2fdevs.videogular.plugins.buffering", "com.2fdevs.videogular.plugins.poster", "info.vietnamcode.nampnq.videogular.plugins.youtube", "info.vietnamcode.nampnq.videogular.plugins.quiz"])
.config(["$locationProvider", "$routeProvider", function ($locationProvider, $routeProvider) {
$routeProvider
.when("/",
@@ -190,8 +190,8 @@ angular.module("easylearncode.admin.course", ["easylearncode.admin.core"])
headers: {'Content-Type': undefined },
transformRequest: angular.identity
}).success(function (data) {
- course.img = data.image_url;
- }).error();
+ course.img = data.image_url;
+ }).error();
})
};
@@ -538,7 +538,7 @@ angular.module("easylearncode.admin.course", ["easylearncode.admin.core"])
};
- var ModalInstanceCtrl = function ($scope, $modalInstance, form) {
+ var ModalInstanceCtrl = function ($scope, $modalInstance, form) {
$scope.form = form;
@@ -551,9 +551,210 @@ angular.module("easylearncode.admin.course", ["easylearncode.admin.core"])
};
};
}])
- .controller("QuestionAdminCtrl", ["$scope", "api", "$routeParams", '$modal', '$http', function ($scope, api, $routeParams, $modal, $http) {
- $scope.lecture = api.Model.get({type: 'lectures', id: $routeParams.lectureId, recurse: true});
+ .controller("QuestionAdminCtrl", ["$scope", "api", "$routeParams", '$modal', '$http', '$sce', '$compile', '$rootScope', "VG_EVENTS", function ($scope, api, $routeParams, $modal, $http, $sce, $compile, $rootScope, VG_EVENTS) {
+ var addForm = {
+ "form_id": 1,
+ "form_name": "Add Question",
+ "form_fields": [
+ {
+ "field_id": 1,
+ "field_title": "title",
+ "field_type": "textfield",
+ "field_value": "",
+ "field_required": true
+ },
+ {
+ "field_id": 2,
+ "field_title": "description",
+ "field_type": "code",
+ "field_language": "python",
+ "field_value": "",
+ "field_required": true
+ }
+ ]
+ }
+
+ var ModalInstanceCtrl = function ($scope, $modalInstance, form) {
+
+ $scope.form = form;
+
+ $scope.ok = function (data) {
+ $modalInstance.close($scope.form);
+ };
+
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
+ };
+ $scope.showAddModal = function () {
+ var modalInstance = $modal.open({
+ templateUrl: 'myModalContent.html',
+ controller: ModalInstanceCtrl,
+ resolve: {
+ form: function () {
+ return addForm;
+ }
+ }
+ });
+ modalInstance.result.then(function (addForm) {
+ lecture = {}
+ _.each(addForm.form_fields, function (ele) {
+ lecture[ele.field_title] = ele.field_value;
+ });
+// api.Model.save({type: 'lectures'}, lecture, function (data) {
+// api.Model.get({type: 'lessons', id: $routeParams.lessonId}, function (lesson) {
+// lesson.lecture_keys.push(data.Id);
+// api.Model.save({type: 'lessons', id: lesson.Id}, lesson, function () {
+// $scope.lesson.lecture_keys.push(data);
+// });
+// });
+// })
+ }, function () {
+ console.log('Modal dismissed at: ' + new Date());
+ });
+
+ };
+
+ $scope.lecture = api.Model.get({type: 'lectures', id: $routeParams.lectureId, recurse: true}, function (data) {
+ $scope.currentTime = 0;
+ $scope.totalTime = 0;
+ $scope.state = null;
+ $scope.volume = 1;
+ $scope.isCompleted = false;
+ $scope.API = null;
+
+ $scope.onPlayerReady = function (API) {
+ $scope.API = API;
+ };
+
+ $scope.onCompleteVideo = function () {
+ $scope.isCompleted = true;
+ };
+
+ $scope.onUpdateState = function (state) {
+ $scope.state = state;
+ };
+
+ $scope.pauseVideo = function () {
+ $scope.API.pause();
+ };
+
+ $rootScope.$on(VG_EVENTS.ON_EXIT_FULLSCREEN, function () {
+ $scope.API.setSize(700, 380);
+ });
+//
+// $rootScope.$on(VG_EVENTS.ON_ENTER_FULLSCREEN, function(){
+// alert($scope.config.width);
+// $scope.config.width = 700;
+// $scope.config.height = 380;
+// });
+
+ $scope.onUpdateTime = function (currentTime, totalTime) {
+ $scope.currentTime = currentTime;
+ $scope.totalTime = totalTime;
+// angular.forEach(codes, function (code) {
+// if (code.time < currentTime) {
+// if ($scope.state == 'play')
+// $scope.code = code.code;
+// }
+// });
+ };
+
+ $scope.onUpdateVolume = function (newVol) {
+ $scope.volume = newVol;
+ };
+
+ $scope.onUpdateSize = function (width, height) {
+ $scope.config.width = width;
+ $scope.config.height = height;
+ };
+
+ $scope.onQuizSubmit = function (data) {
+ return {
+ result: true,
+ description: "Correct"
+ }
+ }
+
+ $scope.stretchModes = [
+ {
+ label: "None",
+ value: "none"
+ },
+ {
+ label: "Fit",
+ value: "fit"
+ },
+ {
+ label: "Fill",
+ value: "fill"
+ }
+ ];
+ $scope.goLecture = function (lecture) {
+// $location.path("/").search('lecture_id', lecture.Id).replace();
+// $scope.lecture = lecture;
+// $scope.loadLecture();
+ }
+ $scope.loadLecture = function () {
+ $scope.youtubeUrl = $sce.trustAsResourceUrl("http://www.youtube.com/watch?v=" + $scope.lecture.youtube_id);
+ $scope.show = false;
+ if (angular.isDefined($scope.vgScope)) {
+ $scope.vgScope.$destroy();
+ }
+ $scope.vgScope = $scope.$new(false);
+ $('#video').html($compile("\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n {{ currentTime }}\r\n \r\n \r\n \r\n {{ totalTime }}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ")($scope.vgScope));
+ $("#gplus-cm").html("Loading G+ Comments");
+ }
+
+ $scope.config = {
+ width: 700,
+ height: 380,
+ autoHide: true,
+ autoHideTime: 3000,
+ autoPlay: false,
+ responsive: false,
+ stretch: $scope.stretchModes[1],
+ theme: {
+ url: "/application/css/videogular/videogular.css",
+ playIcon: "",
+ pauseIcon: "",
+ volumeLevel3Icon: "",
+ volumeLevel2Icon: "",
+ volumeLevel1Icon: "",
+ volumeLevel0Icon: "",
+ muteIcon: "",
+ enterFullScreenIcon: "",
+ exitFullScreenIcon: ""
+ },
+ plugins: {
+ poster: {
+ url: "http://upload.wikimedia.org/wikipedia/commons/4/4a/Python3-powered_hello-world.svg"
+ },
+ quiz: {
+ data: [
+ {
+ "time": "164",
+ "question_id": "70d70be689d73e08687496a6d12b2b0d",
+ "html": "
Select the restaurant(s) that serve Canadian cuisine for a price of $$$.\n\n
\nGeorgie Porgie\n87%\n$$$\nCanadian,Pub Food\n\nSilver Spoon\n97%\n$$$$\nCanadian\n\nCoffee Cafe\n77%\n$$\nCoffee/Tea,Diner\n
\n\n
\n\n\n
\n\n\n
\n\n\n
",
+ "background": "color",
+ "background_src": "white",
+ "post_answer_url": "https:\/\/class.coursera.org\/programming2-001\/quiz\/video_quiz_attempt?method=post_question_answer&quiz_id=20&preview=0&question_id=70d70be689d73e08687496a6d12b2b0d"
+ },
+ {
+ "time": "180",
+ "question_id": "9326a7b17e15cfc69f8e46f9357bf6c5",
+ "html": "\n
\ndef is_palindrome_v3(s):\n i = 0\n j = len(s) - 1\n while i < j and s[i] == s[j]:\n i = i + 1\n j = j - 1\n\n return j <= i\n
\n\nIf
s refers to a single-character string such as 'x', when the return statement is reached, which of the following expressions evaluates to
True?
\n\n\n
\n\n\n
\n\n\n
\n\n\n
",
+ "background": "color",
+ "background_src": "white",
+ "post_answer_url": "https:\/\/class.coursera.org\/programming2-001\/quiz\/video_quiz_attempt?method=post_question_answer&quiz_id=18&preview=0&question_id=9326a7b17e15cfc69f8e46f9357bf6c5"
+ }
+ ]
+ }
+ }
+ };
+ $scope.loadLecture();
+ });
}]);
angular.module("easylearncode.admin.quiz", ["easylearncode.admin.core"])
.config(["$locationProvider", "$routeProvider", function ($locationProvider, $routeProvider) {
@@ -611,10 +812,10 @@ angular.module("easylearncode.admin.quiz", ["easylearncode.admin.core"])
modalInstance.result.then(function (addForm) {
quiz = {}
_.each(addForm.form_fields, function (ele) {
- if(ele.field_type == "date"){
+ if (ele.field_type == "date") {
ele.field_value = new Date(ele.field_value);
}
- if(ele.field_title == "week"){
+ if (ele.field_title == "week") {
ele.field_value = parseInt(ele.field_value);
}
quiz[ele.field_title] = ele.field_value;
@@ -645,10 +846,10 @@ angular.module("easylearncode.admin.quiz", ["easylearncode.admin.core"])
modalInstance.result.then(function (addForm) {
quiz_tmp = {}
_.each(addForm.form_fields, function (ele) {
- if(ele.field_type == "date"){
+ if (ele.field_type == "date") {
ele.field_value = new Date(ele.field_value);
}
- if(ele.field_title == "week"){
+ if (ele.field_title == "week") {
ele.field_value = parseInt(ele.field_value);
}
quiz_tmp[ele.field_title] = ele.field_value;
diff --git a/admin/templates/admin/base.html b/admin/templates/admin/base.html
index e11e25f..a79e182 100644
--- a/admin/templates/admin/base.html
+++ b/admin/templates/admin/base.html
@@ -1,210 +1,223 @@
-
-
-
- Easy Learn Code - Admin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ Easy Learn Code - Admin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% block mediaJS %}
- {% endblock %}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
Here settings can be configured...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% block mediaJS %}
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
+
diff --git a/admin/templates/admin/course.html b/admin/templates/admin/course.html
index 18cf2c7..f59fb5b 100644
--- a/admin/templates/admin/course.html
+++ b/admin/templates/admin/course.html
@@ -239,11 +239,11 @@ Lecture
{% endblock %}
{% block pluginJS %}
-
-
-
-
-
-
-
-
-
-
+
{% endblock %}
\ No newline at end of file
diff --git a/application/static/js/main.js b/application/static/js/main.js
index 8fd08f3..654e48d 100644
--- a/application/static/js/main.js
+++ b/application/static/js/main.js
@@ -683,7 +683,42 @@ angular.module("easylearncode.learn").run(function () {
description: "Định nghĩa hàm trong python",
time: 552,
youtube_id: 'JwO_25S_eWE'
- }
+ },
+ {
+ Id: 'asdsfsAsafasWWWWWWWWWWWxxxx11',
+ title: "Biểu đồ những gì xảy ra khi hàm được gọi",
+ description: "Hiểu được phạm vi biến và hàm được gọi",
+ time: 552,
+ youtube_id: '6qCQB8E5bkI'
+ },
+ {
+ Id: 'asdsfsAsafasWWWWWWWWWWWxxxx12',
+ title: "Hàm đệ quy",
+ description: "Tìm hiểu về đệ quy",
+ time: 552,
+ youtube_id: 'o920mj0NbhE'
+ },
+ {
+ Id: 'asdsfsAsafasWWWWWWWWWWWxxxx13',
+ title: "So sánh hàm lặp và đệ quy",
+ description: "Tìm hiểu về đệ quy",
+ time: 552,
+ youtube_id: 'kx6DfrYfWnQ'
+ },
+ {
+ Id: 'asdsfsAsafasWWWWWWWWWWWxxxx14',
+ title: "Viết hàm Fibonacci",
+ description: "Giới thiệu dãy fibonacci",
+ time: 552,
+ youtube_id: 'Bdbc1ZC-vhw'
+ },
+ {
+ Id: 'asdsfsAsafasWWWWWWWWWWWxxxx15',
+ title: "Hàm Fibonacci sử dụng vòng lặp",
+ description: "Một cách khác để viết hàm Fibonacci",
+ time: 552,
+ youtube_id: '94O_3QCvfqI'
+ },
];
$scope.lang =
{
@@ -940,7 +975,7 @@ angular.module("easylearncode.learn").run(function () {
$scope.ViewOnYoutube = function () {
$window.open($scope.youtubeUrl + '#t=' + $scope.currentTime);
- $scope.state = 'pause';
+ $scope.API.pause();
}
$scope.lecture = _.where($scope.lectures, {Id: $location.search()['lecture_id']})[0];
$scope.loadLecture();
@@ -1340,7 +1375,7 @@ angular.module("easylearncode.visualization", ["ui.bootstrap", "ui.ace", 'easyle
];
$scope.updateVisualizationUrl = function () {
- src = "http://pythontutor.com/iframe-embed.html#code=" + encodeURIComponent($scope.exercise[1].source) + "&cumulative=false&heapPrimitives=false&drawParentPointers=false&textReferences=false&showOnlyOutputs=false&py=2&curInstr=0&codeDivWidth=350&codeDivHeight=400";
+ src = "http://pythontutor.com/iframe-embed.html#code=" + encodeURIComponent($scope.TreeId.currentNode.code) + "&cumulative=false&heapPrimitives=false&drawParentPointers=false&textReferences=false&showOnlyOutputs=false&py=2&curInstr=0&codeDivWidth=350&codeDivHeight=400";
$("#visualizationModal .modal-body").find("iframe").remove();
var iframe = $('');
$("#visualizationModal .modal-body").append(iframe);
@@ -1389,7 +1424,7 @@ angular.module("easylearncode.visualization", ["ui.bootstrap", "ui.ace", 'easyle
$scope.showConsole = true;
jqconsole.Reset();
dataObj = {
- command: $scope.exercise[1].source,
+ command: $scope.TreeId.currentNode.code,//$scope.exercise[1].source,
testScript: '',
type: 'evalUser'
};
@@ -1411,20 +1446,47 @@ angular.module("easylearncode.visualization", ["ui.bootstrap", "ui.ace", 'easyle
})
});
- $scope.treedata =
+ $scope.Tests =
[
- { "roleName": "User", "roleId": "role1", "children": [
- { "roleName": "subUser1", "roleId": "role11", "children": [] },
- { "roleName": "subUser2", "roleId": "role12", "children": [
- { "roleName": "subUser2-1", "roleId": "role121", "children": [
- { "roleName": "subUser2-1-1", "roleId": "role1211", "children": [] },
- { "roleName": "subUser2-1-2", "roleId": "role1212", "children": [] }
- ]}
- ]}
+ { "title": "Phần 1: Kiến thức cơ bản về Python", "id": "LessonId1", "children": [
+ { "title": "GT về chương trình, loại dữ liệu và giá trị", "id": "LectureId01", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId01", "code": 'print(3+7)\r\nprint(2-1) \r\nprint("this is a chunk of text")', "children":[]},
+ {"title": "Ví dụ 02", "id": "LessonId02", "code": 'a = 3+5\r\nb= a*a-a-1\r\nc = a*b\r\nprint(c)', "children":[]},
+ {"title": "Ví dụ 03", "id": "LessonId03", "code": 'a = -6\r\nb= a*a-a-1\r\nc = a*b\r\nif(a<0):\r\n\tprint(c)\r\nelse:\r\n\tprint(c-a)', "children":[]},
+ {"title": "Ví dụ 04", "id": "LessonId04", "code": 'a = -6\r\nb= a*a-a-1\r\nc = a*b\r\nif(a<0):\r\n\tprint("a<0")\r\n\tprint(c)\r\nelse:\r\n\tprint("a is not less than 0")\r\n\tprint(c-a)\r\n\tprint("We are done with the program")', "children":[]}
+ ]},
+ { "title": "List trong Python", "id": "LectureId03", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId05", "code": "a =[1, 2, -7, 9, 11]\r\nprint(a)\r\na[1] = \"Sal's String\"\r\nprint (a)\r\nb=a\r\nprint(b)\r\nc = a[:]\r\nprint (c)\r\nb[0] = 0\r\nprint(b)\r\nprint(a)\r\nprint(c)\r\na.append(\"new elemen\")\r\nprint(a)\r\nprint(b)\r\nprint(c)", "children":[]}
+ ]},
+ { "title": "Vòng lặp for trong python", "id": "LectureId04", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId06", "code": "print range(6)\r\nprint range(7)\r\nprint range(1,7)\r\nprint range(0, 8, 2)\r\nprint range(3, 31, 3)" , "children":[]},
+ {"title": "Ví dụ 02", "id": "LessonId07", "code": "for i in range(5):\n print i" , "children":[]},
+ {"title": "Ví dụ 03", "id": "LessonId08", "code": "sum = 0\r\nfor i in range(5):\r\n sum = sum+i\r\n print sum" , "children":[]}
+ ]},
+ { "title": "Vòng lặp while trong python", "id": "LectureId05", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId09", "code": "#this while loop calculates the sum of 0 throunh 9 (including 9) and places\n#it in the variable \"sum\"\nsum = 0\ni = 0\nwhile i < 10:\n sum = sum + i\n print sum\n i = i +1\n \n#for i in range(10):\n# sum = sum + i\n# print sum" , "children":[]}
+ ]},
+ { "title": "Kiểu chuỗi trong python", "id": "LectureId06", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId10", "code": "a = \"My first test string\"\nb = 'Another test string that I have defined'\nc = \"this is Sal's string\"\nd = 'My favorite word is \"asparaus\", what is your?'\nmath_string = \"3+4*2\"\nexpression_string = \"a+' '+b+' tiger'\"\nprint a\nprint b\nprint c\nprint d\nprint math_string\nprint expression_string\n" , "children":[]},
+ {"title": "Ví dụ 02", "id": "LessonId11", "code": "a = \"My first test string\"\nb = 'Another test string that I have defined'\nc = \"this is Sal's string\"\nd = 'My favorite word is \"asparaus\", what is your?'\nmath_string = \"3+4*2\"\nexpression_string = \"a+' '+b+' tiger'\"\nprint a\nprint b\nprint c\nprint d\nprint math_string\nprint expression_string\nprint a +b" , "children":[]},
+ {"title": "Ví dụ 03", "id": "LessonId12", "code": "a = \"My first test string\"\nb = 'Another test string that I have defined'\nc = \"this is Sal's string\"\nd = 'My favorite word is \"asparaus\", what is your?'\nmath_string = \"3+4*2\"\nexpression_string = \"a+' '+b+' tiger'\"\nprint a\nprint b\nprint c\nprint d\nprint math_string\nprint expression_string\nprint math_string.find('*')\nprint math_string.find('3')" , "children":[]},
+ {"title": "Ví dụ 04", "id": "LessonId13", "code": "a = \"My first test string\"\nb = 'Another test string that I have defined'\nc = \"this is Sal's string\"\nd = 'My favorite word is \"asparaus\", what is your?'\nmath_string = \"3+4*2\"\nexpression_string = \"a+' '+b+' tiger'\"\nprint a\nprint b\nprint c\nprint d\nprint math_string\nprint expression_string\nprint c.replace('i', 'o')\nprint c" , "children":[]},
+ {"title": "Ví dụ 05", "id": "LessonId14", "code": "a = \"My first test string\"\nb = 'Another test string that I have defined'\nc = \"this is Sal's string\"\nd = 'My favorite word is \"asparaus\", what is your?'\nmath_string = \"3+4*2\"\nexpression_string = \"a+' '+b+' tiger'\"\nprint a\nprint b\nprint c\nprint d\nprint math_string\nprint expression_string\nc = c.replace('i', 'o')\nprint c" , "children":[]},
+ {"title": "Ví dụ 06", "id": "LessonId15", "code": "a = \"My first test string\"\nb = 'Another test string that I have defined'\nc = \"this is Sal's string\"\nd = 'My favorite word is \"asparaus\", what is your?'\nmath_string = \"3+4*2\"\nexpression_string = \"a+' '+b+' tiger'\"\nprint a\nprint b\nprint c\nprint d\nprint math_string\nprint expression_string\nprint eval(math_string)\nprint eval(math_string + '1')" , "children":[]},
+ ]},
+ { "title": "Viết một chương trình đơn giản", "id": "LectureId07", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId16", "code": "#Enter non-negative integer to take the factorial of:\nnumber = 10\n\nproduct = 1\nfor i in range(number):\n product = product * (i+1)\n\nprint product" , "children":[]}
+ ]},
+ { "title": "Định nghĩa hàm trong python", "id": "LectureId08", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId17", "code": "#returns the facturial of the argument \"number\"\ndef factorial(number): \n product = 1\n for i in range(number):\n product = product * (i+1)\n return product\n\nprint factorial(10)" , "children":[]}
+ ]},
+ { "title": "Hàm đệ quy", "id": "LectureId09", "children": [
+ {"title": "Ví dụ 01", "id": "LessonId18", "code": "def factorial(number):\n if number <= 1:\n return 1\n else:\n return number*factorial(number -1)\n\nprint factorial(10)", "children":[]}
+ ]},
]},
-
- { "roleName": "Admin", "roleId": "role2", "children": [] },
-
- { "roleName": "Guest", "roleId": "role3", "children": [] }
+ { "title": "Phần 2: Python nâng cao", "id": "LessonId2", "children": [
+ { "title": "Bài 1", "id": "LectureId33", "children": [
+ ]}
+ ]}
];
}]);
\ No newline at end of file
diff --git a/application/templates/visualization.html b/application/templates/visualization.html
index b9b451f..aa25e27 100644
--- a/application/templates/visualization.html
+++ b/application/templates/visualization.html
@@ -59,7 +59,7 @@ Code window
@@ -70,18 +70,17 @@ Code window
-
Python
- syntax
+
Contents