Beispiel #1
0
function emarking_get_student_picture($student, $userimgdir)
{
    global $CFG, $DB;
    // Get the image file for student if user pictures are configured
    if ($studentimage = emarking_get_student_picture_path($student->idnumber) && file_exists($studentimage)) {
        return $studentimage;
    }
    // If no picture was found in the pictures repo try to use the
    // Moodle one or default on the anonymous
    $usercontext = context_user::instance($student->id);
    $imgfile = $DB->get_record('files', array('contextid' => $usercontext->id, 'component' => 'user', 'filearea' => 'icon', 'filename' => 'f1.png'));
    if ($imgfile) {
        return emarking_get_path_from_hash($userimgdir, $imgfile->pathnamehash, "u" . $student->id, true);
    } else {
        return $CFG->dirroot . "/pix/u/f1.png";
    }
}
Beispiel #2
0
        }
        echo "User {$user->id} updated its idnumber from {$previdnumber} to {$user->idnumber} \n";
        $fixed++;
    }
    if ($debug && $total > 10) {
        break;
    }
}
echo "Finished fixing id numbers, {$total} students found, {$fixed} fixed.\n";
// Second we check if the user picture is downloaded
$total = 0;
$fixed = 0;
foreach ($usuariosOmega as $email => $usuario) {
    $total++;
    // Check if the picture is already downloaded
    $picturefilename = emarking_get_student_picture_path($usuario['rut']);
    if ($debug) {
        echo "{$picturefilename} \n";
    }
    if ($picturefilename && !file_exists($picturefilename)) {
        $url = "https://omega.uai.cl/WebForms/Tools/LoadPersonaPicture.aspx?personaId=" . $usuario['idomega'];
        echo "Missing picture {$picturefilename}, downloading: {$url} \n";
        // download_image_url($url, "/tmp/".$usuario['idomega'].".png");
        if (!$debug) {
            echo "Moving /tmp/" . $usuario['idomega'] . ".png a {$picturefilename}\n";
        }
        $fixed++;
    }
    if ($debug && $total > 10) {
        break;
    }