pub async fn api_view_all_sync_tasks_in_class(
    class_id: i32,
    auth: AuthCookie,
    conn: Database,
) -> Json<ApiResponse<ViewAllSyncTasks>> {
    Json(
        if let Some(role) = get_user_role_in_class(auth.0, class_id, &conn).await {
            match role {
                crate::class::ClassMemberRole::Teacher => {
                    let tasks = match show_teacher_sync_tasks_summary(class_id, &conn).await {
                        Ok(t) => t,
                        Err(e) => return Json(e.into()),
                    };
                    ApiResponse::new_ok(ViewAllSyncTasks::Teacher(
                        tasks
                            .into_iter()
                            .map(|(task, user)| TeacherTask { task, user })
                            .collect(),
                    ))
                }
                crate::class::ClassMemberRole::Student => {
                    let tasks = match show_student_sync_tasks_summary(class_id, auth.0, &conn).await
                    {
                        Ok(t) => t,
                        Err(e) => return Json(e.into()),
                    };
                    ApiResponse::new_ok(ViewAllSyncTasks::Student(
                        tasks
                            .into_iter()
                            .map(|(student_task, task)| StudentTask { task, student_task })
                            .collect(),
                    ))
                }
            }
        } else {
            return Json(From::from(LovelaceError::PermissionError));
        },
    )
}
/// Show a list of all the synchronous tasks have been set in a class, either to a teacher or a
/// student (this is retrieved from the database).
Show a list of all the synchronous tasks have been set in a class, either to a teacher or a
student (this is retrieved from the database).
Show a list of all the synchronous tasks have been set in a class either to a teacher or a student ( this is retrieved from the database ) .
pub async fn api_view_all_sync_tasks_in_class(
    class_id: i32,
    auth: AuthCookie,
    conn: Database,
) -> Json<ApiResponse<ViewAllSyncTasks>> {
    Json(
        if let Some(role) = get_user_role_in_class(auth.0, class_id, &conn).await {
            match role {
                crate::class::ClassMemberRole::Teacher => {
                    let tasks = match show_teacher_sync_tasks_summary(class_id, &conn).await {
                        Ok(t) => t,
                        Err(e) => return Json(e.into()),
                    };
                    ApiResponse::new_ok(ViewAllSyncTasks::Teacher(
                        tasks
                            .into_iter()
                            .map(|(task, user)| TeacherTask { task, user })
                            .collect(),
                    ))
                }
                crate::class::ClassMemberRole::Student => {
                    let tasks = match show_student_sync_tasks_summary(class_id, auth.0, &conn).await
                    {
                        Ok(t) => t,
                        Err(e) => return Json(e.into()),
                    };
                    ApiResponse::new_ok(ViewAllSyncTasks::Student(
                        tasks
                            .into_iter()
                            .map(|(student_task, task)| StudentTask { task, student_task })
                            .collect(),
                    ))
                }
            }
        } else {
            return Json(From::from(LovelaceError::PermissionError));
        },
    )
}
pub async fn api_view_all_sync_tasks_in_class ( class_id : i32 , auth : AuthCookie , conn : Database , ) -> Json < ApiResponse < ViewAllSyncTasks > > { Json ( if let Some ( role ) = get_user_role_in_class ( auth . 0 , class_id , & conn ) . await { match role { crate :: class :: ClassMemberRole :: Teacher => { let tasks = match show_teacher_sync_tasks_summary ( class_id , & conn ) . await { Ok ( t ) => t , Err ( e ) => return Json ( e . into ( ) ) , } ; ApiResponse :: new_ok ( ViewAllSyncTasks :: Teacher ( tasks . into_iter ( ) . map ( | ( task , user ) | TeacherTask { task , user } ) . collect ( ) , ) ) } crate :: class :: ClassMemberRole :: Student => { let tasks = match show_student_sync_tasks_summary ( class_id , auth . 0 , & conn ) . await { Ok ( t ) => t , Err ( e ) => return Json ( e . into ( ) ) , } ; ApiResponse :: new_ok ( ViewAllSyncTasks :: Student ( tasks . into_iter ( ) . map ( | ( student_task , task ) | StudentTask { task , student_task } ) . collect ( ) , ) ) } } } else { return Json ( From :: from ( LovelaceError :: PermissionError ) ) ; } , ) }
Show a list of all the synchronous tasks have been set in a class, either to a teacher or a
student (this is retrieved from the database).
Show a list of all the synchronous tasks have been set in a class either to a teacher or a student ( this is retrieved from the database ) .
class_id
i32
auth
AuthCookie
conn
Database