pub async fn api_view_specific_synchronous_task(
    class_id: i32,
    task_id: i32,
    auth: AuthCookie,
    conn: Database,
) -> Json<ApiResponse<ViewSpecificSyncTaskApiRes>> {
    let role = if let Some(role) = get_user_role_in_class(auth.0, class_id, &conn).await {
        role
    } else {
        return Json(From::from(LovelaceError::PermissionError));
    };
    Json(match role {
        crate::class::ClassMemberRole::Teacher => {
            let (task, student_tasks) =
                match get_teacher_sync_task_summary(task_id, class_id, auth.0, &conn).await {
                    Ok(t) => t,
                    Err(e) => return Json(From::from(e)),
                };
            ApiResponse::new_ok(ViewSpecificSyncTaskApiRes::Teacher(
                TeacherViewSyncTaskRes {
                    task,
                    student_tasks: student_tasks
                        .into_iter()
                        .map(|(user, task)| StudentTask { user, task })
                        .collect(),
                },
            ))
        }
        crate::class::ClassMemberRole::Student => {
            let (task, student_task) =
                match get_student_sync_task_summary(task_id, class_id, auth.0, &conn).await {
                    Ok(t) => t,
                    Err(e) => return Json(From::from(e)),
                };
            ApiResponse::new_ok(ViewSpecificSyncTaskApiRes::Student(
                StudentViewSyncTaskRes { task, student_task },
            ))
        }
    })
}
/// Retrieve information about a specific synchronous task.
Retrieve information about a specific synchronous task.
Retrieve information about a specific synchronous task .
pub async fn api_view_specific_synchronous_task(
    class_id: i32,
    task_id: i32,
    auth: AuthCookie,
    conn: Database,
) -> Json<ApiResponse<ViewSpecificSyncTaskApiRes>> {
    let role = if let Some(role) = get_user_role_in_class(auth.0, class_id, &conn).await {
        role
    } else {
        return Json(From::from(LovelaceError::PermissionError));
    };
    Json(match role {
        crate::class::ClassMemberRole::Teacher => {
            let (task, student_tasks) =
                match get_teacher_sync_task_summary(task_id, class_id, auth.0, &conn).await {
                    Ok(t) => t,
                    Err(e) => return Json(From::from(e)),
                };
            ApiResponse::new_ok(ViewSpecificSyncTaskApiRes::Teacher(
                TeacherViewSyncTaskRes {
                    task,
                    student_tasks: student_tasks
                        .into_iter()
                        .map(|(user, task)| StudentTask { user, task })
                        .collect(),
                },
            ))
        }
        crate::class::ClassMemberRole::Student => {
            let (task, student_task) =
                match get_student_sync_task_summary(task_id, class_id, auth.0, &conn).await {
                    Ok(t) => t,
                    Err(e) => return Json(From::from(e)),
                };
            ApiResponse::new_ok(ViewSpecificSyncTaskApiRes::Student(
                StudentViewSyncTaskRes { task, student_task },
            ))
        }
    })
}
pub async fn api_view_specific_synchronous_task ( class_id : i32 , task_id : i32 , auth : AuthCookie , conn : Database , ) -> Json < ApiResponse < ViewSpecificSyncTaskApiRes > > { let role = if let Some ( role ) = get_user_role_in_class ( auth . 0 , class_id , & conn ) . await { role } else { return Json ( From :: from ( LovelaceError :: PermissionError ) ) ; } ; Json ( match role { crate :: class :: ClassMemberRole :: Teacher => { let ( task , student_tasks ) = match get_teacher_sync_task_summary ( task_id , class_id , auth . 0 , & conn ) . await { Ok ( t ) => t , Err ( e ) => return Json ( From :: from ( e ) ) , } ; ApiResponse :: new_ok ( ViewSpecificSyncTaskApiRes :: Teacher ( TeacherViewSyncTaskRes { task , student_tasks : student_tasks . into_iter ( ) . map ( | ( user , task ) | StudentTask { user , task } ) . collect ( ) , } , ) ) } crate :: class :: ClassMemberRole :: Student => { let ( task , student_task ) = match get_student_sync_task_summary ( task_id , class_id , auth . 0 , & conn ) . await { Ok ( t ) => t , Err ( e ) => return Json ( From :: from ( e ) ) , } ; ApiResponse :: new_ok ( ViewSpecificSyncTaskApiRes :: Student ( StudentViewSyncTaskRes { task , student_task } , ) ) } } ) }
Retrieve information about a specific synchronous task.
Retrieve information about a specific synchronous task .
class_id
i32
task_id
i32
auth
AuthCookie
conn
Database