-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#125 Tutor queue panel with demo functions
- Loading branch information
Showing
5 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
admin/src/main/java/org/dcsc/admin/controllers/tutoring/TutoringOfficeHourController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.dcsc.admin.controllers.tutoring; | ||
|
||
import org.dcsc.admin.dto.QueueSummary; | ||
import org.dcsc.admin.dto.TutorQueueRefreshSummary; | ||
import org.dcsc.core.course.AcademicCourse; | ||
import org.dcsc.core.time.AcademicTermService; | ||
import org.dcsc.core.tutor.Tutor; | ||
import org.dcsc.core.tutor.TutorService; | ||
import org.dcsc.core.user.DcscUser; | ||
import org.dcsc.core.user.details.DcscUserDetails; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.messaging.handler.annotation.MessageMapping; | ||
import org.springframework.messaging.simp.annotation.SendToUser; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.stereotype.Controller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
|
||
@Controller | ||
public class TutoringOfficeHourController { | ||
@Autowired | ||
private TutorService tutorService; | ||
@Autowired | ||
private AcademicTermService academicTermService; | ||
|
||
@MessageMapping("/tutor/queue/refresh") | ||
@SendToUser("/queue/office-hour") | ||
public TutorQueueRefreshSummary courseQueueRefresh(Authentication authentication) throws Exception { | ||
DcscUserDetails userDetails = (DcscUserDetails) authentication.getPrincipal(); | ||
DcscUser dcscUser = userDetails.getUser(); | ||
|
||
Tutor tutor = tutorService.getTutor(dcscUser); | ||
|
||
// Demo code | ||
List<QueueSummary> summaries = new ArrayList<>(); | ||
List<AcademicCourse> courses = tutor.getCourses(academicTermService.getCurrentTerm().getCode()); | ||
for (AcademicCourse course : courses) { | ||
QueueSummary summary = new QueueSummary(course.getCode(), ThreadLocalRandom.current().nextInt(0, 19)); | ||
summaries.add(summary); | ||
} | ||
|
||
return new TutorQueueRefreshSummary(summaries); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.dcsc.admin.dto; | ||
|
||
public class QueueSummary { | ||
private String course; | ||
private int size; | ||
|
||
public QueueSummary() { | ||
|
||
} | ||
|
||
public QueueSummary(String course, int size) { | ||
this.course = course; | ||
this.size = size; | ||
} | ||
|
||
public String getCourse() { | ||
return course; | ||
} | ||
|
||
public void setCourse(String course) { | ||
this.course = course; | ||
} | ||
|
||
public int getSize() { | ||
return size; | ||
} | ||
|
||
public void setSize(int size) { | ||
this.size = size; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
admin/src/main/java/org/dcsc/admin/dto/TutorQueueRefreshSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.dcsc.admin.dto; | ||
|
||
import java.util.List; | ||
|
||
public class TutorQueueRefreshSummary { | ||
List<QueueSummary> summaries; | ||
|
||
public TutorQueueRefreshSummary(List<QueueSummary> summaries) { | ||
this.summaries = summaries; | ||
} | ||
|
||
public List<QueueSummary> getSummaries() { | ||
return summaries; | ||
} | ||
|
||
public void setSummaries(List<QueueSummary> summaries) { | ||
this.summaries = summaries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule resources
updated
from fbda0f to 79465e