Skip to content

Commit 102edc9

Browse files
committed
update
1 parent 06e6025 commit 102edc9

14 files changed

+43
-19
lines changed
Binary file not shown.
Loading
Loading
Loading
Loading
Loading

Website/javascript/material.js

-11
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ function createCard(cardTitle, description ,type, imgSrc, link) {
8484
}
8585

8686

87-
88-
89-
9087
function createAddMatirialCard() {
9188
const parentDiv = document.getElementById('main-material-div');
9289

@@ -140,14 +137,6 @@ function createAddMatirialCard() {
140137
}
141138

142139

143-
144-
145-
146-
147-
148-
149-
150-
151140

152141

153142
var materials = [

Website/javascript/weeks.js

+43-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,43 @@ var courseIdforcrearte = urlParams.get("id");
44
var domain = "https://localhost:44303/";
55

66
//test varables
7-
var userRole = "admin";
87

8+
function changee(inp) {
9+
userRole=inp;
10+
}
911
// -------------------------------------------------------------------- user info ---------------------------------------------------
12+
InfoUserOfAdmin();
13+
function InfoUserOfAdmin() {
14+
var formData = new FormData();
15+
formData.append("id", courseIdforcrearte);
16+
17+
var xhr = new XMLHttpRequest();
18+
xhr.open(
19+
"GET",
20+
"https://localhost:44303/api/User/GetRoles?CourceId=" + courseIdforcrearte
21+
);
22+
23+
var token = "Bearer " + localStorage.getItem("token");
24+
xhr.setRequestHeader("Authorization", token);
25+
26+
xhr.onreadystatechange = function () {
27+
if (xhr.readyState === 4) {
28+
if (xhr.status === 200) {
29+
console.log("Featch Week successfully");
30+
} else {
31+
console.log("Featch Week filed creating course");
32+
}
33+
}
34+
};
35+
xhr.send(formData);
36+
xhr.onload = function () {
37+
// convert to object
38+
var obj = JSON.parse(xhr.responseText);
39+
let Data = obj;
40+
userRole(Data);
41+
42+
};
43+
}
1044

1145

1246
function createWeeksCard(imgSrc, weekName, doctorName, lastUpdate, weekid) {
@@ -652,11 +686,12 @@ function PrintWeeks(obj) {
652686
});
653687
}
654688

655-
// createWeeksCard("imgSrc", "weekName", "doctorName", "lastUpdate", "weekid");
656689

657-
if (userRole == "admin") {
658-
addWeekButton();
659-
createAddWeeksCard();
660-
createAddTaskCard();
661-
displayAddAnnouncement();
662-
}
690+
function userRole(userRole) {
691+
if (userRole == 1 || userRole == 2) {
692+
addWeekButton();
693+
createAddWeeksCard();
694+
createAddTaskCard();
695+
displayAddAnnouncement();
696+
}
697+
}

0 commit comments

Comments
 (0)