<h1>Student Progress Report</h1>
<!--
<button (click)='clicked()' type="button" class="btn btn-primary">Left</button> -->
<div class="container" style="padding:80px; display: inline; margin: 300px;">
<select name="Class" id="Class" [(ngModel)]="selectedClass">
<option *ngFor="let clas of classes" [value]="clas.Id">
{{clas.Name}}
</option>
</select>
<select name="Class" required id="Level" [(ngModel)]="selectedLevel ">
<!-- <option value="selected">select</option> -->
<option *ngFor="let lev of levels" [value]="lev.Name">
{{lev.Name}}
</option>
</select>
<button (click)="clicked()" type="button" class="btn btn-primary" style="padding: 1px; margin: auto;">Get
Report</button>
</div>
<div class="container mt-5">
<table class="table table-striped">
<thead>
<tr>
<th (click)="sortTable()">studentName </th>
<th>rank</th>
<th>peformanceLevel</th>
<th>mid1Score</th>
<th>mid2score</th>
<th [hidden]='ishidden'>finalscore</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let Student of students">
<td>{{ Student.studentName }}</td>
<td>{{ Student.rank }}</td>
<td>{{ Student.peformanceLevel }}</td>
<td>{{ Student.mid1Score }}</td>
<td>{{ Student.mid2score }}</td>
<td [hidden]='ishidden'>{{ Student.finalscore }}</td>
</tr>
</tbody>
</table>
<button (click)="hideit()" type="button" class="btn btn-primary" style="padding: 1px; margin: auto;">>
</button>
<button (click)="unhideit()" type="button" class="btn btn-primary" style="padding: 1px; margin: auto;"><
</button>
</div>
import { Component, HostListener, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
interface Student{
studentName: String;
rank: number;
peformanceLevel: String;
mid1Score: number;
mid2score:number;
finalscore:number;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
// title = 'ict';
classes!: { Id: number; Name: string; }[];
levels!: { Id: number; Name: string; }[];
ngOnInit(): void {
this.classes=[
{Id:0,Name:"class6"},
{Id:1,Name:"class7"},
{Id:2,Name:"class8"},
{Id:3,Name:"class9"},
{Id:4,Name:"class10"},
]
this.levels=[
{Id:0,Name:"all-level"},
{Id:1,Name:"Below-level"},
{Id:2,Name:"On-Level"},
{Id:3,Name:"Above-level"},
]
this.selectedClass=0;
this.selectedLevel='';
}
name = 'AngularIct';
classesObj={
'0':
[
{
studentName: "Abdullah",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 468,
mid2score: 581,
finalscore: 563,
},
{
studentName: "Rakesh",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 345,
mid2score: 346,
finalscore: 466,
},
{
studentName: "raju",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 456,
mid2score: 476,
finalscore: 436,
},
{
studentName: "kavin",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 458,
mid2score: 501,
finalscore: 569,
},
{
studentName: "bhanu teja",
rank: 1,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 567,
mid2score: 561,
finalscore: 59,
},
{
studentName: "Rohith",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 445,
mid2score: 555,
finalscore: 567,
},
{
studentName: "vandana",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "teju",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
},
],
'1':[
{
studentName: "vandu",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "yogesh",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "nav",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
},
{
studentName: "swetha",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "bhanu teja",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "kavin",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "gambir",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "bhanu",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
}
],
'2':[
{
studentName: "teja",
rank: 1,
peformanceLevel:
"Above-Level " + '' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "aarni",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "sudeer",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
},
{
studentName: "sandeep",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "vand",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "shruthi",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "teju",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
}
],
'3':[
{
studentName: "gani",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "ravi",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "mourish",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
},
{
studentName: "warner",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "pavan",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "lokesh",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "chandra",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
}
],
'4':[
{
studentName: "viany",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "teju",
rank: 2,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 368,
mid2score: 369,
finalscore: 401,
},
{
studentName: "mani",
rank: 3,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 234,
mid2score: 326,
finalscore: 289,
},
{
studentName: "vijay",
rank: 1,
peformanceLevel:
"Above-Level " + ' ' + " 85%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "Mira",
rank: 1,
peformanceLevel:
"Below-Level " + ' ' + " 55%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
},
{
studentName: "zaheer",
rank: 1,
peformanceLevel:
"On-Level " + ' ' + " 65%",
mid1Score: 498,
mid2score: 501,
finalscore: 499,
}
]
}
students=this.classesObj[0]
public selectedClass!: number;
public selectedLevel!: string;
clicked(){
if(this.selectedLevel[0]=="a"){
this.students=this.classesObj[this.selectedClass]
console.log(this.selectedClass);
}
else{
this.students=[];
for(var i=0;i<this.classesObj[this.selectedClass].length;i++){
if(this.classesObj[this.selectedClass][i].peformanceLevel[0]==this.selectedLevel[0]){
this.students.push(this.classesObj[this.selectedClass][i]);
}
}
}
}
dynamicsort(property, order) {
var sort_order = 1;
if (order === "desc") {
sort_order = -1;
}
return function (a, b) {
// a should come before b in the sorted order
if (a[property] < b[property]) {
return -1 * sort_order;
// a should come after b in the sorted order
} else if (a[property] > b[property]) {
return 1 * sort_order;
// a and b are the same
} else {
return 0 * sort_order;
}
}
}
order = true;
sortTable(){
// console.log('clicked');
let tempOrder;
if (this.order) {
tempOrder = 'asc';
} else {
tempOrder = 'desc';
}
this.students = this.students.sort(this.dynamicsort('studentName', tempOrder));
this.order=!this.order;
}
ishidden=false;
hideit(){
this.ishidden=true;
console.log(this.getScreenHeight,this.getScreenWidth);
}
unhideit(){
this.ishidden=false;
}
getScreenWidth = window.innerWidth;
getScreenHeight = window.innerHeight;
@HostListener('window:resize', ['$event'])
onWindowResize() {
this.getScreenWidth = window.innerWidth;
this.getScreenHeight = window.innerHeight;
console.log('changed');
if(this.getScreenWidth<801){
this.ishidden=true;
}else{
this.ishidden=false;
}
}
};