Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
463 changes: 463 additions & 0 deletions contracts/teachlink/src/assessment.rs

Large diffs are not rendered by default.

113 changes: 109 additions & 4 deletions contracts/teachlink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@
#![allow(clippy::trivially_copy_pass_by_ref)]
#![allow(clippy::needless_borrow)]

use soroban_sdk::{contract, contractimpl, Address, Bytes, Env, Map, String, Vec};
use soroban_sdk::{contract, contractimpl, Address, Bytes, Env, Map, String, Vec, Symbol};

mod analytics;
mod arbitration;
mod assessment;
mod atomic_swap;
mod audit;
mod bft_consensus;
Expand All @@ -110,7 +111,7 @@ mod notification_types;
mod rewards;
mod slashing;
// mod social_events;
// mod social_learning;
mod social_learning;
mod storage;
mod tokenization;
mod types;
Expand All @@ -128,6 +129,7 @@ pub use types::{
TransferType, UserNotificationSettings, UserReputation, UserReward, ValidatorInfo,
ValidatorReward, ValidatorSignature,
};
pub use assessment::{Assessment, AssessmentSettings, AssessmentSubmission, Question, QuestionType};

/// TeachLink main contract.
///
Expand All @@ -136,7 +138,6 @@ pub use types::{
#[contract]
pub struct TeachLinkBridge;

/*
#[contractimpl]
impl TeachLinkBridge {
/// Initialize the bridge contract
Expand Down Expand Up @@ -759,6 +760,111 @@ impl TeachLinkBridge {
rewards::Rewards::get_rewards_admin(&env)
}

// ========== Assessment and Testing Platform Functions ==========

/// Create a new assessment
pub fn create_assessment(
env: Env,
creator: Address,
title: Bytes,
description: Bytes,
questions: Vec<u64>,
settings: AssessmentSettings,
) -> Result<u64, assessment::AssessmentError> {
assessment::AssessmentManager::create_assessment(
&env,
creator,
title,
description,
questions,
settings,
)
}

/// Add a question to the pool
pub fn add_assessment_question(
env: Env,
creator: Address,
q_type: QuestionType,
content_hash: Bytes,
points: u32,
difficulty: u32,
correct_answer_hash: Bytes,
metadata: Map<Symbol, Bytes>,
) -> Result<u64, assessment::AssessmentError> {
assessment::AssessmentManager::add_question(
&env,
creator,
q_type,
content_hash,
points,
difficulty,
correct_answer_hash,
metadata,
)
}

/// Submit an assessment
pub fn submit_assessment(
env: Env,
student: Address,
assessment_id: u64,
answers: Map<u64, Bytes>,
proctor_logs: Vec<Bytes>,
) -> Result<u32, assessment::AssessmentError> {
assessment::AssessmentManager::submit_assessment(
&env,
student,
assessment_id,
answers,
proctor_logs,
)
}

/// Get assessment details
pub fn get_assessment(env: Env, id: u64) -> Option<Assessment> {
assessment::AssessmentManager::get_assessment(&env, id)
}

/// Get user submission
pub fn get_assessment_submission(
env: Env,
student: Address,
assessment_id: u64,
) -> Option<AssessmentSubmission> {
assessment::AssessmentManager::get_submission(&env, student, assessment_id)
}

/// Report a proctoring violation
pub fn report_proctor_violation(
env: Env,
student: Address,
assessment_id: u64,
violation_type: Bytes,
) -> Result<(), assessment::AssessmentError> {
assessment::AssessmentManager::report_proctoring_violation(
&env,
student,
assessment_id,
violation_type,
)
}

/// Get next adaptive question
pub fn get_next_adaptive_question(
env: Env,
id: u64,
scores: Vec<u32>,
answered_ids: Vec<u64>,
) -> Result<u64, assessment::AssessmentError> {
assessment::AssessmentManager::get_next_adaptive_question(
&env,
id,
scores,
answered_ids,
)
}

// ========== Escrow Functions ==========

/// Create a multi-signature escrow
Expand Down Expand Up @@ -1377,4 +1483,3 @@ impl TeachLinkBridge {
// Analytics function removed due to contracttype limitations
// Use internal notification manager for analytics
}
*/
Loading
Loading