示例#1
0
def checkMissingHWQ(server=None, pwd=None):
    if server and ":" in server:
        s, p = server.split(":")
        msgr = ScanMessenger(s, port=p)
    else:
        msgr = ScanMessenger(server)
    msgr.start()

    if not pwd:
        pwd = getpass.getpass("Please enter the 'scanner' password:"******"scanner", pwd)
    except PlomExistingLoginException as e:
        print(
            "You appear to be already logged in!\n\n"
            "  * Perhaps a previous session crashed?\n"
            "  * Do you have another scanner-script running,\n"
            "    e.g., on another computer?\n\n"
            'In order to force-logout the existing authorisation run "plom-scan clear"'
        )
        exit(10)

    missingHWQ = msgr.getMissingHW()
    msgr.closeUser()
    msgr.stop()

    return missingHWQ
示例#2
0
def whoSubmittedWhatOnServer(server, password):
    if server and ":" in server:
        s, p = server.split(":")
        msgr = ScanMessenger(s, port=p)
    else:
        msgr = ScanMessenger(server)
    msgr.start()

    # get the password if not specified
    if password is None:
        try:
            pwd = getpass.getpass("Please enter the 'scanner' password:"******"ERROR", error)
    else:
        pwd = password

    # get started
    try:
        msgr.requestAndSaveToken("scanner", pwd)
    except PlomExistingLoginException:
        print(
            "You appear to be already logged in!\n\n"
            "  * Perhaps a previous session crashed?\n"
            "  * Do you have another scanner-script running,\n"
            "    e.g., on another computer?\n\n"
            'In order to force-logout the existing authorisation run "plom-hwscan clear"'
        )
        exit(10)

    missingHWQ = msgr.getMissingHW()  # passes back dict
    completeHW = msgr.getCompleteHW()  # passes back list [test_number, sid]

    msgr.closeUser()
    msgr.stop()

    print(">> Checking incomplete submissions on server <<")
    print(
        "The following students have complete submissions (each question present)"
    )
    print(", ".join(sorted([x[1] for x in completeHW])))
    print(
        "The following students have incomplete submissions (missing questions indicated)"
    )
    for t in missingHWQ:
        print("{} missing {}".format(missingHWQ[t][1], missingHWQ[t][2:]))