├── .gitignore ├── DB Scripts └── Script.sql ├── LICENSE ├── Quiz-Application.Services ├── Entities │ ├── Answer.cs │ ├── BaseEntity.cs │ ├── Candidate.cs │ ├── Choices.cs │ ├── Exam.cs │ ├── QnA.cs │ ├── Question.cs │ ├── Request.cs │ └── Result.cs ├── Migrations │ ├── 20210523162654_Initial-Migration.Designer.cs │ ├── 20210523162654_Initial-Migration.cs │ ├── 20210717080733_Modified-Field-ImgFile.Designer.cs │ ├── 20210717080733_Modified-Field-ImgFile.cs │ ├── 20210717084352_Added-Field-Roles.Designer.cs │ ├── 20210717084352_Added-Field-Roles.cs │ ├── 20210822100202_Added new columnn - SessionID.Designer.cs │ ├── 20210822100202_Added new columnn - SessionID.cs │ ├── 20210827183543_Added-SP-GetReport.Designer.cs │ ├── 20210827183543_Added-SP-GetReport.cs │ └── QuizDBContextModelSnapshot.cs ├── Quiz-Application.Services.csproj ├── QuizDBContext.cs ├── Repository │ ├── Base │ │ ├── CandidateService.cs │ │ ├── ExamService.cs │ │ ├── QuestionService.cs │ │ └── ResultService.cs │ └── Interfaces │ │ ├── ICandidate.cs │ │ ├── IExam.cs │ │ ├── IQuestion.cs │ │ └── IResult.cs └── ServiceCollectionExtension.cs ├── Quiz-Application.Web ├── Authentication │ └── BasicAuthentication.cs ├── Controllers │ ├── AccountController.cs │ ├── ExamController.cs │ ├── HomeController.cs │ └── ScoreController.cs ├── Enums │ └── Alerts.cs ├── Extensions │ ├── AlertExtension.cs │ ├── EncodingExtension.cs │ └── SessionExtension.cs ├── Models │ ├── ErrorViewModel.cs │ ├── LoginViewModel.cs │ ├── ProfileViewModel.cs │ ├── RegisterViewModel.cs │ ├── ResetViewModel.cs │ └── ResultViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Quiz-Application.Web.csproj ├── Startup.cs ├── Views │ ├── Account │ │ ├── _Login.cshtml │ │ ├── _Register.cshtml │ │ └── _Reset.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Profile.cshtml │ ├── Score │ │ └── Result.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json ├── bundleconfig.json ├── libwkhtmltox.dll ├── libwkhtmltox.dylib ├── libwkhtmltox.so └── wwwroot │ ├── UploadedFiles │ └── Report │ │ └── 801894_Certificate.pdf │ ├── css │ ├── main.css │ ├── site.css │ └── util.css │ ├── favicon.ico │ ├── fonts │ ├── JosefinSans │ │ ├── JosefinSans-Bold.ttf │ │ ├── JosefinSans-BoldItalic.ttf │ │ ├── JosefinSans-Italic.ttf │ │ ├── JosefinSans-Light.ttf │ │ ├── JosefinSans-LightItalic.ttf │ │ ├── JosefinSans-Regular.ttf │ │ ├── JosefinSans-SemiBold.ttf │ │ ├── JosefinSans-SemiBoldItalic.ttf │ │ ├── JosefinSans-Thin.ttf │ │ ├── JosefinSans-ThinItalic.ttf │ │ └── OFL.txt │ ├── Linearicons-Free-v1.0.0 │ │ ├── WebFont │ │ │ ├── Linearicons-Free.eot │ │ │ ├── Linearicons-Free.svg │ │ │ ├── Linearicons-Free.ttf │ │ │ ├── Linearicons-Free.woff │ │ │ └── Linearicons-Free.woff2 │ │ └── icon-font.min.css │ ├── OpenSans │ │ ├── OpenSans-Bold.ttf │ │ ├── OpenSans-BoldItalic.ttf │ │ ├── OpenSans-ExtraBold.ttf │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ ├── OpenSans-Italic.ttf │ │ ├── OpenSans-Light.ttf │ │ ├── OpenSans-LightItalic.ttf │ │ ├── OpenSans-Regular.otf │ │ ├── OpenSans-Regular.ttf │ │ ├── OpenSans-SemiBold.ttf │ │ └── OpenSans-SemiBoldItalic.ttf │ ├── font-awesome-4.7.0 │ │ ├── HELP-US-OUT.txt │ │ ├── css │ │ │ ├── font-awesome.css │ │ │ └── font-awesome.min.css │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ │ ├── less │ │ │ ├── animated.less │ │ │ ├── bordered-pulled.less │ │ │ ├── core.less │ │ │ ├── fixed-width.less │ │ │ ├── font-awesome.less │ │ │ ├── icons.less │ │ │ ├── larger.less │ │ │ ├── list.less │ │ │ ├── mixins.less │ │ │ ├── path.less │ │ │ ├── rotated-flipped.less │ │ │ ├── screen-reader.less │ │ │ ├── stacked.less │ │ │ └── variables.less │ │ └── scss │ │ │ ├── _animated.scss │ │ │ ├── _bordered-pulled.scss │ │ │ ├── _core.scss │ │ │ ├── _fixed-width.scss │ │ │ ├── _icons.scss │ │ │ ├── _larger.scss │ │ │ ├── _list.scss │ │ │ ├── _mixins.scss │ │ │ ├── _path.scss │ │ │ ├── _rotated-flipped.scss │ │ │ ├── _screen-reader.scss │ │ │ ├── _stacked.scss │ │ │ ├── _variables.scss │ │ │ └── font-awesome.scss │ └── oswald │ │ ├── Oswald-Bold.ttf │ │ ├── Oswald-ExtraLight.ttf │ │ ├── Oswald-Light.ttf │ │ ├── Oswald-Medium.ttf │ │ ├── Oswald-Regular.ttf │ │ └── Oswald-SemiBold.ttf │ ├── images │ ├── bg-01.jpg │ ├── icons │ │ ├── favicon.ico │ │ └── map-marker.png │ └── img-01.png │ ├── js │ ├── main.js │ ├── map-custom.js │ ├── site.js │ └── site.min.js │ ├── lib │ ├── bootstrap │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-grid.css │ │ │ ├── bootstrap-grid.css.map │ │ │ ├── bootstrap-grid.min.css │ │ │ ├── bootstrap-grid.min.css.map │ │ │ ├── bootstrap-reboot.css │ │ │ ├── bootstrap-reboot.css.map │ │ │ ├── bootstrap-reboot.min.css │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ └── js │ │ │ ├── bootstrap.bundle.js │ │ │ ├── bootstrap.bundle.js.map │ │ │ ├── bootstrap.bundle.min.js │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.js.map │ │ │ ├── bootstrap.min.js │ │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ │ ├── LICENSE.txt │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ └── jquery │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map │ └── vendor │ ├── animate │ └── animate.css │ ├── animsition │ ├── css │ │ ├── animsition.css │ │ └── animsition.min.css │ └── js │ │ ├── animsition.js │ │ └── animsition.min.js │ ├── bootstrap │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── popper.js │ │ ├── popper.min.js │ │ └── tooltip.js │ ├── countdowntime │ └── countdowntime.js │ ├── css-hamburgers │ ├── hamburgers.css │ └── hamburgers.min.css │ ├── daterangepicker │ ├── daterangepicker.css │ ├── daterangepicker.js │ ├── moment.js │ └── moment.min.js │ ├── jquery │ └── jquery-3.2.1.min.js │ ├── perfect-scrollbar │ ├── perfect-scrollbar.css │ └── perfect-scrollbar.min.js │ └── select2 │ ├── select2.css │ ├── select2.js │ ├── select2.min.css │ └── select2.min.js ├── Quiz-Application.sln └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /DB Scripts/Script.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnabMSDN/Quiz-Application/3d3b0cd9bee2ddec9c68dbbc28894838e6c6c1db/DB Scripts/Script.sql -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Arnab Mukherjee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Answer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Quiz_Application.Services.Entities 10 | { 11 | public class Answer:BaseEntity 12 | { 13 | [Key] 14 | public int Sl_No { get; set; } 15 | public int QuestionID { get; set; } 16 | public int ChoiceID { get; set; } 17 | public string DisplayText { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/BaseEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Quiz_Application.Services.Entities 10 | { 11 | public class BaseEntity 12 | { 13 | 14 | [Column(TypeName = "datetime")] 15 | [DataType(DataType.DateTime)] 16 | public DateTime? CreatedOn { get; set; } 17 | 18 | [Column(TypeName = "datetime")] 19 | [DataType(DataType.DateTime)] 20 | public DateTime? ModifiedOn { get; set; } 21 | 22 | [Column(TypeName = "varchar(200)")] 23 | public string CreatedBy { get; set; } 24 | 25 | [Column(TypeName = "varchar(200)")] 26 | public string ModifiedBy { get; set; } 27 | public bool IsDeleted { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Candidate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Quiz_Application.Services.Entities 10 | { 11 | public class Candidate:BaseEntity 12 | { 13 | [Key] 14 | public int Sl_No { get; set; } 15 | 16 | [Column(TypeName = "varchar(250)")] 17 | public string Name { get; set; } 18 | 19 | [Column(TypeName = "varchar(250)")] 20 | public string Email { get; set; } 21 | 22 | [Column(TypeName = "varchar(20)")] 23 | public string Phone { get; set; } 24 | 25 | [Column(TypeName = "varchar(20)")] 26 | public string Candidate_ID { get; set; } 27 | 28 | [Column(TypeName = "varchar(100)")] 29 | public string Roles { get; set; } 30 | 31 | [Column(TypeName = "varchar(250)")] 32 | public string Password { get; set; } 33 | 34 | [MaxLength] 35 | public string ImgFile { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Choices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Quiz_Application.Services.Entities 10 | { 11 | public class Choice:BaseEntity 12 | { 13 | [Key] 14 | public int ChoiceID { get; set; } 15 | public int QuestionID { get; set; } 16 | public string DisplayText { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Exam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Quiz_Application.Services.Entities 10 | { 11 | public class Exam:BaseEntity 12 | { 13 | [Key] 14 | public int ExamID { get; set; } 15 | 16 | [Column(TypeName = "varchar(1000)")] 17 | public string Name { get; set; } 18 | 19 | [Column(TypeName = "decimal(18,2)")] 20 | public decimal FullMarks { get; set; } 21 | 22 | [Column(TypeName = "decimal(18,2)")] 23 | public decimal Duration { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/QnA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Quiz_Application.Services.Entities 8 | { 9 | public class QnA 10 | { 11 | public int ExamID { get; set; } 12 | public string Exam { get; set; } 13 | public List questions { get; set; } 14 | } 15 | public class QuestionDetails 16 | { 17 | public int QuestionID { get; set; } 18 | public string QuestionText { get; set; } 19 | public int QuestionType { get; set; } 20 | public List options { get; set; } 21 | public AnswerDetails answer { get; set; } 22 | } 23 | public class OptionDetails 24 | { 25 | public int OptionID { get; set; } 26 | public string Option { get; set; } 27 | } 28 | public class AnswerDetails 29 | { 30 | public int AnswarID { get; set; } 31 | public int OptionID { get; set; } 32 | public string Answar { get; set; } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Question.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel.DataAnnotations; 7 | using System.ComponentModel.DataAnnotations.Schema; 8 | 9 | namespace Quiz_Application.Services.Entities 10 | { 11 | public class Question:BaseEntity 12 | { 13 | [Key] 14 | public int QuestionID { get; set; } 15 | public int QuestionType { get; set; } //MCQ-1 16 | public string DisplayText { get; set; } 17 | public int ExamID { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Request.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Quiz_Application.Services.Entities 8 | { 9 | public class Option 10 | { 11 | public int CandidateID { get; set; } 12 | public int ExamID { get; set; } 13 | public int QuestionID { get; set; } 14 | public int AnswerID { get; set; } 15 | public int SelectedOption { get; set; } 16 | } 17 | public class Root 18 | { 19 | public Candidate objCandidate { get; set; } 20 | public List objAttempt { get; set; } 21 | } 22 | public class QuizAttempt 23 | { 24 | public int Sl_No { get; set; } 25 | public string SessionID { get; set; } 26 | public int ExamID { get; set; } 27 | public string Exam { get; set; } 28 | public string Date { get; set; } 29 | public string Score { get; set; } 30 | public string Status { get; set; } 31 | } 32 | public class QuizReport 33 | { 34 | public int CandidateID { get; set; } 35 | public string SessionID { get; set; } 36 | public int ExamID { get; set; } 37 | public string Exam { get; set; } 38 | public string Date { get; set; } 39 | public string Message { get; set; } 40 | } 41 | public class ReqReport 42 | { 43 | public int ExamID { get; set; } 44 | public string CandidateID { get; set; } 45 | public string SessionID { get; set; } 46 | } 47 | public class ReqCertificate 48 | { 49 | public int CandidateID { get; set; } 50 | public string SessionID { get; set; } 51 | public int ExamID { get; set; } 52 | public string Exam { get; set; } 53 | public string Date { get; set; } 54 | public string Score { get; set; } 55 | } 56 | 57 | public class Request 58 | { 59 | } 60 | public class ResPDF 61 | { 62 | public bool IsSuccess { get; set; } 63 | public string Path { get; set; } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Entities/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Quiz_Application.Services.Entities 9 | { 10 | public class Result:BaseEntity 11 | { 12 | [Key] 13 | public int Sl_No { get; set; } 14 | 15 | [MaxLength] 16 | public string SessionID { get; set; } 17 | public int CandidateID { get; set; } 18 | public int ExamID { get; set; } 19 | public int QuestionID { get; set; } 20 | public int AnswerID { get; set; } 21 | public int SelectedOptionID { get; set; } 22 | public bool IsCorrent { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Migrations/20210717080733_Modified-Field-ImgFile.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Quiz_Application.Services.Migrations 4 | { 5 | public partial class ModifiedFieldImgFile : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.RenameColumn( 10 | name: "ImgPath", 11 | table: "Candidate", 12 | newName: "ImgFile"); 13 | } 14 | 15 | protected override void Down(MigrationBuilder migrationBuilder) 16 | { 17 | migrationBuilder.RenameColumn( 18 | name: "ImgFile", 19 | table: "Candidate", 20 | newName: "ImgPath"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Migrations/20210717084352_Added-Field-Roles.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Quiz_Application.Services.Migrations 4 | { 5 | public partial class AddedFieldRoles : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AlterColumn( 10 | name: "Password", 11 | table: "Candidate", 12 | type: "varchar(250)", 13 | nullable: true, 14 | oldClrType: typeof(string), 15 | oldType: "varchar(50)", 16 | oldNullable: true); 17 | 18 | migrationBuilder.AddColumn( 19 | name: "Roles", 20 | table: "Candidate", 21 | type: "varchar(100)", 22 | nullable: true); 23 | } 24 | 25 | protected override void Down(MigrationBuilder migrationBuilder) 26 | { 27 | migrationBuilder.DropColumn( 28 | name: "Roles", 29 | table: "Candidate"); 30 | 31 | migrationBuilder.AlterColumn( 32 | name: "Password", 33 | table: "Candidate", 34 | type: "varchar(50)", 35 | nullable: true, 36 | oldClrType: typeof(string), 37 | oldType: "varchar(250)", 38 | oldNullable: true); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Migrations/20210822100202_Added new columnn - SessionID.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Quiz_Application.Services.Migrations 4 | { 5 | public partial class AddednewcolumnnSessionID : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "SessionID", 11 | table: "Result", 12 | type: "nvarchar(max)", 13 | nullable: true); 14 | } 15 | 16 | protected override void Down(MigrationBuilder migrationBuilder) 17 | { 18 | migrationBuilder.DropColumn( 19 | name: "SessionID", 20 | table: "Result"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Migrations/20210827183543_Added-SP-GetReport.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Quiz_Application.Services.Migrations 4 | { 5 | public partial class AddedSPGetReport : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.Sql(@"CREATE OR ALTER PROCEDURE GetReport 10 | ( 11 | @ExamID int, 12 | @CandidateID varchar(50), 13 | @SessionID nvarchar(max) 14 | ) 15 | AS 16 | BEGIN 17 | SET NOCOUNT ON; 18 | 19 | SELECT 20 | R.CandidateID, 21 | R.SessionID, 22 | R.ExamID, 23 | E.Name AS Exam, 24 | CONVERT(VARCHAR, R.CreatedOn, 106) AS Date, 25 | CASE 26 | WHEN ((CAST(COUNT(R.Sl_No) AS decimal)/E.FullMarks *100) >50) THEN 'Excellent! You gave '+CAST(COUNT(R.Sl_No) as varchar)+' correct answers out of '+CAST(CAST(E.FullMarks AS int) AS varchar)+' questions. You are very close to become an expert. Keep learning!' 27 | ELSE 'Oops! You gave '+CAST(COUNT(R.Sl_No) as varchar)+' correct answers out of '+CAST(CAST(E.FullMarks AS int) AS varchar)+' questions. You really need to work hard to become an expert.' 28 | END AS 'Message' 29 | FROM Result R 30 | LEFT JOIN Exam E ON R.ExamID=E.ExamID 31 | WHERE R.ExamID=@ExamID AND R.CandidateID = @CandidateID AND R.SessionID=@SessionID AND R.IsCorrent=1 32 | GROUP BY R.CandidateID,R.SessionID,R.ExamID,E.Name,E.FullMarks,R.CreatedOn 33 | 34 | SET NOCOUNT OFF; 35 | END"); 36 | } 37 | 38 | protected override void Down(MigrationBuilder migrationBuilder) 39 | { 40 | migrationBuilder.Sql("DROP PROC GetReport"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Quiz-Application.Services.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | Quiz_Application.Services 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | all 27 | runtime; build; native; contentfiles; analyzers; buildtransitive 28 | 29 | 30 | 31 | all 32 | runtime; build; native; contentfiles; analyzers; buildtransitive 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Quiz-Application.Services/QuizDBContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Quiz_Application.Services.Entities; 4 | 5 | namespace Quiz_Application.Services 6 | { 7 | public class QuizDBContext : DbContext 8 | { 9 | public QuizDBContext() 10 | { 11 | } 12 | public QuizDBContext(DbContextOptions options) : base(options) 13 | { 14 | } 15 | public virtual DbSet Candidate { get; set; } 16 | public virtual DbSet Exam { get; set; } 17 | public virtual DbSet Question { get; set; } 18 | public virtual DbSet Choice { get; set; } 19 | public virtual DbSet Answer { get; set; } 20 | public virtual DbSet Result { get; set; } 21 | 22 | protected override void OnModelCreating(ModelBuilder modelBuilder) 23 | { 24 | modelBuilder.Entity(eb => 25 | { 26 | eb.HasNoKey(); 27 | eb.ToView(null); 28 | }); 29 | 30 | modelBuilder.Entity(eb => 31 | { 32 | eb.HasNoKey(); 33 | eb.ToView(null); 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Base/CandidateService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Linq.Expressions; 6 | using Microsoft.EntityFrameworkCore; 7 | using Quiz_Application.Services.Entities; 8 | using Quiz_Application.Services.Repository.Interfaces; 9 | 10 | namespace Quiz_Application.Services.Repository.Base 11 | { 12 | public class CandidateService : ICandidate where TEntity : BaseEntity 13 | { 14 | private readonly QuizDBContext _dbContext; 15 | private DbSet _dbSet; 16 | public CandidateService(QuizDBContext dbContext) 17 | { 18 | _dbContext = dbContext; 19 | _dbSet = dbContext.Set(); 20 | } 21 | public async Task> GetCandidateList() 22 | { 23 | return await _dbSet.ToListAsync(); 24 | } 25 | public async Task GetCandidate(int id) 26 | { 27 | return await _dbSet.FindAsync(id); 28 | } 29 | 30 | public async Task> SearchCandidate(Expression> search = null) 31 | { 32 | IQueryable query=_dbSet; 33 | if (search != null) 34 | { 35 | query =query.Where(search); 36 | } 37 | return query; 38 | } 39 | 40 | public async Task AddCandidate(TEntity entity) 41 | { 42 | int output = 0; 43 | _dbSet.Add(entity); 44 | output = await _dbContext.SaveChangesAsync(); 45 | return output; 46 | } 47 | public async Task UpdateCandidate(TEntity entity) 48 | { 49 | int output = 0; 50 | _dbSet.Update(entity); 51 | output = await _dbContext.SaveChangesAsync(); 52 | return output; 53 | } 54 | public async Task DeleteCandidate(TEntity entity) 55 | { 56 | int output = 0; 57 | _dbSet.Remove(entity); 58 | output = await _dbContext.SaveChangesAsync(); 59 | return output; 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Base/ExamService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Linq.Expressions; 6 | using Microsoft.EntityFrameworkCore; 7 | using Quiz_Application.Services.Entities; 8 | using Quiz_Application.Services.Repository.Interfaces; 9 | 10 | namespace Quiz_Application.Services.Repository.Base 11 | { 12 | public class ExamService : IExam where TEntity : BaseEntity 13 | { 14 | private readonly QuizDBContext _dbContext; 15 | private DbSet _dbSet; 16 | public ExamService(QuizDBContext dbContext) 17 | { 18 | _dbContext = dbContext; 19 | _dbSet = dbContext.Set(); 20 | } 21 | public async Task> GetExamList() 22 | { 23 | return await _dbSet.ToListAsync(); 24 | } 25 | public async Task GetExam(int id) 26 | { 27 | return await _dbSet.FindAsync(id); 28 | } 29 | public async Task> SearchExam(Expression> search = null) 30 | { 31 | IQueryable query=_dbSet; 32 | if (search != null) 33 | { 34 | query =query.Where(search); 35 | } 36 | return query; 37 | } 38 | 39 | public async Task AddExam(TEntity entity) 40 | { 41 | int output = 0; 42 | _dbSet.Add(entity); 43 | output = await _dbContext.SaveChangesAsync(); 44 | return output; 45 | } 46 | 47 | public async Task UpdateExam(TEntity entity) 48 | { 49 | int output = 0; 50 | _dbSet.Update(entity); 51 | output = await _dbContext.SaveChangesAsync(); 52 | return output; 53 | } 54 | public async Task DeleteExam(TEntity entity) 55 | { 56 | int output = 0; 57 | _dbSet.Remove(entity); 58 | output = await _dbContext.SaveChangesAsync(); 59 | return output; 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Base/QuestionService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | using Microsoft.EntityFrameworkCore; 7 | using Quiz_Application.Services.Entities; 8 | using Quiz_Application.Services.Repository.Interfaces; 9 | 10 | namespace Quiz_Application.Services.Repository.Base 11 | { 12 | public class QuestionService : IQuestion where TEntity : BaseEntity 13 | { 14 | private readonly QuizDBContext _dbContext; 15 | private DbSet _dbSet; 16 | public QuestionService(QuizDBContext dbContext) 17 | { 18 | _dbContext = dbContext; 19 | _dbSet = dbContext.Set(); 20 | } 21 | 22 | public Task DeleteQuestion(TEntity entity) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | 27 | public async Task GetQuestionList(int ExamID) 28 | { 29 | QnA objQnA = null; 30 | AnswerDetails _objA = null; 31 | List _objQlst = new List(); 32 | string _examName = await _dbContext.Exam.Where(e => e.ExamID == ExamID).Select(o => o.Name).SingleOrDefaultAsync(); 33 | var questions = await _dbContext.Question.Where(q => q.ExamID == ExamID).ToListAsync(); 34 | foreach (var Qitem in questions) 35 | { 36 | List _objOlst = new List(); 37 | QuestionDetails _objQ = new QuestionDetails(); 38 | _objQ.QuestionID = Qitem.QuestionID; 39 | _objQ.QuestionType = Qitem.QuestionType; 40 | _objQ.QuestionText = Qitem.DisplayText; 41 | 42 | var options = await _dbContext.Choice.Where(q => q.QuestionID == Qitem.QuestionID).Select(o => new { OptionID = o.ChoiceID, Option = o.DisplayText }).ToListAsync(); 43 | 44 | foreach (var Oitem in options) 45 | { 46 | OptionDetails _objO = new OptionDetails() 47 | { 48 | OptionID=Oitem.OptionID, 49 | Option=Oitem.Option 50 | }; 51 | _objOlst.Add(_objO); 52 | } 53 | _objQ.options = _objOlst; 54 | 55 | var ans =await _dbContext.Answer.Where(q => q.QuestionID == Qitem.QuestionID).Select(o => new { AnswerID = o.Sl_No, OptionID = o.ChoiceID, Answer = o.DisplayText, }).FirstOrDefaultAsync(); 56 | 57 | _objA = new AnswerDetails() 58 | { 59 | AnswarID = ans.AnswerID, 60 | OptionID=ans.OptionID, 61 | Answar = ans.Answer 62 | }; 63 | _objQ.answer = _objA; 64 | 65 | _objQlst.Add(_objQ); 66 | } 67 | 68 | objQnA = new QnA() 69 | { 70 | ExamID = ExamID, 71 | Exam= _examName, 72 | questions = _objQlst 73 | }; 74 | return objQnA; 75 | } 76 | 77 | public Task AddQuestion(TEntity entity) 78 | { 79 | throw new NotImplementedException(); 80 | } 81 | 82 | public async Task> SearchQuestion(Expression> search = null) 83 | { 84 | IQueryable query = _dbSet; 85 | if (search != null) 86 | { 87 | query = query.Where(search); 88 | } 89 | return query; 90 | } 91 | 92 | public Task UpdateQuestion(TEntity entity) 93 | { 94 | throw new NotImplementedException(); 95 | } 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Base/ResultService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Linq.Expressions; 6 | using Microsoft.EntityFrameworkCore; 7 | using Quiz_Application.Services.Entities; 8 | using Quiz_Application.Services.Repository.Interfaces; 9 | using System.Text; 10 | 11 | namespace Quiz_Application.Services.Repository.Base 12 | { 13 | public class ResultService : IResult where TEntity : BaseEntity 14 | { 15 | private readonly QuizDBContext _dbContext; 16 | private DbSet _dbSet; 17 | public ResultService(QuizDBContext dbContext) 18 | { 19 | _dbContext = dbContext; 20 | _dbSet = dbContext.Set(); 21 | } 22 | public async Task AddResult(List entity) 23 | { 24 | int output = 0; 25 | _dbSet.AddRange(entity); 26 | output = await _dbContext.SaveChangesAsync(); 27 | return output; 28 | } 29 | public async Task> GetAttemptHistory(string argCandidateID) 30 | { 31 | try 32 | { 33 | List obj = await _dbContext.Set().FromSqlRaw(@"SELECT 34 | CAST(ROW_NUMBER() OVER (ORDER BY R.CreatedOn DESC) AS int) Sl_No, 35 | R.SessionID, 36 | R.ExamID, 37 | E.Name AS Exam, 38 | CONVERT(varchar, R.CreatedOn, 106) AS Date, 39 | (CAST(COUNT(R.Sl_No) as varchar(20)) + '/' + CAST(CAST(E.FullMarks AS INT) AS VARCHAR(20))) AS Score, 40 | CASE 41 | WHEN ((CAST(COUNT(R.Sl_No) AS decimal)/E.FullMarks *100) >50) THEN '1' 42 | ELSE '0' 43 | END AS 'Status' 44 | FROM Result R 45 | LEFT JOIN Exam E ON R.ExamID = E.ExamID 46 | WHERE R.CandidateID ='" + argCandidateID + "' AND R.IsCorrent = 1" 47 | +"GROUP BY R.SessionID, R.ExamID, E.Name, E.FullMarks, R.CreatedOn", argCandidateID).ToListAsync(); 48 | return obj; 49 | } 50 | catch (Exception ex) 51 | { 52 | throw new Exception(ex.Message, ex.InnerException); 53 | } 54 | finally 55 | { 56 | } 57 | } 58 | public async Task> ScoreReport(ReqReport argRpt) 59 | { 60 | try 61 | { 62 | List obj = await _dbContext.Set().FromSqlRaw(@"EXEC GetReport {0},{1},{2}", argRpt.ExamID, argRpt.CandidateID, argRpt.SessionID).ToListAsync(); 63 | return obj; 64 | } 65 | catch (Exception ex) 66 | { 67 | throw new Exception(ex.Message, ex.InnerException); 68 | } 69 | finally 70 | { 71 | } 72 | } 73 | public async Task GetCertificateString(ReqCertificate argRpt) 74 | { 75 | Candidate _candidate =await _dbContext.Candidate.Where(e => e.Candidate_ID == argRpt.CandidateID.ToString()).FirstOrDefaultAsync(); 76 | 77 | try 78 | { 79 | string cert =null; 80 | cert= @" 81 | 82 | 124 | 125 | 126 |
127 |

128 | avatar 129 |


130 | Certificate of Completion 131 |

132 | This is to certify that 133 |

"+ _candidate.Name + @"
134 |
has successfully completed the certification 135 |

"+argRpt.Exam+@"

136 | with score of "+argRpt.Score+@" 137 |


138 | dated
"+argRpt.Date+@" 139 |
140 |
141 | 142 | "; 143 | return cert.ToString(); 144 | } 145 | catch (Exception ex) 146 | { 147 | throw new Exception(ex.Message, ex.InnerException); 148 | } 149 | finally 150 | { 151 | } 152 | } 153 | 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Interfaces/ICandidate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | 7 | namespace Quiz_Application.Services.Repository.Interfaces 8 | { 9 | public interface ICandidate 10 | { 11 | Task> GetCandidateList(); 12 | Task GetCandidate(int id); 13 | Task> SearchCandidate(Expression> search = null); 14 | Task AddCandidate(TEntity entity); 15 | Task UpdateCandidate(TEntity entity); 16 | Task DeleteCandidate(TEntity entity); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Interfaces/IExam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | 7 | namespace Quiz_Application.Services.Repository.Interfaces 8 | { 9 | public interface IExam 10 | { 11 | Task> GetExamList(); 12 | Task GetExam(int id); 13 | Task> SearchExam(Expression> search = null); 14 | Task AddExam(TEntity entity); 15 | Task UpdateExam(TEntity entity); 16 | Task DeleteExam(TEntity entity); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Interfaces/IQuestion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | using Quiz_Application.Services.Entities; 7 | 8 | namespace Quiz_Application.Services.Repository.Interfaces 9 | { 10 | public interface IQuestion 11 | { 12 | Task GetQuestionList(int ExamID); 13 | Task> SearchQuestion(Expression> search = null); 14 | Task AddQuestion(TEntity entity); 15 | Task UpdateQuestion(TEntity entity); 16 | Task DeleteQuestion(TEntity entity); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Quiz-Application.Services/Repository/Interfaces/IResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | using Quiz_Application.Services.Entities; 7 | 8 | namespace Quiz_Application.Services.Repository.Interfaces 9 | { 10 | public interface IResult 11 | { 12 | Task> GetAttemptHistory(string argCandidateID); 13 | Task> ScoreReport(ReqReport argRpt); 14 | Task AddResult(List entity); 15 | Task GetCertificateString(ReqCertificate argRpt); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Quiz-Application.Services/ServiceCollectionExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Quiz_Application.Services.Repository.Interfaces; 9 | using Quiz_Application.Services.Repository.Base; 10 | 11 | 12 | namespace Quiz_Application.Services 13 | { 14 | public static class ServiceCollectionExtension 15 | { 16 | public static IServiceCollection AddServices(this IServiceCollection services) 17 | { 18 | return services 19 | .AddScoped, CandidateService>() 20 | .AddScoped, ExamService>() 21 | .AddScoped, QuestionService>() 22 | .AddScoped, ResultService>(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Quiz-Application.Web/Authentication/BasicAuthentication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.AspNetCore.Mvc.Filters; 9 | using Microsoft.AspNetCore.Routing; 10 | 11 | namespace Quiz_Application.Web.Authentication 12 | { 13 | public class BasicAuthentication : ActionFilterAttribute 14 | { 15 | public override void OnActionExecuting(ActionExecutingContext context) 16 | { 17 | string value = Convert.ToString(context.HttpContext.Session.GetString("AuthenticatedUser")); 18 | if (ReferenceEquals(value, null)) 19 | { 20 | context.Result = new RedirectToRouteResult(new RouteValueDictionary { { "Controller", "Account" }, { "Action", "Login" } }); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Quiz-Application.Web/Controllers/ExamController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.Extensions.Logging; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Quiz_Application.Web.Authentication; 9 | using Quiz_Application.Services.Entities; 10 | using Quiz_Application.Web.Models; 11 | using Quiz_Application.Services.Repository.Interfaces; 12 | 13 | 14 | namespace Quiz_Application.Web.Controllers 15 | { 16 | [BasicAuthentication] 17 | public class ExamController : Controller 18 | { 19 | private readonly ILogger _logger; 20 | private readonly IExam _exam; 21 | private readonly IQuestion _question; 22 | private readonly IResult _result; 23 | public ExamController(ILogger logger, IExam exam, IQuestion question, IResult result) 24 | { 25 | _logger = logger; 26 | _exam = exam; 27 | _question = question; 28 | _result = result; 29 | } 30 | 31 | [HttpGet] 32 | [Route("~/api/Exams")] 33 | public async Task Exams() 34 | { 35 | try 36 | { 37 | IEnumerable lst = await _exam.GetExamList(); 38 | return Ok(lst.ToList()); 39 | } 40 | catch (Exception ex) 41 | { 42 | throw new Exception(ex.Message, ex.InnerException); 43 | } 44 | finally 45 | { 46 | } 47 | } 48 | 49 | [HttpGet] 50 | [Route("~/api/Exam/{ExamID?}")] 51 | public async Task Exam(int ExamID) 52 | { 53 | try 54 | { 55 | Exam exm = await _exam.GetExam(ExamID); 56 | return Ok(exm); 57 | } 58 | catch (Exception ex) 59 | { 60 | throw new Exception(ex.Message, ex.InnerException); 61 | } 62 | finally 63 | { 64 | } 65 | } 66 | 67 | [HttpGet] 68 | [Route("~/api/Questions/{ExamID?}")] 69 | public async Task Questions(int ExamID) 70 | { 71 | try 72 | { 73 | QnA _obj = await _question.GetQuestionList(ExamID); 74 | return Ok(_obj); 75 | } 76 | catch (Exception ex) 77 | { 78 | throw new Exception(ex.Message, ex.InnerException); 79 | } 80 | finally 81 | { 82 | } 83 | } 84 | 85 | [HttpPost] 86 | [Route("~/api/Score")] 87 | public async Task Score(List