Advertisement
Guest User

Untitled

a guest
Jun 7th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.87 KB | None | 0 0
  1. Module Module1
  2. Dim user As String
  3. Dim apass As String
  4. Sub Main()
  5. login()
  6. End Sub
  7. Sub login()
  8. Dim choice As Integer
  9. Do
  10. Console.WriteLine("-----------LOGIN MENU-----------")
  11. Console.WriteLine("Please choose an option from below")
  12. Console.WriteLine("1 - Admin Login")
  13. Console.WriteLine("2 - Student Login")
  14. Console.WriteLine("9- Exit")
  15. Console.Write("Please Enter Your Choice: ")
  16. choice = Console.ReadLine
  17. Select Case choice
  18. Case "1"
  19. loginadmin()
  20. Case "2"
  21. loginstudent()
  22. Case "9"
  23. Exit Do
  24. Case Else
  25. Console.WriteLine("Please Enter A Vaild Option")
  26. End Select
  27. Loop Until choice = "1" Or "2" Or "9"
  28. End Sub
  29. Sub loginadmin()
  30. Console.WriteLine("-----------ADMIN LOGIN-----------")
  31. Console.Write("Username: ")
  32. user = Console.ReadLine()
  33. Console.Write("Password: ")
  34. apass = Console.ReadLine
  35. If apass = "Admin" And user = "Admin" Then
  36. AdminMenu()
  37. Else
  38. Console.Write("Wrong Login Credentials, Press ENTER To Try Again")
  39. Console.ReadLine()
  40. loginadmin()
  41. End If
  42. End Sub
  43. Sub loginstudent()
  44. Console.WriteLine("-----------STUDENT LOGIN-----------")
  45. Console.Write("Username: ")
  46. user = Console.ReadLine()
  47.  
  48. If user.Contains("y3") Then
  49. Testy3()
  50. ElseIf user.Contains("y4") Then
  51. Testy4()
  52. ElseIf user.Contains("y5") Then
  53. Testy5()
  54. ElseIf user.Contains("y6") Then
  55. Testy6()
  56. End If
  57. End Sub
  58. Sub AdminMenu()
  59. Dim choice As Integer
  60. Dim mark As Integer
  61. mark = 0
  62. Do
  63. Console.WriteLine("-----------ADMIN MENU-----------")
  64. Console.WriteLine("Please choose an option from below")
  65. Console.WriteLine("1 - Set Test For Year 3")
  66. Console.WriteLine("2 - Set Test For Year 4")
  67. Console.WriteLine("3 - Set Test For Year 5")
  68. Console.WriteLine("4 - Set Test For Year 6")
  69. Console.WriteLine("5 - Look At Test Results")
  70. Console.WriteLine("9 - Exit")
  71. Console.Write("Please Enter Your Choice: ")
  72. choice = Console.ReadLine
  73. Select Case choice
  74. Case "1"
  75. Settesty3()
  76. Case "2"
  77. Settesty4()
  78. Case "3"
  79. Settesty5()
  80. Case "4"
  81. Settesty6()
  82. Case "5"
  83. listresults()
  84. Case "9"
  85. Exit Do
  86. Case Else
  87. Console.WriteLine("Please enter a valid option")
  88. End Select
  89.  
  90. Loop Until choice = "9"
  91. FileOpen(1, CurDir() & "\users.csv", OpenMode.Append)
  92. Dim fullline As String = user & "," & mark
  93. PrintLine(1, fullline)
  94. FileClose(1)
  95. End Sub
  96. Sub Settesty3()
  97. Dim word(10) As String
  98. Dim definition(10) As String
  99. Console.WriteLine("-----------SET TEST - YEAR 3-----------")
  100. For i As Integer = 1 To 10
  101. Console.Write("Enter " & i & "st Word: ")
  102. word(i) = Console.ReadLine()
  103. Next
  104. For a As Integer = 1 To 10
  105. Console.Write("Enter The Definiton For The " & a & "st Word: ")
  106. definition(a) = Console.ReadLine()
  107. Next
  108.  
  109. FileOpen(1, CurDir() & "\testy3.csv", OpenMode.Output)
  110. For e = 1 To 10
  111. Dim fullline As String = word(e) & "," & definition(e)
  112. PrintLine(1, fullline)
  113. Next
  114. FileClose(1)
  115. End Sub
  116. Sub Testy3()
  117. Dim word(10) As String
  118. Dim definition(10) As String
  119. Dim noofrecords As Integer
  120. Dim items() As String
  121. Dim answer(10) As String
  122. Dim mark As Integer
  123. Dim total As Integer
  124.  
  125. total = 20
  126. mark = 0
  127. noofrecords = 0
  128. FileOpen(1, CurDir() & "\testy3.csv", OpenMode.Input)
  129. Do Until EOF(1)
  130. noofrecords += 1
  131. Dim fullline As String = LineInput(1)
  132. items = Split(fullline, ",")
  133. word(noofrecords) = items(0)
  134. definition(noofrecords) = items(1)
  135. Loop
  136. FileClose(1)
  137. Console.WriteLine("-----------DEFINITIONS-----------")
  138. For i = 1 To 10
  139. Console.WriteLine(i & ": " & definition(i))
  140. Next
  141. Console.WriteLine("-----------TEST TIME-----------")
  142. Console.WriteLine("Enter your answers for the definitions 1 - 10 below:")
  143. For e = 1 To 10
  144. Console.Write(e & ": ")
  145. answer(e) = Console.ReadLine
  146. Next
  147.  
  148. For j = 1 To 10
  149. If word(j) = answer(j) Then
  150. mark = mark + 2
  151. End If
  152. Next
  153. FileOpen(1, CurDir() & "\users.csv", OpenMode.Append)
  154. Dim fullline1 As String = user & "," & mark & "," & total
  155. PrintLine(1, fullline1)
  156. FileClose(1)
  157. Console.Write("Your total score was" & mark & "/" & total & ", Press enter to close the test.")
  158. Console.ReadLine()
  159. End Sub
  160. Sub Settesty4()
  161. Dim word(10) As String
  162. Dim definition(10) As String
  163. Console.WriteLine("-----------SET TEST - YEAR 4-----------")
  164. For i As Integer = 1 To 10
  165. Console.Write("Enter " & i & "st Word: ")
  166. word(i) = Console.ReadLine()
  167. Next
  168. For a As Integer = 1 To 10
  169. Console.Write("Enter The Definiton for the " & a & "st Word: ")
  170. definition(a) = Console.ReadLine()
  171. Next
  172.  
  173. FileOpen(1, CurDir() & "\testy4.csv", OpenMode.Output)
  174. For e As Integer = 1 To 10
  175. Dim fullline As String = word(e) & "," & definition(e)
  176. PrintLine(1, fullline)
  177. Next
  178. FileClose(1)
  179. End Sub
  180. Sub Testy4()
  181. Dim word(10) As String
  182. Dim definition(10) As String
  183. Dim noofrecords As Integer
  184. Dim items() As String
  185. Dim answer(10) As String
  186. Dim mark As Integer
  187. Dim total As Integer
  188.  
  189. total = 20
  190. mark = 0
  191. noofrecords = 0
  192. FileOpen(1, CurDir() & "\testy4.csv", OpenMode.Input)
  193. Do Until EOF(1)
  194. noofrecords += 1
  195. Dim fullline As String = LineInput(1)
  196. items = Split(fullline, ",")
  197. word(noofrecords) = items(0)
  198. definition(noofrecords) = items(1)
  199. Loop
  200. FileClose(1)
  201. Console.WriteLine("-----------TEST TIME-----------")
  202. For i = 1 To 10
  203. Console.WriteLine(i & ": " & definition(i))
  204. Next
  205. Console.WriteLine("-----------PRESS ENTER TO CONTINUE-----------")
  206. Console.WriteLine("Enter your answers for definitions 1 - 10 below:")
  207. For e = 1 To 10
  208. Console.Write(e & ": ")
  209. answer(e) = Console.ReadLine
  210. Next
  211.  
  212. For j = 1 To 10
  213. If word(j) = answer(j) Then
  214. mark = mark + 2
  215. End If
  216. Next
  217. FileOpen(1, CurDir() & "\users.csv", OpenMode.Append)
  218. Dim fullline1 As String = user & "," & mark & "," & total
  219. PrintLine(1, fullline1)
  220. FileClose(1)
  221. Console.Write("Your total score was" & mark & "/" & total & ", Press enter to close the test.")
  222. Console.ReadLine()
  223. End Sub
  224. Sub Settesty5()
  225. Dim word(10) As String
  226. Dim definition(10) As String
  227. Console.WriteLine("-----------TEST TIME-----------")
  228. For i As Integer = 1 To 10
  229. Console.Write("Enter " & i & "st Word: ")
  230. word(i) = Console.ReadLine()
  231. Next
  232. For a As Integer = 1 To 10
  233. Console.Write("Enter The Definiton for the " & a & "st Word: ")
  234. definition(a) = Console.ReadLine()
  235. Next
  236.  
  237. FileOpen(1, CurDir(), "\testy5.csv", OpenMode.Output)
  238. For e As Integer = 1 To 10
  239. Dim fullline As String = word(e) & "," & definition(e)
  240. PrintLine(1, fullline)
  241. Next
  242. FileClose(1)
  243. End Sub
  244. Sub Testy5()
  245. Dim word(10) As String
  246. Dim definition(10) As String
  247. Dim noofrecords As Integer
  248. Dim items() As String
  249. Dim answer(10) As String
  250. Dim mark As Integer
  251. Dim total As Integer
  252.  
  253. total = 20
  254. mark = 0
  255. noofrecords = 0
  256. FileOpen(1, CurDir() & "\testy5.csv", OpenMode.Input)
  257. Do Until EOF(1)
  258. noofrecords += 1
  259. Dim fullline As String = LineInput(1)
  260. items = Split(fullline, ",")
  261. word(noofrecords) = items(0)
  262. definition(noofrecords) = items(1)
  263. Loop
  264. FileClose(1)
  265. Console.WriteLine("-----------TEST TIME-----------")
  266. For i = 1 To 10
  267. Console.WriteLine(i & ": " & definition(i))
  268. Next
  269. Console.WriteLine("-----------PRESS ENTER TO CONTINUE-----------")
  270. Console.WriteLine("Enter your answers for definitions 1 - 10 below:")
  271. For e = 1 To 10
  272. Console.Write(e & ": ")
  273. answer(e) = Console.ReadLine
  274. Next
  275.  
  276. For j = 1 To 10
  277. If word(j) = answer(j) Then
  278. mark = mark + 2
  279. End If
  280. Next
  281. FileOpen(1, CurDir() & "\users.csv", OpenMode.Append)
  282. Dim fullline1 As String = user & "," & mark & "," & total
  283. PrintLine(1, fullline1)
  284. FileClose(1)
  285. Console.Write("Your total score was" & mark & "/" & total & ", Press enter to close the test.")
  286. Console.ReadLine()
  287. End Sub
  288. Sub Settesty6()
  289. Dim word(10) As String
  290. Dim definition(10) As String
  291. Console.WriteLine("-----------SET TEST - YEAR 6-----------")
  292. For i As Integer = 1 To 10
  293. Console.Write("Enter " & i & "st Word: ")
  294. word(i) = Console.ReadLine()
  295. Next
  296. For a As Integer = 1 To 10
  297. Console.Write("Enter The Definiton for the " & a & "st Word: ")
  298. definition(a) = Console.ReadLine()
  299. Next
  300.  
  301. FileOpen(1, CurDir() & "\testy6.csv", OpenMode.Output)
  302. For e As Integer = 1 To 10
  303. Dim fullline As String = word(e) & "," & definition(e)
  304. PrintLine(1, fullline)
  305. Next
  306. FileClose(1)
  307. End Sub
  308. Sub Testy6()
  309. Dim word(10) As String
  310. Dim definition(10) As String
  311. Dim noofrecords As Integer
  312. Dim items() As String
  313. Dim answer(10) As String
  314. Dim mark As Integer
  315. Dim total As Integer
  316.  
  317. total = 20
  318. mark = 0
  319. noofrecords = 0
  320. FileOpen(1, CurDir() & "\testy6.csv", OpenMode.Input)
  321. Do Until EOF(1)
  322. noofrecords += 1
  323. Dim fullline As String = LineInput(1)
  324. items = Split(fullline, ",")
  325. word(noofrecords) = items(0)
  326. definition(noofrecords) = items(1)
  327. Loop
  328. FileClose(1)
  329. Console.WriteLine("-----------DEFINITIONS-----------")
  330. For i = 1 To 10
  331. Console.WriteLine(i & ": " & definition(i))
  332. Next
  333. Console.WriteLine("-----------TEST TIME-----------")
  334. Console.WriteLine("Enter your answers for definition 1 - 10 below:")
  335. For e = 1 To 10
  336. Console.Write(e & ": ")
  337. answer(e) = Console.ReadLine
  338. Next
  339.  
  340. For j = 1 To 10
  341. If word(j) = answer(j) Then
  342. mark = mark + 2
  343. End If
  344. Next
  345. FileOpen(1, CurDir() & "\users.csv", OpenMode.Append)
  346. Dim fullline1 As String = user & "," & mark & "," & total
  347. PrintLine(1, fullline1)
  348. FileClose(1)
  349. Console.Write("Your total score was " & mark & "/" & total & ", Press enter to close the test.")
  350. Console.ReadLine()
  351. End Sub
  352. Sub listresults()
  353. Dim noofrecords As Integer
  354. Dim items() As String
  355. Dim answer(10) As String
  356. Dim mark(999) As Integer
  357. Dim total As Integer
  358. Dim users(999) As String
  359.  
  360. total = 20
  361.  
  362. FileOpen(1, CurDir() & "\users.csv", OpenMode.Input)
  363. Do Until EOF(1)
  364. noofrecords += 1
  365. Dim fullline As String = LineInput(1)
  366. items = Split(fullline, ",")
  367. users(noofrecords) = items(0)
  368. mark(noofrecords) = items(1)
  369. Loop
  370. FileClose(1)
  371. Console.WriteLine("-----------RESULTS-----------")
  372. For i = 1 To noofrecords
  373. Console.WriteLine(users(i) & ": " & mark(i) & "/" & total)
  374. Next
  375. Console.ReadLine()
  376. End Sub
  377. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement