aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaref Haque <warefhaque@Warefs-MacBook-Pro.local>2016-07-19 04:21:17 +0000
committerWaref Haque <warefhaque@Warefs-MacBook-Pro.local>2016-07-19 04:21:17 +0000
commitdaefddd8dc45e7044e83bd40706cfdca36471fe9 (patch)
tree6d3617d1385d7e81af353f8196ddbd67204e26b2
parent5392cf6f6fa08d666ee58a2a57757192d9a50398 (diff)
proper exams rendering
-rw-r--r--.idea/jsLibraryMappings.xml7
-rw-r--r--.idea/libraries/solutions_repo_node_modules.xml14
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/solutions_repo.iml9
-rw-r--r--.idea/vcs.xml6
-rw-r--r--.idea/workspace.xml248
-rw-r--r--app.js48
-rw-r--r--routes/index.js45
8 files changed, 335 insertions, 50 deletions
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..ddeb853
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="JavaScriptLibraryMappings">
+ <file url="file://$PROJECT_DIR$" libraries="{solutions_repo node_modules}" />
+ <includedPredefinedLibrary name="Node.js Core" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/libraries/solutions_repo_node_modules.xml b/.idea/libraries/solutions_repo_node_modules.xml
new file mode 100644
index 0000000..fd48a42
--- /dev/null
+++ b/.idea/libraries/solutions_repo_node_modules.xml
@@ -0,0 +1,14 @@
+<component name="libraryTable">
+ <library name="solutions_repo node_modules" type="javaScript">
+ <properties>
+ <option name="frameworkName" value="node_modules" />
+ <sourceFilesUrls>
+ <item url="file://$PROJECT_DIR$/node_modules" />
+ </sourceFilesUrls>
+ </properties>
+ <CLASSES>
+ <root url="file://$PROJECT_DIR$/node_modules" />
+ </CLASSES>
+ <SOURCES />
+ </library>
+</component> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3d57a3a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/solutions_repo.iml" filepath="$PROJECT_DIR$/.idea/solutions_repo.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/solutions_repo.iml b/.idea/solutions_repo.iml
new file mode 100644
index 0000000..004ef7c
--- /dev/null
+++ b/.idea/solutions_repo.iml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="solutions_repo node_modules" level="project" />
+ </component>
+</module> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..a15a1d8
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ChangeListManager">
+ <list default="true" id="4718d530-71c3-46c6-9a25-2c29293cab58" name="Default" comment="">
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/app.js" afterPath="$PROJECT_DIR$/app.js" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/routes/index.js" afterPath="$PROJECT_DIR$/routes/index.js" />
+ </list>
+ <ignored path="solutions_repo.iws" />
+ <ignored path=".idea/workspace.xml" />
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+ <option name="TRACKING_ENABLED" value="true" />
+ <option name="SHOW_DIALOG" value="false" />
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+ <option name="LAST_RESOLUTION" value="IGNORE" />
+ </component>
+ <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
+ <component name="CreatePatchCommitExecutor">
+ <option name="PATCH_PATH" value="" />
+ </component>
+ <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
+ <component name="FavoritesManager">
+ <favorites_list name="solutions_repo" />
+ </component>
+ <component name="FileEditorManager">
+ <leaf>
+ <file leaf-file-name="index.js" pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/routes/index.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="1136">
+ <caret line="109" column="1" selection-start-line="109" selection-start-column="1" selection-end-line="109" selection-end-column="1" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="www.js" pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/bin/www.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="195">
+ <caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="app.js" pinned="false" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/app.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="341">
+ <caret line="34" column="0" selection-start-line="34" selection-start-column="0" selection-end-line="34" selection-end-column="0" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ </leaf>
+ </component>
+ <component name="Git.Settings">
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+ </component>
+ <component name="IdeDocumentHistory">
+ <option name="CHANGED_PATHS">
+ <list>
+ <option value="$PROJECT_DIR$/routes/index.js" />
+ <option value="$PROJECT_DIR$/app.js" />
+ </list>
+ </option>
+ </component>
+ <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
+ <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
+ <package-json value="$PROJECT_DIR$/package.json" />
+ </component>
+ <component name="JsGulpfileManager">
+ <detection-done>true</detection-done>
+ <sorting>DEFINITION_ORDER</sorting>
+ </component>
+ <component name="ProjectFrameBounds">
+ <option name="x" value="4" />
+ <option name="y" value="23" />
+ <option name="width" value="1276" />
+ <option name="height" value="777" />
+ </component>
+ <component name="ProjectLevelVcsManager" settingsEditedManually="false">
+ <OptionsSetting value="true" id="Add" />
+ <OptionsSetting value="true" id="Remove" />
+ <OptionsSetting value="true" id="Checkout" />
+ <OptionsSetting value="true" id="Update" />
+ <OptionsSetting value="true" id="Status" />
+ <OptionsSetting value="true" id="Edit" />
+ <ConfirmationsSetting value="0" id="Add" />
+ <ConfirmationsSetting value="0" id="Remove" />
+ </component>
+ <component name="ProjectView">
+ <navigator currentView="ProjectPane" proportions="" version="1">
+ <flattenPackages />
+ <showMembers />
+ <showModules />
+ <showLibraryContents />
+ <hideEmptyPackages />
+ <abbreviatePackageNames />
+ <autoscrollToSource />
+ <autoscrollFromSource />
+ <sortByType />
+ <manualOrder />
+ <foldersAlwaysOnTop value="true" />
+ </navigator>
+ <panes>
+ <pane id="Scratches" />
+ <pane id="Scope" />
+ <pane id="ProjectPane">
+ <subPane>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="routes" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="solutions_repo" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="bin" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ </subPane>
+ </pane>
+ </panes>
+ </component>
+ <component name="PropertiesComponent">
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
+ <property name="WebServerToolWindowFactoryState" value="false" />
+ <property name="HbShouldOpenHtmlAsHb" value="" />
+ <property name="settings.editor.selected.configurable" value="settings.nodejs" />
+ <property name="nodejs_interpreter_path" value="/usr/local/bin/node" />
+ <property name="javascript.nodejs.core.library.configured.version" value="6.2.2" />
+ <property name="settings.editor.splitter.proportion" value="0.2" />
+ </component>
+ <component name="RunManager">
+ <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" working-dir="">
+ <method />
+ </configuration>
+ </component>
+ <component name="ShelveChangesManager" show_recycled="false">
+ <option name="remove_strategy" value="false" />
+ </component>
+ <component name="TaskManager">
+ <task active="true" id="Default" summary="Default task">
+ <changelist id="4718d530-71c3-46c6-9a25-2c29293cab58" name="Default" comment="" />
+ <created>1468901747117</created>
+ <option name="number" value="Default" />
+ <option name="presentableId" value="Default" />
+ <updated>1468901747117</updated>
+ <workItem from="1468901749320" duration="256000" />
+ </task>
+ <servers />
+ </component>
+ <component name="TimeTrackingManager">
+ <option name="totallyTimeSpent" value="256000" />
+ </component>
+ <component name="ToolWindowManager">
+ <frame x="4" y="23" width="1276" height="777" extended-state="6" />
+ <editor active="false" />
+ <layout>
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24940239" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
+ <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+ <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
+ <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+ <window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
+ <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+ <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.329927" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+ <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
+ <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
+ <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
+ <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+ <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+ <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+ </layout>
+ </component>
+ <component name="VcsContentAnnotationSettings">
+ <option name="myLimit" value="2678400000" />
+ </component>
+ <component name="XDebuggerManager">
+ <breakpoint-manager />
+ <watches-manager />
+ </component>
+ <component name="editorHistoryManager">
+ <entry file="file://$PROJECT_DIR$/routes/index.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="1136">
+ <caret line="109" column="1" selection-start-line="109" selection-start-column="1" selection-end-line="109" selection-end-column="1" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/bin/www.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="195">
+ <caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/app.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="341">
+ <caret line="34" column="0" selection-start-line="34" selection-start-column="0" selection-end-line="34" selection-end-column="0" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </component>
+</project> \ No newline at end of file
diff --git a/app.js b/app.js
index e4d0843..ba7c014 100644
--- a/app.js
+++ b/app.js
@@ -32,51 +32,3 @@ app.use(express.static(__dirname));
app.use('/', routes);
module.exports = app;
-
-app.listen(3000, function() {
- console.log('listening on http://localhost:3000/');
-});
-
-//to fetch exams given a course code and populate the exams page
-app.get('/exams',function (req,res) {
- console.log(req.query.search);
- var courseName = req.query.search;
- courseName = sanitizer.escape(courseName);
- courseName = courseName.toUpperCase();
- console.log(courseName);
- var result = getExamsForCourseCode(courseName);
- console.log(result);
- res.write(JSON.stringify(result));
-});
-
-function getExamsForCourseCode(courseCode) {
- var minExamInfoArray = [];
- dbFile.get_all_exams(courseCode, function (exams) {
- if (exams.length == 0){
- console.log("Nothing was found");
- }
- else {
- //console.log(exams);
- //only pass over the information that is necessary for the exams page
- for (var i = 0; i<exams.length;i++){
- var minExamInfo = { courseCode:exams[i].course_code,
- year:exams[i].year,
- term:toProperCase(exams[i].term),
- instructors:exams[i].instructors,
- type:toProperCase(exams[i].type) + " Examination"
- };
- minExamInfoArray.push(minExamInfo);
- console.log(minExamInfo);
- }
- }
- });
-
- return minExamInfoArray;
-}
-
-
-/*Helper function to make sure the proper capital case is presented*/
-
-function toProperCase(string) {
- return string.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
-}
diff --git a/routes/index.js b/routes/index.js
index 457fbd1..1406143 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -28,9 +28,46 @@ router.get('/questions', function(req, res, next) {
});
/* Render/GET exam page */
-router.get('/exams/:id', function(req, res, next) {
+/* Render/GET exam page */
+//EXAMPLE EXPECTED DATA GIVEN BELOW:
+/*[ { courseCode: 'CSC240',
+ year: 2016,
+ term: 'Fall',
+ instructors: [ 'Faith Ellen', 'Tom F.' ],
+ type: 'Midterm Examination',
+ title: 'Thry of Computation' },
+ { courseCode: 'CSC240',
+ year: 2014,
+ term: 'Fall',
+ instructors: [ 'Faith Ellen', 'Tom F.' ],
+ type: 'Midterm Examination',
+ title: 'Thry of Computation' } ]
+ */
- res.render('exams', {query: req.params.id});
+router.get('/exams/:id', function(req, res, next) {
+ var minExamInfoArray = [];
+ dbFile.get_all_exams(req.params.id, function (exams) {
+ if (exams.length == 0){
+ console.log("Nothing was found");
+ }
+ else {
+ //console.log(exams);
+ //only pass over the information that is necessary for the exams page
+ for (var i = 0; i<exams.length;i++){
+ var minExamInfo = { courseCode:exams[i].course_code,
+ year:exams[i].year,
+ term:toProperCase(exams[i].term),
+ instructors:exams[i].instructors,
+ type:toProperCase(exams[i].type) + " Examination",
+ title:exams[i].title
+ };
+ //console.log(minExamInfo);
+ minExamInfoArray.push(minExamInfo);
+ }
+ }
+ console.log(minExamInfoArray);
+ res.render('exams', {query: minExamInfoArray});
+ });
});
/* Render/GET search (exam) page */
@@ -67,3 +104,7 @@ function getExamsForCourseCode(courseCode) {
}
module.exports = router;
+
+function toProperCase(string) {
+ return string.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
+} \ No newline at end of file