[][src]Crate cms_tools

Examples:

  • Print list of people with highest number of fastest solutions
//make a client
let client = Client::new(String::from("Gemmady"));
let task_list = client.get_task_list(0, 1024, "", None, None).unwrap();
let mut hm = std::collections::HashMap::<String, u32>::new();
for i in task_list.tasks {
    let best = client.get_stats(&i.name).unwrap().best;
    if best.len() > 0 {
        let t = hm.entry(best[0].username.clone()).or_insert(0);
        *t += 1;
    }
}
let mut v: Vec<(u32, String)> = hm.iter().map(|x| (*x.1, x.0.clone())).collect();
v.sort();
for i in v.iter().rev() {
    println!("{} {}", i.1, i.0);
}
  • Resubmit all fastest solutions
let username = String::from("user");
let password = "password";
let mut client = Client::new(username.clone());
client.login(password).unwrap();
let user = client.get_user(&username).unwrap();
for sc in user.scores.unwrap() {
    if sc.score == 100.0 {
        println!("{} has score 100", sc.title);
        let sub_list = client.get_submission_list(&sc.name).unwrap();
        let best_sub = sub_list.get_fastest_high(&client).unwrap();
        let files = &best_sub.files;
        if files.len() == 1 { // if it is not an output-only
            let mut submitted: bool = false;
            print!("Resubmitting {}", sc.name.clone());
            while !submitted { // because cmsocial has a limit to submission rate
                print!(".");
                if client
                    .submit_normal(
                        &sc.name,
                        &client.get_file(&files[0]).unwrap(),
                        files[0].name.split(".").collect::<Vec<&str>>().last().unwrap(),
                    )
                    .is_ok()
                {
                    submitted = true;
                }
            }
            println!("");
        }
    }
}

Not implemented yet:

Structs

CheckResponse

Response for email and username checking

Client

Client you will do almost everything with

DetailedSubmission

Details of a specific submission

DetailedTask

Detailed task description

File

Description of a file

Institute

Institute of an user

Question

Question inside of a test

RecoverResponse

Responses for password recovery requests

Region

Region

RegionList

List of regions

Score

Score achieved on a certain task by someone

ScoreDetail

Score details for a specific submission

Stat

Best time by someone on some task

Statement

digest of statement file? apparently not

Stats

Stats of a certain task

Submission

Submission, not detailed

SubmissionList

List of submissions by a user for a task

Tag

tags, like technique or event tags

Task

Task in a TaskList

TaskList

List of tasks

TechniqueList

List of technique tags

Test

Test, also known as Quiz

TestHead

Basic informations of a test

TestList

List of Tests

Testcase

Outcome of a certain submission for a specific testcase

User

User info

UserList

List of users