├── .gitignore ├── Config ├── .babelrc └── webpack.config.js ├── LICENSE ├── README.md ├── app ├── dev │ ├── RLMSAdmin │ │ ├── .gitkeep │ │ ├── ItemComponent.jsx │ │ ├── ListComponent.jsx │ │ └── RLMSBatch.jsx │ ├── RLMSCurriculum │ │ ├── index,jsx │ │ └── index.jsx │ ├── RLMSExam │ │ ├── .gitkeep │ │ └── examComponent.jsx │ ├── RLMSForum │ │ ├── .gitkeep │ │ └── Components │ │ │ ├── blog.jsx │ │ │ └── newComment.jsx │ ├── RLMSLogin │ │ ├── .gitkeep │ │ ├── RLMSLogin.jsx │ │ └── RLMSSignup.jsx │ ├── RLMSMain │ │ ├── .gitkeep │ │ ├── App.jsx │ │ ├── Footer.jsx │ │ ├── NavLink.jsx │ │ ├── digest.jsx │ │ ├── header.jsx │ │ ├── home.jsx │ │ └── index.jsx │ ├── RLMSTests │ │ └── test1.spec.jsx │ └── RLMSUser │ │ ├── .gitkeep │ │ └── profile.jsx └── public │ ├── Tests │ └── index.html │ ├── index.html │ └── style.css ├── json ├── Exam.json ├── Forum.json ├── Lesson.json └── User.json ├── package.json ├── routing ├── RLMSAdmin.js ├── RLMSCurriculum.js ├── RLMSExam.js ├── RLMSForum.js ├── RLMSGetUsers.js ├── RLMSPassport │ ├── init.js │ └── sRoutes.js └── RLMSTesting.js ├── server.js └── tools ├── mongoDataAccess.js └── mongoutil.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .idea 3 | -------------------------------------------------------------------------------- /Config/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015","react", "airbnb"] 3 | } -------------------------------------------------------------------------------- /Config/webpack.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Alex Redmon on 8/22/2016. 3 | */ 4 | var webpack = require('webpack'); 5 | var path= require('path'); 6 | const BUILD_DIR = path.resolve('app/public/JS/'); 7 | const APP_DIR = path.resolve('app/dev/'); 8 | var glob = require('glob'); 9 | var config ={ 10 | plugins:[ 11 | new webpack.optimize.OccurenceOrderPlugin(), 12 | new webpack.HotModuleReplacementPlugin(), 13 | new webpack.NoErrorsPlugin() 14 | // new webpack.optimize.CommonsChunkPlugin({ 15 | // name: 'common', 16 | // filename: 'rlmsCommon.js', 17 | // minChunks: 2 18 | // }) 19 | //new webpack.optimize.UglifyJsPlugin() 20 | ], 21 | entry:{ 22 | vendor:['webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000','react','react-dom'], 23 | rlmsForum:glob.sync(APP_DIR + '/RLMSForum/**/*.jsx'), 24 | rlmsAdmin:glob.sync(APP_DIR+ '/RLMSAdmin/**/*.jsx'), 25 | rlmsCurriculum:glob.sync(APP_DIR + '/RLMSCurriculum/**/*.jsx'), 26 | rlmsLogin:glob.sync(APP_DIR + '/RLMSLogin/**/*.jsx'), 27 | rlmsExam:glob.sync(APP_DIR + '/RLMSExams/**/*.jsx'), 28 | rlmsUser:glob.sync(APP_DIR + '/RLMSUsers/**/*.jsx'), 29 | rlmsMain:glob.sync(APP_DIR + '/RLMSMain/**/*.jsx'), 30 | rlmsTests:glob.sync(APP_DIR + '/RLMSTests/**/*.jsx') 31 | }, 32 | 33 | output:{ 34 | path:BUILD_DIR, 35 | filename:'[name].js' 36 | }, 37 | 38 | watch: true, 39 | module:{ 40 | loaders:[ 41 | { 42 | test : /\.jsx?/, 43 | include:APP_DIR, 44 | loader:'babel-loader', 45 | query:{ 46 | presets: ['es2015', 'react'] 47 | } 48 | } 49 | 50 | 51 | ] 52 | 53 | }, 54 | externals: { 55 | 'cheerio': 'window', 56 | 'react/lib/ExecutionEnvironment': true, 57 | 'react/lib/ReactContext': true, 58 | 'react/addons': true, 59 | } 60 | 61 | 62 | 63 | }; 64 | module.exports = config; 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RLMS 2 | This React application is an online classroom portal that incorporates various service features. It allows, students and trainers to interact within a course. The environment is complete with React, Webpack, Babel, Express, and Node. 3 | 4 | ###### menu 5 | - [Description](#rlms) 6 | - [Responsibilities](#responsibilities) 7 | - [Features & Services](#features-and-services) 8 | - [Technologies](#technologies) 9 | - [Installation](#installation) 10 | - [Developers](#developers) 11 | 12 | ### Responsibilities 13 | - Created a portal with React to provide features 14 | - Develop UI dashboard for each service using React framework and Bootstrap styles 15 | - Leveraged React Routing for navigating the application 16 | - Wrote React components using JSX syntax and ES6 Classes 17 | - Developed Express web services to provide JSON and React components 18 | - Incorporated security using Passport running on Node 19 | - Wrote data access modules to access Oracle using NodeDriver 20 | - Configured WebPack to run on Node, for rapid development 21 | - Created unit tests with Jasmine and Karma 22 | 23 | ### Features and Services 24 | ###### end-to-end service (developed by) 25 | - Forum ([Alex](#developers)) 26 | - User ([Cory](#developers)) 27 | - Login & Sign Up ([DeShon](#developers)) 28 | - Exam ([Isaiah](#developers)) 29 | - Curriculum ([Jordan](#developers)) 30 | - Admin ([Justin](#developers)) 31 | 32 | ### Technologies 33 | - React JS 34 | - Express JS 35 | - Node JS 36 | - Bootstrap 37 | - Passport 38 | - Jasmine & Karma 39 | - WebPack 40 | - Babel 41 | - MongoDriver 42 | - Mongo DB 43 | - NodeDriver for Oracle 44 | - HTML 45 | - ES6 46 | - CSS 47 | 48 | ### Installation 49 | ~~~~ 50 | npm install 51 | ~~~~ 52 | followed by 53 | ~~~~ 54 | npm start 55 | ~~~~ 56 | The webhost will run on localhost:3000 57 | 58 | ##### File Structure 59 | Store your components in their respected folders under app/dev and they we automatically transpiled into their respected bundle. 60 | 61 | ### Developers 62 | - Alex Redmon 63 | - Cory Davenport 64 | - DeShon Thomas-Wright 65 | - Isaias Cervantes 66 | - Jordan Clarke 67 | - Justin Atkinson 68 | -------------------------------------------------------------------------------- /app/dev/RLMSAdmin/.gitkeep: -------------------------------------------------------------------------------- 1 | Structure for components 2 | -------------------------------------------------------------------------------- /app/dev/RLMSAdmin/ItemComponent.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | class ItemComponent extends React.Component { 4 | 5 | constructor() { 6 | super(); 7 | 8 | } 9 | 10 | onCheckOrUncheck(event){ 11 | this.props.clickFunction(this.props.user); 12 | //console.log(this.props.user.username); 13 | } 14 | 15 | onRadioTrainerSelect(event) { 16 | this.props.clickFunction(this.props.user); 17 | //console.log(this.props.user.username); 18 | } 19 | 20 | onRadioBatchSelect(event) { 21 | this.props.clickFunction(this.props.user); 22 | //console.log(this.props.user.batch.name); 23 | } 24 | 25 | render() { 26 | console.log(this.props.user.batch); 27 | if(this.props.listType === "student" && (this.props.user.is_active === true || this.props.user.is_active !== false ) && this.props.user.is_admin !== true && this.props.user.username !== null && this.props.user.batch === null) { 28 | return ( 29 |
  • 30 | 31 | {this.props.key} {this.props.user.f_name} {this.props.user.l_name} ({this.props.user.username}) 32 |
  • 33 | ); 34 | } else { 35 | if (this.props.listType === "trainer" && (this.props.user.is_active === true || this.props.user.is_active !== false ) && this.props.user.is_admin === true && this.props.user.username !== null && !(this.props.user.batch)) { 36 | return ( 37 |
  • 38 | 39 | {this.props.key} {this.props.user.f_name} {this.props.user.l_name} ({this.props.user.username}) 40 |
  • 41 | ); 42 | } else { 43 | if (this.props.listType === "batch" && this.props.user.batch && !(this.props.user.username)) { 44 | return ( 45 |
  • 46 | 47 | {this.props.key} {this.props.user.batch.batchName} 48 |
  • 49 | ); 50 | } else { 51 | return null; 52 | } 53 | } 54 | } 55 | } 56 | } 57 | 58 | export default ItemComponent; 59 | -------------------------------------------------------------------------------- /app/dev/RLMSAdmin/ListComponent.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ItemComponent from './ItemComponent.jsx'; 3 | 4 | class ListComponent extends React.Component { 5 | 6 | onListSelectChange(event) { 7 | this.props.clickFunction(event); 8 | //console.log(event); 9 | } 10 | 11 | render() { 12 | // get request for Users 13 | // pass parameter? student / trainer / batch 14 | let arr = this.props.users; 15 | let arrItem = arr.map((item, index) => { return }); 16 | return ( 17 |
      18 | {arrItem} 19 |
    20 | ); 21 | } 22 | } 23 | 24 | export default ListComponent; 25 | -------------------------------------------------------------------------------- /app/dev/RLMSAdmin/RLMSBatch.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import Request from 'superagent'; 4 | import ListComponent from './ListComponent.jsx'; 5 | 6 | export default class BatchManagement extends React.Component { 7 | constructor(){ 8 | super(); 9 | this.state = { 10 | userBatchData:[], 11 | batchHasAdmin:false, 12 | batchIsSelected:false, 13 | trainerData:null, 14 | batchData:null 15 | }; 16 | } 17 | 18 | componentWillMount() { 19 | var url = 'http://localhost:3000/admin/getAllUsers'; 20 | 21 | this.serverRequest = Request.get(url).end(function(err, result) { 22 | this.setState({ 23 | data:JSON.parse(result.text) 24 | }); 25 | }.bind(this)); 26 | } 27 | 28 | componentWillUnmount() { 29 | this.serverRequest.abort(); 30 | } 31 | 32 | updateBatchArray(event) { 33 | var exists = false; 34 | var self = this; 35 | 36 | var index = this.state.userBatchData.indexOf(event); 37 | var forIndex = 0; 38 | var dup = -1; 39 | 40 | if(event.username) { 41 | if(event.is_admin) { 42 | this.state.trainerData = event; 43 | this.state.batchHasAdmin = true; 44 | } else { 45 | if(index >= 0) { 46 | this.state.userBatchData.splice(index, 1); 47 | } else { 48 | this.state.userBatchData.push(event); 49 | } 50 | } 51 | } else { 52 | this.state.batchData = event; 53 | this.state.batchIsSelected = true; 54 | } 55 | } 56 | 57 | // var redirect = () => { 58 | // this.context.router.push('/home/forum'); 59 | // } 60 | 61 | postToDB() { 62 | var url = "/admin/updateBatchAndUsers"; 63 | var json = JSON.stringify(this.state.userBatchData); 64 | //console.log(json); 65 | 66 | Request.post(url).send(this.state.userBatchData).end(function(err, res) { 67 | if(err) { 68 | console.log('good'); 69 | } else { 70 | console.log('error'); 71 | } 72 | }); 73 | 74 | this.forceUpdate(); 75 | 76 | } 77 | 78 | compileDataForPost() { 79 | if(this.state.trainerData && this.state.batchData){ 80 | document.getElementById("create-batch-btn").disabled = true; 81 | 82 | var newState = this.state; 83 | 84 | this.state.userBatchData.push(this.state.trainerData); 85 | this.state.userBatchData.forEach( function(item) { 86 | item.batch = newState.batchData.batch; 87 | }); 88 | // 89 | // var json = JSON.stringify(this.state.userBatchData); 90 | // console.log(json); 91 | 92 | this.postToDB(); 93 | } 94 | } 95 | 96 | render() { 97 | if(this.state.data) { 98 | return ( 99 |
    100 |
    101 |

    Batch Assignment

    102 |
    103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |
    110 |

    Available Students

    111 |
    112 |
    Filter Students:
    113 | 114 |
    115 |
    116 | 117 |
    118 |
    119 |
    120 |
    121 |
    122 |

    Available Trainers

    123 |
    124 |
    Filter Trainers:
    125 | 126 |
    127 |
    128 | 129 |
    130 |
    131 |
    132 |
    133 |
    134 |
    135 | 147 |
    148 |
    149 |
    150 |
    151 |
    152 | 154 |
    155 | {/*
    */} 156 | {/**/} 157 | {/*
    */} 158 |
    159 | ) 160 | } else { 161 | return ( 162 |
    Here is some content.
    163 | ); 164 | } 165 | } 166 | } 167 | // 168 | // BatchManagement.contextTypes = { 169 | // router: React.PropTypes.object.isRequired 170 | // }; 171 | 172 | //render(, document.getElementById('app')); 173 | //export default BatchManagement 174 | -------------------------------------------------------------------------------- /app/dev/RLMSCurriculum/index,jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import Request from 'superagent'; 4 | //import OtherApp from './app.jsx'; 5 | //var get = require('./getLessons.js'); 6 | //import OtherApp from '../app/app.jsx'; 7 | //var ReactTestUtils = require('react-addons-test-utils'); 8 | 9 | //require('react/addons').addons.TestUtils 10 | var data = { 11 | "curriculum": { 12 | "id":0, 13 | "name":".NET", 14 | "lesson":[ 15 | { 16 | "id":1, 17 | "topic":"Core", 18 | "week":1, 19 | "frameworks":[{"id":1, "title":".Net", "keywords":"class, property, polymorphism"}] 20 | }, 21 | { 22 | "id":2, 23 | "topic":"Data", 24 | "week":2, 25 | "frameworks": [{"id":3, "title":"SQL", "keywords":"insert, table, stored procedure"}, 26 | {"id":4, "title":"Entity", "keywords":"ORM, save changes"}] 27 | }, 28 | { 29 | "id":5, 30 | "topic":"Angular", 31 | "week":3, 32 | "frameworks": [{"id":7, "title":"Angular", "keywords":"ng-repeat, directive"}] 33 | } 34 | ] 35 | } 36 | 37 | } 38 | var Curriculum = React.createClass({ 39 | getInitialState () { 40 | return { 41 | curriculum: '', 42 | Lesson: '' 43 | }; 44 | }, 45 | componentDidMount() { 46 | get(1,1); 47 | /*this.serverRequest = $.get("./syllabus.json", function (result) { 48 | //var lastGist = result[0]; 49 | this.setState({ 50 | curriculum: result.curriculum, 51 | Lesson: result.curriculum.lesson 52 | }); 53 | }.bind(this));*/ 54 | /*this.serverRequest= Request.get("./syllabus.json").end(function(err,res){ 55 | this.setState({ 56 | curriculum:res.curriculum, 57 | Lesson:res.curriculum.lesson 58 | }); 59 | }.bind(this));*/ 60 | this.setState({ 61 | curriculum:data.curriculum, 62 | Lesson:data.curriculum.lesson, 63 | test:100 64 | }) 65 | }, 66 | componentWillUnmount: function() { 67 | this.serverRequest.abort(); 68 | }, 69 | render () { 70 | if(this.state.Lesson[0] == null || this.state.Lesson[0] == undefined){ 71 | return

    72 | } 73 | //console.log(this.state.Lesson); 74 | return (
    75 |

    {this.state.curriculum.name}

    76 | {this.state.Lesson.map(function(name, index){ 77 | var s = JSON.stringify(name.frameworks); 78 | return
    79 |

    Week {name.week} {name.topic}

    80 | 81 |
    82 |
    ; 83 | })} 84 |
    ); 85 | } 86 | }); 87 | 88 | var Lesson = React.createClass({ 89 | 90 | render () { 91 | console.log(this.props.framework); 92 | var s = JSON.parse(this.props.framework); 93 | return
    94 | {s.map(function(name, index){ 95 | return

    Framework: {name.title}

    Keywords: {name.keywords}

    ; 96 | })} 97 |
    ; 98 | } 99 | }); 100 | 101 | var T = React.createClass({ 102 | render(){ 103 | return
    some text
    104 | } 105 | }); 106 | 107 | render(, document.getElementById('myApp')); 108 | //render(, document.getElementById('otherApp')); 109 | 110 | 111 | if (module.hot) { 112 | module.hot.accept(); 113 | } 114 | 115 | export default Curriculum 116 | -------------------------------------------------------------------------------- /app/dev/RLMSCurriculum/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import Request from 'superagent'; 4 | var res; 5 | 6 | var Curriculum = React.createClass({ 7 | getInitialState () { 8 | return {}; 9 | }, 10 | componentWillMount() { 11 | if(sessionStorage.getItem('batchName')){ 12 | console.log('made request'); 13 | //pull batchName from storage 14 | var b = sessionStorage.getItem('batchName').split('-')[2]; 15 | if(b=="NET"){ 16 | b=".NET"; 17 | } 18 | //request lesson for batch 19 | var url = 'http://localhost:3000/getLesson/' + b; 20 | this.serverRequest = Request.get(url).end(function(err,result){ 21 | this.setState({ 22 | data:JSON.parse(result.text) 23 | }); 24 | }.bind(this)); 25 | } 26 | }, 27 | render () { 28 | //if data not initialized, assume not assigned to batch 29 | if(this.state.data == null || this.state.data == undefined){ 30 | return( 31 |
    32 |

    You are not assigned to a batch!

    33 |

    If you're recieving this message in error, please contact your trainer.

    34 |
    35 | ) 36 | } 37 | //else render Lesson 38 | else if(sessionStorage.getItem('batchName')){ 39 | console.log('made it here'); 40 | var hstyle = {'text-align':'center'}; 41 | return( 42 |
    43 |

    {this.state.data[0].curriculum}

    44 | {this.state.data.map(function(name, index){ 45 | var s = JSON.stringify(name.topic) 46 | return
    47 |

    Week {name.week}: {name.lessonName}

    48 | 49 |
    50 |
    ; 51 | })} 52 |
    53 | ); 54 | } 55 | else{ 56 | return( 57 |
    58 |

    You are not assigned to a batch!

    59 |

    If you're recieving this message in error, please contact your trainer.

    60 |
    61 | ) 62 | } 63 | } 64 | }); 65 | 66 | 67 | 68 | var Lesson = React.createClass({ 69 | render () { 70 | //render table with lessons 71 | var s = JSON.parse(this.props.framework); 72 | return 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | {s.map(function(name, index){ 81 | return ; 82 | })} 83 | 84 |
    FrameworkKeywords
    {name.title} {name.keywords}
    ; 85 | } 86 | }); 87 | 88 | 89 | if (module.hot) { 90 | module.hot.accept(); 91 | } 92 | 93 | export default Curriculum 94 | -------------------------------------------------------------------------------- /app/dev/RLMSExam/.gitkeep: -------------------------------------------------------------------------------- 1 | Structure for components 2 | -------------------------------------------------------------------------------- /app/dev/RLMSExam/examComponent.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button, Modal, ProgressBar } from 'react-bootstrap'; 3 | import Request from 'superagent'; 4 | 5 | //local vars for testing code 6 | var res; 7 | 8 | var Exam = React.createClass({ 9 | /*properties 10 | * input= Holding entire test 11 | */ 12 | 13 | getInitialState: function() { 14 | return {totalscore : 0, testSubmitted: false, q:"", loadstatus:0, showModal:false}; 15 | 16 | }, 17 | handleChange: function(result) { 18 | this.setState({totalscore: result.totalscore, testSubmitted: true, showModal:true}); 19 | }, 20 | 21 | //api call 22 | getExam(){ 23 | this.setState({loadstatus:30}); 24 | this.setState({loadstatus:80}); 25 | var url = 'http://localhost:3000/getExam'; 26 | Request.get(url).then(result =>{ 27 | 28 | res = JSON.parse(result.text); 29 | var batch = sessionStorage.getItem('batchName'); 30 | 31 | //depending on batch get corresponding test 32 | //[0] = C# 33 | //[1] = Java 34 | if (batch.includes("NET")) { 35 | this.setState({q: res[0]});} 36 | if(batch.includes("Java")){ 37 | this.setState({q: res[1]});} 38 | 39 | }); 40 | }, 41 | 42 | close(){ 43 | //submit to score to DB 44 | var tpts = 0; 45 | this.state.q.questions.map(question => tpts += question.weight); 46 | var grade = Math.round(this.state.totalscore*100/tpts); 47 | let postUrl = 'http://localhost:3000/postExam'; 48 | var usergrade = { 49 | username:sessionStorage.getItem("username"), 50 | grade:grade 51 | }; 52 | 53 | console.log(usergrade); 54 | Request.post(postUrl).send(usergrade).end(function(err,res){ 55 | if(err){console.log(err)} 56 | }); 57 | 58 | this.setState({showModal:false}); 59 | tpts=0; 60 | }, 61 | 62 | componentWillMount(){ 63 | this.getExam() 64 | }, 65 | 66 | render: function(){ 67 | var totalPoints=0; 68 | if(this.state.q){ 69 | this.state.q.questions.map(question => totalPoints += question.weight); 70 | return( 71 |
    72 |

    Exam for {this.state.q.topic}

    73 |
    74 | {/**/} 75 | 76 | 77 | 78 | 81 | 82 | 83 |
    79 | 80 |
    84 | 85 | 86 | 87 | Score Summary 88 | 89 | 90 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
    99 | ); 100 | } 101 | else{ 102 | return(); 103 | } 104 | 105 | } 106 | }); 107 | 108 | var QuestionList = React.createClass({ 109 | /*properties 110 | /questions = list of questions 111 | /onSubmitted = bool if test has been submitted 112 | */ 113 | getInitialState: function() { 114 | return {totalscore : 0}; 115 | }, 116 | handleChange: function(score) { 117 | this.setState({totalscore: this.state.totalscore + score}); 118 | }, 119 | handleSubmitted: function(event) { 120 | var result = {totalscore: this.state.totalscore}; 121 | this.props.onSubmitted( result ); 122 | clearInterval(this.interval); 123 | }, 124 | 125 | 126 | render: function(){ 127 | var questionAnswers = this.props.questions.map(function(question,i){ 128 | return( 129 | 130 | 133 | ); 134 | }, this); 135 | return( 136 |
    137 | 138 | {questionAnswers}
    139 |
    141 |
    142 | 143 | ); 144 | } 145 | }); 146 | 147 | var Question = React.createClass({ 148 | /*properties 149 | /question = question 150 | /number = number of question in list 151 | /options = array of answers for the question 152 | /answer = correct answer 153 | /weight = weight of questions 154 | /onAnswered = event in QuestionListClass that passes in score 155 | */ 156 | 157 | getInitialState: function() { 158 | return { 159 | correctAnswerRecorded: false, 160 | negativeAnswerRecorded: false, 161 | tempAnswer:"", 162 | glyph:"glyphicon glyphicon-remove", 163 | btn:"btn btn-danger btn-xs", 164 | alert:"alert alert-danger" 165 | }; 166 | }, 167 | 168 | //logic for keeping score of question 169 | handleChange: function(event) { 170 | let score = 0; 171 | this.state.tempAnswer = event.target.value; 172 | this.state.glyph="glyphicon glyphicon-ok"; 173 | this.state.btn="btn btn-success btn-xs pull-right"; 174 | this.state.alert="alert alert-info"; 175 | 176 | //check if selected answer is correct 177 | if( event.target.value == this.props.answer) { 178 | //first response 179 | if( this.state.correctAnswerRecorded === false ) { 180 | //keep score the same 181 | score = this.props.weight; 182 | } 183 | 184 | this.state.correctAnswerRecorded = true; 185 | this.state.negativeAnswerRecorded = false; 186 | } else { 187 | //deviate from correct 188 | if( this.state.correctAnswerRecorded === true ) { 189 | score = -this.props.weight; 190 | } 191 | this.state.negativeAnswerRecorded = true; 192 | this.state.correctAnswerRecorded = false; 193 | } 194 | //pass in score to scoreboard exam 195 | this.props.onAnswered(score); 196 | }, 197 | render: function(){ 198 | //set input element name 199 | var qname = "option" + this.props.number; 200 | //return radio buttons with answers 201 | var qoptions = this.props.options.map(function(option,i){ 202 | return ( 203 | //display answers of question 204 |
    206 | ); 207 | }, this); 208 | return( 209 |
    210 | {/*display questions*/} 211 | 212 |
    Question {this.props.number}: {this.props.question}Points: {this.props.weight}
    213 | {/*display answers*/} 214 |
    {qoptions}
    215 |
    216 |
    217 |

    Answer saved: {this.state.tempAnswer} 218 |

    221 |
    222 | 223 |
    224 | ); 225 | } 226 | }); 227 | 228 | var Report = React.createClass({ 229 | /*properties 230 | /score = summation of weight 231 | /testSubmitted = bool if test submitted 232 | /percentage = score/total points points 233 | /tpoints = total points possible 234 | */ 235 | 236 | render: function(){ 237 | var status = "Test not submitted!"; 238 | if( this.props.testSubmitted == true ) { 239 | if( this.props.percentage < 70 ) { 240 | status = "Sorry, you did not pass the test." 241 | } else { 242 | status = "Congratulations!! You passed the test."; 243 | } 244 | } 245 | return( 246 |
    247 |
    Score: {this.props.score} out of {this.props.tpoints}
    248 |
    Percentage: {this.props.percentage} %
    249 |
    Status: {status}
    250 |
    251 | ); 252 | } 253 | }); 254 | 255 | export default Exam; 256 | -------------------------------------------------------------------------------- /app/dev/RLMSForum/.gitkeep: -------------------------------------------------------------------------------- 1 | Structure for components 2 | -------------------------------------------------------------------------------- /app/dev/RLMSForum/Components/blog.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import Request from 'superagent'; 4 | import NewComment from './newComment.jsx'; 5 | 6 | var posts=[]; 7 | export default class Blog extends React.Component{ 8 | constructor() 9 | { 10 | super(); 11 | this.state={}; 12 | 13 | } 14 | doStuff(stuff){ 15 | 16 | var posts = this.state.data[0].posts; 17 | var now = new Date(); 18 | var min; 19 | if(now.getMinutes() <10) 20 | { 21 | 22 | min = "0" + now.getMinutes(); 23 | }else{min =now.getMinutes()} 24 | var newPost = { 25 | username: sessionStorage.getItem('username'), 26 | comment: stuff, 27 | timestamp: now.getDay() + "/" +now.getMonth()+ '/' + now.getFullYear() + " " + now.getHours() + ":" + min 28 | }; 29 | if(posts) 30 | { 31 | posts.unshift(newPost); 32 | this.state.data[0].posts = posts; 33 | } 34 | else{ 35 | var tempArray =[]; 36 | tempArray.push(newPost); 37 | var x = this.state.data[0].posts = tempArray; 38 | } 39 | 40 | Request.post('http://localhost:3000/postForum').send(this.state.data[0]).end(function(err,res){ 41 | if(err){console.log(err)} 42 | 43 | }); 44 | this.forceUpdate(); 45 | 46 | }getForum(batchname) 47 | { 48 | 49 | var url = 'http://localhost:3000/getForum/'+batchname; 50 | console.log(url); 51 | Request.get(url).then(result =>{ 52 | this.setState({data: JSON.parse(result.text)}); 53 | }); 54 | 55 | 56 | } 57 | getUser(username){ 58 | let url = "http://localhost:3000/getUser/" + username; 59 | console.log(url); 60 | let stuff = Request.get(url).then((result)=>{ 61 | this.setState({batch:JSON.parse(result.text)[0].batch}); 62 | 63 | sessionStorage.setItem('batchName',this.state.batch.batchName); 64 | this.getForum(this.state.batch.batchName); 65 | }) 66 | 67 | 68 | } 69 | componentWillMount(){ 70 | 71 | if(!sessionStorage.getItem("username")){ 72 | const {query} = this.props.location; 73 | const {id} = query; 74 | console.log(id); 75 | sessionStorage.setItem("username",id); 76 | } 77 | this.getUser(sessionStorage.getItem("username")); 78 | 79 | 80 | } 81 | 82 | componentWillUnmount(){ 83 | 84 | } 85 | render(){ 86 | 87 | if(this.state.data){ 88 | 89 | posts = this.state.data[0].posts; 90 | let blogs = this.state.data.map((item,i) => 91 | { 92 | //console.log(item); 93 | if(posts) { 94 | this.comments = item.posts.map((stuff, k) => { 95 | return 96 | }); 97 | }else { 98 | console.log(item); 99 | } 100 | return( 101 |
    102 | 103 |
    104 |

    {item.batchName}

    105 |
    106 | 107 |
    108 |

    {item.description}

    109 | 110 |
    111 |
    112 | {this.comments} 113 |
    114 | 115 | 116 |
    117 | ) 118 | }); 119 | return( 120 |
    121 | {blogs} 122 |
    123 | ) 124 | }else{ 125 | return( 126 |
    127 |

    You are not assigned to a batch!

    128 |

    If you're recieving this message in error, please contact your trainer.

    129 |
    130 | ) 131 | } 132 | } 133 | } 134 | const Comment = (props) => { 135 | 136 | return ( 137 |
    138 |
    139 | 140 |

    {props.data.username}

    141 |

    {props.data.timestamp}

    142 |
    143 |
    144 |

    {props.data.comment}

    145 |
    146 | ) 147 | 148 | } 149 | -------------------------------------------------------------------------------- /app/dev/RLMSForum/Components/newComment.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | 4 | export default class NewComment extends React.Component{ 5 | 6 | constructor(){ 7 | 8 | super(); 9 | this.state={value:"stuff"}; 10 | this.OnChangeEvent.bind(this); 11 | } 12 | 13 | OnChangeEvent(e){ 14 | 15 | this.setState({value:e.target.value}); 16 | 17 | } 18 | onClick(e){ 19 | this.props.doStuff(this.state.value) 20 | } 21 | 22 | render(){ 23 | 24 | return( 25 |
    26 | 27 | 28 |
    29 | ) 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/dev/RLMSLogin/.gitkeep: -------------------------------------------------------------------------------- 1 | Structure for components 2 | -------------------------------------------------------------------------------- /app/dev/RLMSLogin/RLMSLogin.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import Request from 'superagent'; 4 | 5 | class LoginApp extends React.createClass({ 6 | contextTypes: { 7 | router: React.PropTypes.object.isRequired 8 | }, 9 | reg: function(){ 10 | this.context.router.push('/signUp'); 11 | }, 12 | btnAlign:{ 13 | marginTop: '1em' 14 | }, 15 | 16 | componentWillMount(){ 17 | sessionStorage.clear(); 18 | }, 19 | render(){ 20 | return ( 21 |
    22 | 23 |
    24 | ); 25 | } 26 | }){} 27 | 28 | const LoginForm = (props) =>{ 29 | return ( 30 |
    31 | 32 |

    Login

    33 | 34 |
    35 | 36 |
    37 | 38 |
    39 | 40 | 41 |
    42 |
    43 |
    44 | ); 45 | } 46 | 47 | export default LoginApp; 48 | 49 | if(module.hot){ 50 | module.hot.accept(); 51 | } -------------------------------------------------------------------------------- /app/dev/RLMSLogin/RLMSSignup.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import Request from 'superagent'; 4 | 5 | class SignUpApp extends React.createClass({ 6 | contextTypes: { 7 | router: React.PropTypes.object.isRequired 8 | }, 9 | ret: function(){ 10 | this.context.router.push('/login'); 11 | }, 12 | btnAlign:{ 13 | marginTop: '1em' 14 | }, 15 | 16 | componentWillMount(){ 17 | sessionStorage.clear(); 18 | }, 19 | render(){ 20 | return 21 | } 22 | 23 | }){} 24 | 25 | const RegisterForm = (props) =>{ 26 | return ( 27 |
    28 | 29 |

    Sign Up

    30 | 31 |
    32 | 33 |
    34 | 35 |
    36 | 37 |
    38 | 39 |
    40 | 41 |
    42 | 43 | 44 |
    45 |
    46 |
    47 | ) 48 | } 49 | 50 | export default SignUpApp; 51 | 52 | if(module.hot){ 53 | module.hot.accept(); 54 | } -------------------------------------------------------------------------------- /app/dev/RLMSMain/.gitkeep: -------------------------------------------------------------------------------- 1 | Structure for components 2 | -------------------------------------------------------------------------------- /app/dev/RLMSMain/App.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Header from './header.jsx' 3 | import Footer from "./footer.jsx"; 4 | 5 | export default React.createClass({ 6 | render() { 7 | return ( 8 |
    9 |
    10 | {this.props.children} 11 |
    12 |
    13 | ) 14 | } 15 | }) -------------------------------------------------------------------------------- /app/dev/RLMSMain/Footer.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import { Navbar, Nav, NavItem } from 'react-bootstrap' 4 | 5 | class Footer extends React.Component{ 6 | render (){ 7 | return ( 8 | 9 | Copyright © 2016 RLMS 10 | 11 | ) 12 | } 13 | } 14 | 15 | export default Footer; 16 | -------------------------------------------------------------------------------- /app/dev/RLMSMain/NavLink.jsx: -------------------------------------------------------------------------------- 1 | // modules/NavLink.js 2 | import React from 'react' 3 | import { Link } from 'react-router' 4 | 5 | export default React.createClass({ 6 | render() { 7 | return 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /app/dev/RLMSMain/digest.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Request from 'superagent'; 3 | 4 | class ApiEater extends React.Component{ 5 | constructor(){ 6 | super(); 7 | this.state = {}; 8 | } 9 | componentWillMount(){ 10 | var url="http://localhost:3000/api/getBasic"; 11 | Request.get(url).then(result =>{ 12 | var json = JSON.parse(result.text); 13 | this.setState({data:json}); 14 | }) 15 | } 16 | render(){ 17 | if(this.state.data){ 18 | var logo={ 19 | height:'20px', 20 | width:'20px' 21 | }; 22 | return ( 23 |
    24 |
    {this.state.data[0].FirstName} {this.state.data[0].LastName}  
    25 |
    26 | ) 27 | } 28 | else{ 29 | return

    data could not load

    30 | } 31 | }; 32 | } 33 | export default ApiEater; -------------------------------------------------------------------------------- /app/dev/RLMSMain/header.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { render } from 'react-dom' 3 | import { Navbar, Nav, NavItem } from 'react-bootstrap' 4 | import NavLink from './NavLink.jsx' 5 | import User from './digest.jsx'; 6 | 7 | export default class Header extends React.Component{ 8 | render(){ 9 | var name = sessionStorage.getItem("username"); 10 | var leftNav ={ 11 | paddingTop: '28px' 12 | } 13 | var logo={ 14 | height:'20px', 15 | width:'20px' 16 | }; 17 | const userNav={ 18 | color:"white", 19 | textDecoration :'none' 20 | 21 | } 22 | return ( 23 | 24 | 25 | React LMS 26 | 27 | 28 | 29 | ) 30 | } 31 | } -------------------------------------------------------------------------------- /app/dev/RLMSMain/home.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import NavLink from './NavLink.jsx' 3 | export default class Home extends React.Component{ 4 | render() { 5 | const left = { 6 | paddingTop: '0px', 7 | position: 'fixed', 8 | textAlign: 'center', 9 | float: 'left', 10 | width: '15%', 11 | height: '1080px', 12 | }; 13 | const right = { 14 | marginTop: '90px', 15 | float: 'right', 16 | width: '75%', 17 | paddingBottom: '40px' 18 | 19 | }; 20 | const containerFix = { 21 | marginTop: '-20px' 22 | } 23 | const nav = { 24 | paddingTop: '90px', 25 | paddingLeft: '0px', 26 | listStyleType: 'none' 27 | 28 | } 29 | return ( 30 | /////////////////////////////////////// 31 | //for new routes 32 | //Button Text 33 | //add to the list below 34 | //////////////////////////////////////// 35 |
    36 |
    37 |
    38 | 39 | Forum 40 |
    41 | Exam 42 |
    43 | Profile 44 |
    45 | Syllabus 46 | Admin - Batch 47 |
    48 |
    49 |
    50 |

    51 | 52 |
    53 |
    54 | Logout 55 |
    56 |
    57 |
    58 | {this.props.children} 59 |
    60 |
    61 | ) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/dev/RLMSMain/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { render } from 'react-dom' 3 | import { Router, Route, hashHistory, IndexRoute } from 'react-router' 4 | import App from './App.jsx' 5 | import User from './digest.jsx' 6 | import Home from './home.jsx' 7 | 8 | import Profile from '../RLMSUser/profile.jsx'; 9 | 10 | import Forum from '../RLMSForum/Components/Blog.jsx' 11 | 12 | import Login from '../RLMSLogin/RLMSLogin.jsx' 13 | import Signup from '../RLMSLogin/RLMSSignup.jsx'; 14 | import Exam from '../RLMSExam/examComponent.jsx'; 15 | import Admin from '../RLMSAdmin/RLMSBatch.jsx'; 16 | 17 | import Curriculum from '../RLMSCurriculum/index.jsx' 18 | 19 | 20 | render(( 21 | ////////////////////////////// 22 | //for new route 23 | // 24 | //add to list below 25 | ////////////////////////////// 26 | //for a call from function initialize 27 | //contextTypes: { 28 | //router: React.PropTypes.object.isRequired 29 | //}, 30 | //and then in the function call 31 | //function example 32 | //test : function(){ 33 | //this.context.router.push('/#/home'); 34 | //}, 35 | ////////////////////////////// 36 | //onClick={test} 37 | //////////////////////////////// 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | ),document.getElementById('app')) 55 | -------------------------------------------------------------------------------- /app/dev/RLMSTests/test1.spec.jsx: -------------------------------------------------------------------------------- 1 | 2 | import React from 'react'; 3 | import TestUtils from 'react-addons-test-utils'; 4 | 5 | import { mount, shallow } from 'enzyme'; 6 | import Curriculum from '../RLMSCurriculum/index.jsx' 7 | import jasmine from 'jasmine-ajax' 8 | 9 | describe('make sure header appears', function () { 10 | 11 | it('should have lessons', ()=>{ 12 | const wrapper = mount(); 13 | expect(wrapper.find('div').first().childAt(0).html()).toEqual('

    You are not assigned to a batch!

    '); 14 | }); 15 | 16 | }); 17 | 18 | 19 | describe('test ajax calls', function () { 20 | 21 | beforeEach(function() { 22 | const wrapper = mount(); 23 | 24 | sessionStorage.setItem('batchName','0-0-Java'); 25 | 26 | }); 27 | 28 | it('should render syllabus correctly', ()=>{ 29 | 30 | setTimeout(function(){ 31 | expect(wrapper.find('h3').length).toEqual(1); 32 | expect(wrapper.find('h3').text()).toEqual('Week 1: Core'); 33 | 34 | done(); 35 | }, 5000); 36 | expect(wrapper.find('h1').length).toEqual(1); 37 | 38 | }); 39 | 40 | }); 41 | export default Tests 42 | -------------------------------------------------------------------------------- /app/dev/RLMSUser/.gitkeep: -------------------------------------------------------------------------------- 1 | Structure for components 2 | -------------------------------------------------------------------------------- /app/dev/RLMSUser/profile.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-dom'; 3 | import Request from 'superagent'; 4 | 5 | class Profile extends React.Component{ 6 | constructor(){ 7 | super(); 8 | this.state = {}; 9 | this.UpdateInfo = this.UpdateInfo.bind(this); 10 | this.ChangePassword = this.ChangePassword.bind(this); 11 | } 12 | UpdateInfo(event) 13 | { 14 | var url = "http://localhost:3000/updateUserProfile"; 15 | event.preventDefault(); 16 | var a = document.getElementById("fName").value; 17 | var b = document.getElementById("lName").value; 18 | var c = document.getElementById("userName").value; 19 | var d = document.getElementById("email").value; 20 | var updateUser = this.state.data[0]; 21 | if(a){ 22 | updateUser.f_name = a; 23 | } 24 | if(b){ 25 | updateUser.l_name = b; 26 | } 27 | if(c){ 28 | updateUser.username = c; 29 | } 30 | if(d){ 31 | updateUser.email = d; 32 | } 33 | 34 | 35 | Request.post(url).send(updateUser).end(()=>{ 36 | 37 | }) 38 | alert("Update Complete"); 39 | 40 | } 41 | ChangePassword(event) { 42 | var url = "http://localhost:3000/updateUserProfile"; 43 | event.preventDefault(); 44 | var a = document.getElementById("password").value; 45 | var b = document.getElementById("password2").value; 46 | if (a===b && a != null) { 47 | var tempUser = this.state.data[0]; 48 | tempUser.password = a; 49 | Request.post(url).send(tempUser).end(()=>{ 50 | 51 | }) 52 | document.getElementById("password").value = ""; 53 | document.getElementById("password2").value = ""; 54 | alert("Password Changed"); 55 | }else{ 56 | alert("passwords do not match. Please try again."); 57 | } 58 | } 59 | componentWillMount(){ 60 | var name = sessionStorage.getItem("username"); 61 | var url="http://localhost:3000/getUser/"+name; 62 | Request.get(url).then(result =>{ 63 | var json = JSON.parse(result.text); 64 | this.setState({data:json}); 65 | console.log(this.state.data[0]); 66 | }) 67 | var url2="http://localhost:3000/getLesson"; 68 | Request.get(url2).then(result2 =>{ 69 | var json2 = JSON.parse(result2.text); 70 | this.setState({batch:json2}); 71 | console.log(this.state.batch[0]); 72 | }) 73 | } 74 | 75 | render (){ 76 | const center = { 77 | textAlign:'center' 78 | } 79 | const hr = { 80 | borderTop: '1px solid grey' 81 | } 82 | const left = { 83 | float:'left' 84 | } 85 | const newBtn ={ 86 | width: '140px' 87 | } 88 | if(this.state.data && this.state.batch){ 89 | var curriculum = this.state.data[0].batch.batchName.split("-")[2]; 90 | if(curriculum === "NET"){ 91 | curriculum = ".NET"; 92 | } 93 | return ( 94 |
    95 |
    96 | 97 |
    98 |
    99 |

    100 |
    101 | 102 |
    103 | 104 | 105 |
    106 | 107 |
    108 | 109 | 110 | 111 |
    112 | 113 |
    114 |
    115 | 116 | 117 |
    118 | 119 | 120 |
    121 | 122 |
    123 | 124 | 125 |
    126 | 127 |
    128 |
    129 | 130 | 131 |
    132 | 133 |
    134 |
    135 |
    136 |
    137 |
    138 |
    139 |
    140 | 141 | 142 |
    143 |
    144 |
    145 |
    146 | 147 |
    148 | 149 | 150 |
    151 | 152 |
    153 | 154 |
    155 | 156 |
    157 |
    158 |
    159 | 160 |
    161 |
    162 |
    163 |
    164 |
    165 |
    166 |
    167 | 168 |
    169 |
    170 |

    171 |
    172 |
    173 | 174 |
    175 |
    176 | 177 |
    178 |

    179 |
    180 |
    181 | ) 182 | } 183 | else if(this.state.data && !this.state.batch){ 184 | return ( 185 |
    186 |
    187 | 188 |
    189 |
    190 |

    191 |
    192 | 193 |
    194 | 195 | 196 |
    197 | 198 |
    199 | 200 | 201 | 202 |
    203 | 204 |
    205 |
    206 | 207 | 208 |
    209 | 210 | 211 |
    212 | 213 |
    214 | 215 | 216 |
    217 | 218 |
    219 |
    220 | 221 | 222 |
    223 | 224 |
    225 |
    226 |
    227 |
    228 |
    229 |
    230 |
    231 | 232 | 233 |
    234 |
    235 |
    236 |
    237 | 238 |
    239 | 240 | 241 |
    242 | 243 |
    244 | 245 |
    246 | 247 |
    248 |
    249 |
    250 | 251 |
    252 |
    253 |
    254 |
    255 |
    256 |
    257 |
    258 | 259 |
    260 |
    261 |

    262 |
    263 |

    You are not assigned to a batch!

    264 |
    265 |

    If you are receiving this message in error, please contact your trainer.

    266 |
    267 |
    268 | ) 269 | } 270 | else{ 271 | return( 272 |
    273 |

    Failed to load data.

    274 |

    Please contact and administrator if you are seeing this message

    275 |
    276 | ) 277 | 278 | 279 | } 280 | } 281 | } 282 | 283 | export default Profile; 284 | -------------------------------------------------------------------------------- /app/public/Tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
    12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/public/style.css: -------------------------------------------------------------------------------- 1 | #dividerComments{ 2 | margin-top:3.5em; 3 | } 4 | .commentButton{ 5 | margin-top:1em; 6 | } 7 | 8 | #registerDiv{ 9 | margin-top: 90px; 10 | } 11 | 12 | .btnCenter{ 13 | margin-left: 10%; 14 | } 15 | .comment{ 16 | border-bottom: solid 1px black ; 17 | margin-bottom: 1em; 18 | box-shadow: gray 1px 1px 10px 1px; 19 | padding-top: 1em; 20 | } 21 | .commentBlock{ 22 | overflow-y: scroll; 23 | overflow-x: hidden; 24 | height: 20em; 25 | background-color:white; 26 | padding: 1em; 27 | border-radius: 5px; 28 | box-shadow: inset 1px 1px 10px 1px gray; 29 | } 30 | 31 | 32 | 33 | .option label{ 34 | font-weight:100 !important; 35 | } 36 | 37 | .examHeader { 38 | text-align: center; 39 | font-family: "Arial Rounded MT Bold"; 40 | } 41 | 42 | .option label:hover{ 43 | font-weight: bolder; 44 | } 45 | -------------------------------------------------------------------------------- /json/Exam.json: -------------------------------------------------------------------------------- 1 | { 2 | "topic":"", 3 | "questions":[ 4 | { 5 | "id":"", 6 | "ques":"", 7 | "ans":"", 8 | "weight":"", 9 | "options":[] 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /json/Forum.json: -------------------------------------------------------------------------------- 1 | { 2 | "batchname":"", 3 | "description":"This is your form", 4 | "Post":[{ 5 | "username":"", 6 | "comment":"" 7 | }] 8 | } -------------------------------------------------------------------------------- /json/Lesson.json: -------------------------------------------------------------------------------- 1 | { 2 | "curriculum":"", 3 | "title":"", 4 | "week":"", 5 | "topic":[] 6 | } -------------------------------------------------------------------------------- /json/User.json: -------------------------------------------------------------------------------- 1 | { 2 | "username":"", 3 | "id":"", 4 | "is_admin":"", 5 | "f_name":"", 6 | "l_name":"", 7 | "email":"", 8 | "batch":{ 9 | "name":"", 10 | "grades":[{ 11 | "score":"", 12 | "exam":"" 13 | }] 14 | } 15 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactproject", 3 | "version": "1.0.0", 4 | "description": "shell of react project", 5 | "main": "server.js", 6 | "dependencies": { 7 | "babel-core": "^6.5.1", 8 | "babel-loader": "^6.2.2", 9 | "babel-preset-es2015": "^6.5.0", 10 | "babel-preset-react": "^6.5.0", 11 | "body-parser": "^1.15.2", 12 | "cookie-parser": "^1.4.3", 13 | "enzyme": "^2.4.1", 14 | "express": "^4.14.0", 15 | "express-session": "^1.14.1", 16 | "glob": "^7.0.6", 17 | "gulp-util": "^3.0.7", 18 | "jsdom": "^9.4.2", 19 | "mongodb": "^2.2.9", 20 | "passport": "^0.3.2", 21 | "passport-local": "^1.0.0", 22 | "react": "^0.14.7", 23 | "react-bootstrap": "^0.30.3", 24 | "react-dom": "^0.14.7", 25 | "react-router": "^2.0.0", 26 | "superagent": "^2.2.0" 27 | }, 28 | "devDependencies": { 29 | "gulp": "^3.9.1", 30 | "jasmine-ajax": "^3.2.0", 31 | "react-addons-test-utils": "^0.14.8", 32 | "react-hot-loader": "^1.3.0", 33 | "webpack-dev-middleware": "^1.6.1", 34 | "webpack-hot-middleware": "^2.12.2" 35 | }, 36 | "scripts": { 37 | "test": "echo \"Error: no test specified\" && exit 1", 38 | "start": "start node server" 39 | }, 40 | "repository": { 41 | "type": "git", 42 | "url": "git+https://github.com/Ahredmon/ReactProject.git" 43 | }, 44 | "keywords": [ 45 | "react", 46 | "express", 47 | "webpack" 48 | ], 49 | "author": "Alex Redmon", 50 | "license": "ISC", 51 | "bugs": { 52 | "url": "https://github.com/Ahredmon/ReactProject/issues" 53 | }, 54 | "homepage": "https://github.com/Ahredmon/ReactProject#readme" 55 | } 56 | -------------------------------------------------------------------------------- /routing/RLMSAdmin.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var bparser = require('body-parser'); 4 | var DataAccess = require('../tools/mongoDataAccess.js'); 5 | router.use(bparser.json()); 6 | 7 | router.get('/getAllUsers', function(req,res){ 8 | var da = new DataAccess; 9 | da.getUsers(null,(result)=>{ 10 | res.status(200); 11 | res.json(result); 12 | }); 13 | }); 14 | 15 | router.post('/updateBatchAndUsers', function(req,res) { 16 | var batchToPost = req.body; 17 | var da = new DataAccess; 18 | res.status(201); 19 | 20 | batchToPost.forEach(function(item) { 21 | da.addOrUpdateUser(item, (result) => { 22 | }); 23 | }); 24 | 25 | res.send('done'); 26 | 27 | }); 28 | 29 | // router.post('/createNewBatch', function(req,res) { 30 | // var newBatch = req.body; 31 | // var da = new DataAccess; 32 | // da.addOrUpdateUser(req.body, (result) => { 33 | // res.status(201); 34 | // }); 35 | // }); 36 | 37 | module.exports = router; 38 | -------------------------------------------------------------------------------- /routing/RLMSCurriculum.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var bparser = require('body-parser'); 4 | var DataAccess = require('../tools/mongoDataAccess.js'); 5 | router.use(bparser.json()); 6 | 7 | router.get('/getLesson',function(req,res){ 8 | var da = new DataAccess; 9 | da.getLessons(null,(result)=>{ 10 | res.status(200); 11 | res.json(result); 12 | }); 13 | }); 14 | 15 | router.get('/getLesson/:batchName',function(req,res){ 16 | var da = new DataAccess; 17 | da.getLessons(req.params.batchName,(result)=>{ 18 | res.status(200); 19 | res.json(result); 20 | }); 21 | }); 22 | 23 | 24 | module.exports = router; -------------------------------------------------------------------------------- /routing/RLMSExam.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var bparser = require('body-parser'); 4 | var DataAccess = require('../tools/mongoDataAccess.js'); 5 | router.use(bparser.json()); 6 | 7 | 8 | router.get('/getExam',function(req,res){ 9 | var da = new DataAccess(); 10 | da.getExams((result)=>{ 11 | res.status(200); 12 | res.json(result); 13 | }); 14 | }); 15 | 16 | router.post('/postExam', function(req,res){ 17 | var da = new DataAccess(); 18 | var Exam=req.body; 19 | 20 | //update grade on databaase 21 | da.getUsers(Exam.username,(result)=>{ 22 | res.status(200); 23 | 24 | 25 | var tmp = result[0].batch; 26 | tmp.grade=Exam.grade; 27 | result[0].batch=tmp; 28 | console.log(result[0]); 29 | da.addOrUpdateUser(result[0],(done)=>{ 30 | res.json(done); 31 | }); 32 | }); 33 | }); 34 | 35 | 36 | module.exports = router; -------------------------------------------------------------------------------- /routing/RLMSForum.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var bparser = require('body-parser'); 4 | var DataAccess = require('../tools/mongoDataAccess.js'); 5 | router.use(bparser.json()); 6 | 7 | router.get('/getForum/:batchname',function(req,res){ 8 | var da = new DataAccess; 9 | console.log(req.params.batchname); 10 | da.getForums(req.params.batchname,(result)=>{ 11 | res.status(200); 12 | res.json(result); 13 | }); 14 | }); 15 | router.get('/getForum',function(req,res){ 16 | var da = new DataAccess; 17 | da.getForums(null,(result)=>{ 18 | res.status(200); 19 | res.json(result); 20 | }); 21 | }); 22 | router.post('/postForum', function(req,res){ 23 | var da = new DataAccess(); 24 | da.addOrUpdateForums(req.body,(result)=>{ 25 | res.status(200); 26 | res.json(result); 27 | }) 28 | }); 29 | 30 | module.exports = router; -------------------------------------------------------------------------------- /routing/RLMSGetUsers.js: -------------------------------------------------------------------------------- 1 | var express = require("express"); 2 | var router = express.Router(); 3 | var mongo = require('../tools/mongoDataAccess.js'); 4 | var bParser = require('body-parser'); 5 | router.use(bParser.json()) 6 | router.get('/getUser/:username', function(req, res){ 7 | res.status(200); 8 | var da = new mongo(); 9 | da.getUsers(req.params.username, function(result){ 10 | res.json(result); 11 | }) 12 | }); 13 | router.post('/updateUserProfile',function(req,res){ 14 | var data = req.body; 15 | res.status(200); 16 | var da=new mongo(); 17 | da.addOrUpdateUser(data,function(){ 18 | console.log("alex is and needs a life " + data); 19 | (result)=>{ 20 | if(result){ 21 | res.send('fuck yea'); 22 | } 23 | else{ 24 | res.send('well, shit.....'); 25 | } 26 | 27 | } 28 | }); 29 | 30 | }) 31 | 32 | module.exports = router; 33 | 34 | 35 | -------------------------------------------------------------------------------- /routing/RLMSPassport/init.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express.Router(); 3 | var passport = require('passport'); 4 | var localStrategy = require('passport-local').Strategy; 5 | var cookie = require('cookie-parser'); 6 | 7 | var session = require('express-session'); 8 | var mon = require('../../tools/mongoDataAccess.js'); 9 | 10 | var user = [ 11 | { 12 | "ID": 0, 13 | "username": "dev", 14 | "password": "123", 15 | "admin": 1 16 | }, 17 | { 18 | "ID": 1, 19 | "username": "guy", 20 | "password": "123", 21 | "admin": 0 22 | }, 23 | { 24 | "ID": 2, 25 | "username": "gal", 26 | "password": "123", 27 | "admin": 0 28 | } 29 | ]; 30 | 31 | app.get('/testGet', function(req, res){ 32 | res.json(data.getData()); 33 | }); 34 | 35 | app.use(cookie('itsASecretToEveyone')); 36 | app.use(session({ 37 | secret:'itsASecretToEveyone', 38 | saveUninitialized: true, 39 | resave: false, 40 | cookie: {path: '/user', httpOnly: true, maxAge: 5000} 41 | })); 42 | app.use(passport.initialize()); 43 | app.use(passport.session()); 44 | 45 | passport.serializeUser(function(userData, cb){ 46 | var sessionUser = {_id: userData.ID, name: userData.username} 47 | cb(null, sessionUser); 48 | }); 49 | 50 | passport.deserializeUser(function(sessionUser, cb){ 51 | findUserByID(sessionUser.ID, cb); 52 | }); 53 | 54 | function findUser(name, callback){ 55 | 56 | var da = new mon(); 57 | da.getUsers(name, function(result){ 58 | if(result.length > 0){ 59 | 60 | // var item = { 61 | // ID: result[0].id, 62 | // firstname: result[0].f_name, 63 | // lastname: result[0].l_name, 64 | // batch: result[0].batch 65 | // }; 66 | 67 | // localStorage.setItem('userObj', item); 68 | return callback(null, result[0]); 69 | } else{ 70 | return callback(null, false); 71 | } 72 | }); 73 | } 74 | 75 | function findUserByID(id, callback){ 76 | 77 | var da = new mon(); 78 | da.getUsers(null, function(userList){ 79 | for(var i = 0; i < userList.length; i++){ 80 | if(userList[i].ID == id){ 81 | return callback(null, userList[i]); 82 | } 83 | } 84 | return callback(null, false); 85 | }); 86 | } 87 | 88 | passport.use(new localStrategy({ 89 | usernameField: 'username', 90 | passwordField: 'password' 91 | }, function(username, password, done){ 92 | findUser(username, function(err, user){ 93 | if(err){ 94 | return done(err); 95 | } 96 | if(!user){ 97 | return done(null, false); 98 | } 99 | if(password !== user.password){ 100 | return done(null, false); 101 | } 102 | 103 | return done(null, user); 104 | }); 105 | })); 106 | 107 | module.exports = app; -------------------------------------------------------------------------------- /routing/RLMSPassport/sRoutes.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var passport = require('passport'); 3 | var app = express.Router(); 4 | var parser = require('body-parser'); 5 | var mon = require('../../tools/mongoDataAccess.js'); 6 | 7 | var secure = require('./init.js'); 8 | 9 | app.use('/', secure); 10 | app.use(parser.urlencoded({extended:false})); 11 | 12 | 13 | app.get('/profile/:username', function(req, res){ 14 | var url = '/#/home/forum?id='+req.params.username; 15 | res.redirect(url); 16 | }); 17 | 18 | app.post('/login', passport.authenticate('local', { 19 | //successRedirect: '/api/profile/', 20 | failureRedirect: '/#/login' 21 | }), function(req, res){ 22 | if(req.body.username){ 23 | res.redirect('/api/profile/'+req.body.username); 24 | } 25 | }); 26 | 27 | app.post('/signup', function(req, res){ 28 | if(req.body.cPass === req.body.password){ 29 | var da = new mon(); 30 | var userData = { 31 | username: req.body.username, 32 | f_name: req.body.firstname, 33 | l_name: req.body.lastname, 34 | password: req.body.password, 35 | email: req.body.email 36 | }; 37 | da.getUsers(userData.username, function(result){ 38 | if(result.length == 0){ 39 | 40 | da.addOrUpdateUser(userData, function(result){ 41 | if(result == "success"){ 42 | 43 | da.getUsers(userData.username, function (result) { 44 | // var item = { 45 | // ID: result[0]._id, 46 | // firstname: result[0].f_name, 47 | // lastname: result[0].l_name, 48 | // batch: result[0].batch}; 49 | 50 | // localStorage.setItem('userObj', it em); 51 | res.redirect('/api/profile/'+result[0].username); 52 | 53 | }); 54 | 55 | }}); 56 | 57 | }}); 58 | }}); 59 | 60 | module.exports = app; 61 | -------------------------------------------------------------------------------- /routing/RLMSTesting.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by coryd on 8/25/2016. 3 | */ 4 | var express =require('express'); 5 | 6 | var otherApp = express.Router(); 7 | 8 | //get method 9 | var data = [ 10 | 11 | { 12 | ID:1, 13 | FirstName:"Cory", 14 | LastName:"Davenport" 15 | }, 16 | { 17 | ID:2, 18 | FirstName: "Alex", 19 | LastName:"Redmond" 20 | 21 | }, 22 | { 23 | ID:3, 24 | FirstName:"David", 25 | LastName:"Socha" 26 | } 27 | ] 28 | otherApp.get('/getBasic',function(req,res){ 29 | res.status(200); 30 | res.send(JSON.stringify(data)); 31 | }); 32 | 33 | module.exports = otherApp; -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Alex Redmon on 8/22/2016. 3 | */ 4 | var express = require('express'), 5 | path = require('path'); 6 | app = express(), 7 | webpack = require('webpack'), 8 | configDir = path.resolve('config/webpack.config.js'), 9 | webpackDevMiddleware = require('webpack-dev-middleware'), 10 | webpackHotMiddleware = require('webpack-hot-middleware'), 11 | gutil = require('gulp-util'), 12 | webpackConfig =require(configDir); 13 | compiler=webpack(webpackConfig); 14 | 15 | var userRouter = require('./routing/RLMSGetUsers.js'); 16 | app.use('',userRouter); 17 | var basicRouter = require('./routing/RLMSTesting.js'); 18 | app.use('/api',basicRouter); 19 | 20 | var DA = require('./tools/mongoDataAccess.js'); 21 | 22 | var RLMSExam = require('./routing/RLMSExam.js'); 23 | app.use("", RLMSExam); 24 | 25 | var login = require('./routing/RLMSPassport/sRoutes'); 26 | app.use('/api', login); 27 | 28 | var DA = require('./tools/mongoDataAccess.js'); 29 | 30 | var RLMSForum = require('./routing/RLMSForum.js'); 31 | var RLMSC = require('./routing/RLMSCurriculum.js'); 32 | 33 | var RLMSAdmin = require('./routing/RLMSAdmin.js'); 34 | app.use("/admin", RLMSAdmin); 35 | 36 | app.use("",RLMSForum); 37 | app.use("",RLMSC); 38 | app.use(webpackDevMiddleware(compiler, { 39 | hot: true, 40 | filename: '[name].js', 41 | publicPath: '/JS', 42 | stats: { 43 | colors: true, 44 | }, 45 | historyApiFallback: true, 46 | })); 47 | app.use(webpackHotMiddleware(compiler, { 48 | log: console.log, 49 | path: '/__webpack_hmr', 50 | heartbeat: 10 * 1000, 51 | })); 52 | app.use(express.static('app/public')); 53 | app.use(function(req,res){ 54 | res.status(404); 55 | res.end("The requested document doesn't exist"); 56 | gutil.log('[Express - info]','A 404 error was reached at ',gutil.colors.magenta(req.originalUrl)); 57 | }); 58 | try{ 59 | 60 | listen(3000); 61 | } 62 | catch(err) 63 | { 64 | gutil.log('[Express - error]', guitil.colors.red('cannot bind to port')); 65 | process.exit(); 66 | } 67 | function listen(port){ 68 | app.listen(port); 69 | gutil.log('[Express -info]','Currently listening on port',gutil.colors.green(port)); 70 | } 71 | -------------------------------------------------------------------------------- /tools/mongoDataAccess.js: -------------------------------------------------------------------------------- 1 | var exports = module.exports = DataAccess; 2 | 3 | function DataAccess() 4 | { 5 | //declared the constructor and the client/url values. 6 | DataAccess.prototype.MongoClient = require('mongodb').MongoClient; 7 | DataAccess.prototype.url= 'mongodb://rlms:rlmsreact@ds017636.mlab.com:17636/rlms'; 8 | } 9 | // if username is null, get all users. Result is passed in callback! 10 | DataAccess.prototype.getUsers =(username,callback)=>{ 11 | 12 | 13 | var url = DataAccess.prototype.url; 14 | DataAccess.prototype.MongoClient.connect(url,(err,db)=> { 15 | if(!err) 16 | { 17 | if(err){console.log(err)} 18 | var cursor; 19 | if(!username) 20 | { 21 | cursor = db.collection('user').find(); 22 | 23 | }else{ 24 | cursor = db.collection('user').find({username:username}); 25 | } 26 | var result=[]; 27 | cursor.each((err,doc)=>{ 28 | if(doc){ 29 | result.push(doc); 30 | }else{callback(result)} 31 | }) 32 | }else{ 33 | console.log(err); 34 | } 35 | }); 36 | }; 37 | // check if user exists, if not insert new user, else update old user. 38 | DataAccess.prototype.addOrUpdateUser=(user,callback)=>{ 39 | var client = DataAccess.prototype.MongoClient; 40 | var url = DataAccess.prototype.url; 41 | var other =[]; 42 | // attempt to get the user. If the use exists, make it fail. 43 | DataAccess.prototype.getUsers(user.username,(result)=>{ 44 | // get the ID of the first result. 45 | if(result.length > 0 ){ 46 | console.log(result); 47 | 48 | user._id = result[0]._id; 49 | 50 | } 51 | if(user) 52 | { 53 | 54 | var newUser = { 55 | username: user.username, 56 | _id : user._id, 57 | id:user.id, 58 | is_admin:user.is_admin, 59 | is_active:user.is_active, 60 | f_name:user.f_name, 61 | l_name:user.l_name, 62 | email:user.email, 63 | batch:user.batch, 64 | password:user.password 65 | }; 66 | client.connect(url,(err,db)=>{ 67 | db.collection('user').save(newUser,(err)=>{ 68 | if(err){callback('error')} 69 | else {callback('success')} 70 | }) 71 | }) 72 | }else{callback('fail')} 73 | }); 74 | 75 | 76 | 77 | 78 | }; 79 | // get forums related to batchname, if null return all. 80 | DataAccess.prototype.getForums=(batchName,callback)=>{//todo 81 | var client = DataAccess.prototype.MongoClient; 82 | var url = DataAccess.prototype.url; 83 | var cursor; 84 | client.connect(url,(err,db)=>{ 85 | if(batchName) 86 | { 87 | cursor = db.collection('forum').find({batchName:batchName}) 88 | console.log('Ive been called!') 89 | }else{ 90 | cursor = db.collection('forum').find(); 91 | } 92 | var result = []; 93 | cursor.each((err,doc)=>{ 94 | if(doc){ 95 | result.push(doc); 96 | }else{ 97 | callback(result); 98 | } 99 | }) 100 | }); 101 | 102 | 103 | }; 104 | //... same as previous update method. 105 | DataAccess.prototype.addOrUpdateForums=(forum,callback)=>{ 106 | var client = DataAccess.prototype.MongoClient; 107 | var url = DataAccess.prototype.url; 108 | var newForm = { 109 | batchName:forum.batchName, 110 | description:forum.description, 111 | posts:forum.posts, 112 | }; 113 | if(forum){ 114 | DataAccess.prototype.getForums(newForm.batchName,(result)=>{ 115 | if(result.length > 0 ) 116 | {newForm._id = result[0]._id; 117 | console.log('duplicate found'); 118 | } 119 | client.connect(url,(err,db)=>{ 120 | console.log(err); 121 | db.collection('forum').save(newForm,(err)=>{ 122 | 123 | if(!err){ 124 | console.log('Entry successfully added to the database'); 125 | callback('Entry successfully added'); 126 | } 127 | else{console.log("this fuck?")} 128 | 129 | }) 130 | }) 131 | 132 | }) 133 | }else{ 134 | console.log('cannot insert a null value into the database'); 135 | } 136 | }; 137 | DataAccess.prototype.getLessons=(lessonName,callback)=>{ 138 | var client = DataAccess.prototype.MongoClient; 139 | var url = DataAccess.prototype.url; 140 | var cursor; 141 | client.connect(url, (err,db)=>{ 142 | if(lessonName) { 143 | cursor = db.collection('lesson').find({curriculum:lessonName}); 144 | }else{ 145 | cursor = db.collection('lesson').find(); 146 | } 147 | var result=[]; 148 | cursor.each((err,doc)=>{ 149 | if(doc){result.push(doc)} 150 | else{ db.close(); callback(result);} 151 | }) 152 | }) 153 | }; 154 | 155 | DataAccess.prototype.addOrUpdateLessons=(lesson,callback)=>{ 156 | var client = DataAccess.prototype.MongoClient; 157 | var url = DataAccess.prototype.url; 158 | client.connect(url, (err,db)=>{ 159 | DataAccess.prototype.getLessons(lesson.batchName,(result)=>{ 160 | if(result.length > 0 ){ 161 | lesson._id = result[0]._id; 162 | } 163 | var newLesson = { 164 | _id:lesson._id, 165 | curriculum:lesson.curriculum, 166 | title:lesson.title, 167 | week:lesson.week, 168 | topic:lesson.topic 169 | }; 170 | db.collection('lesson').save(newLesson,(err)=>{ 171 | if(err){console.log(err)} 172 | else{callback('Success')} 173 | }); 174 | 175 | }) 176 | }) 177 | 178 | 179 | }; 180 | // exam doesn't accept an exam name. Always returns all questions. 181 | 182 | DataAccess.prototype.getExams=(callback)=>{ 183 | var client = DataAccess.prototype.MongoClient; 184 | var url = DataAccess.prototype.url; 185 | client.connect(url,(err,db)=>{ 186 | var result =[]; 187 | var cursor =db.collection('exam').find(); 188 | cursor.each((err,doc)=>{ 189 | if(doc){ 190 | result.push(doc); 191 | }else{callback(result)} 192 | }) 193 | 194 | }) 195 | }; 196 | // add exam to database. Callback provides result. 197 | 198 | DataAccess.prototype.addOrUpdateExams=(exam, callback)=>{ 199 | var client = DataAccess.prototype.MongoClient; 200 | var url = DataAccess.prototype.url; 201 | var newExam = { 202 | topic: exam.topic, 203 | questions: exam.questions 204 | 205 | }; 206 | client.connect((err,db)=>{ 207 | db.collection('exam').save(exam,(err)=>{ 208 | if(!err){callback('success')} 209 | }) 210 | }) 211 | }; 212 | -------------------------------------------------------------------------------- /tools/mongoutil.js: -------------------------------------------------------------------------------- 1 | var MongoClient = require('mongodb').MongoClient; 2 | var exports = module.exports = {}; 3 | url = 'mongodb://localhost:27017/test'; 4 | exports.establish = (callback)=>{ 5 | MongoClient.connect(url,(err,db)=>{ 6 | callback(db); 7 | }) 8 | } 9 | --------------------------------------------------------------------------------