本文整理汇总了PHP中Course::findMany方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::findMany方法的具体用法?PHP Course::findMany怎么用?PHP Course::findMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::findMany方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply_action
/**
* A person applies for a course.
*/
function apply_action()
{
$user_id = $GLOBALS['user']->id;
$courseset = CourseSet::getSetForCourse($this->course_id);
$this->course_name = PageLayout::getTitle();
if ($courseset) {
$errors = $courseset->checkAdmission($user_id, $this->course_id);
if (count($errors)) {
$this->courseset_message = $courseset->toString(true);
$this->admission_error = MessageBox::error(_("Die Anmeldung war nicht erfolgreich."), $errors);
foreach ($courseset->getAdmissionRules() as $rule) {
$admission_form .= $rule->getInput();
}
if ($admission_form) {
$this->admission_form = $admission_form;
}
} else {
if ($courseset->isSeatDistributionEnabled()) {
if ($courseset->hasAlgorithmRun()) {
if ($courseset->getSeatDistributionTime()) {
$msg = _("Die Plätze in dieser Veranstaltung wurden automatisch verteilt.");
}
if (StudipLock::get('enrolment' . $this->course_id)) {
$course = Course::find($this->course_id);
if ($course->getFreeSeats() && !$course->getNumWaiting()) {
$enrol_user = true;
} else {
if ($course->isWaitlistAvailable()) {
$seminar = new Seminar($course);
if ($seminar->addToWaitlist($user_id, 'last')) {
$msg_details[] = sprintf(_("Alle Plätze sind belegt, Sie wurden daher auf Platz %s der Warteliste gesetzt."), $maxpos);
}
} else {
$this->admission_error = MessageBox::error(_("Die Anmeldung war nicht erfolgreich. Alle Plätze sind belegt und es steht keine Warteliste zur Verfügung."));
}
}
} else {
$this->admission_error = MessageBox::error(_("Die Anmeldung war wegen technischer Probleme nicht erfolgreich. Bitte versuchen Sie es später noch einmal."));
}
} else {
$msg = _("Die Plätze in dieser Veranstaltung werden automatisch verteilt.");
if ($limit = $courseset->getAdmissionRule('LimitedAdmission')) {
$msg_details[] = sprintf(_("Diese Veranstaltung gehört zu einem Anmeldeset mit %s Veranstaltungen. Sie können maximal %s davon belegen. Bei der Verteilung werden die von Ihnen gewünschten Prioritäten berücksichtigt."), count($courseset->getCourses()), $limit->getMaxNumber());
$this->user_max_limit = $limit->getMaxNumberForUser($user_id);
if (get_config('IMPORTANT_SEMNUMBER')) {
$order = "ORDER BY VeranstaltungsNummer, Name";
} else {
$order = "ORDER BY Name";
}
$this->priocourses = Course::findMany($courseset->getCourses(), $order);
$this->user_prio = AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id);
$this->max_limit = $limit->getMaxNumber();
$this->prio_stats = AdmissionPriority::getPrioritiesStats($courseset->getId());
$this->already_claimed = count($this->user_prio);
} else {
$this->priocourses = Course::find($this->course_id);
$this->already_claimed = array_key_exists($this->course_id, AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id));
}
$msg_details[] = _("Zeitpunkt der automatischen Verteilung: ") . strftime("%x %X", $courseset->getSeatDistributionTime());
$this->num_claiming = count(AdmissionPriority::getPrioritiesByCourse($courseset->getId(), $this->course_id));
if ($this->already_claimed) {
$msg_details[] = _("Sie sind bereits für die Verteilung angemeldet.");
}
}
$this->courseset_message = MessageBox::info($msg, $msg_details);
} else {
$enrol_user = true;
}
}
} else {
$enrol_user = true;
}
if ($enrol_user) {
$course = Seminar::GetInstance($this->course_id);
if ($course->admission_prelim) {
if (!$course->isStudygroup() && $course->admission_prelim_txt && !Request::submitted('apply')) {
$this->admission_prelim_txt = $course->admission_prelim_txt;
$this->admission_prelim_comment = Config::get()->ADMISSION_PRELIM_COMMENT_ENABLE;
$this->admission_form = $this->render_template_as_string('course/enrolment/prelim');
} else {
if (Request::get('admission_comment')) {
$admission_comment = get_fullname() . ': ' . Request::get('admission_comment');
} else {
$admission_comment = '';
}
if ($course->addPreliminaryMember($user_id, $admission_comment)) {
if ($course->isStudygroup()) {
if (StudygroupModel::isInvited($user_id, $this->course_id)) {
// an invitation exists, so accept the join request automatically
$status = 'autor';
StudygroupModel::accept_user(get_username($user_id), $this->course_id);
StudygroupModel::cancelInvitation(get_username($user_id), $this->course_id);
$success = sprintf(_("Sie wurden in die Veranstaltung %s als %s eingetragen."), $course->getName(), get_title_for_status($status, 1));
PageLayout::postMessage(MessageBox::success($success));
} else {
$success = sprintf(_("Sie wurden auf die Anmeldeliste der Studiengruppe %s eingetragen. Die Moderatoren der Studiengruppe können Sie jetzt freischalten."), $course->getName());
PageLayout::postMessage(MessageBox::success($success));
//.........这里部分代码省略.........
示例2: applications_list_action
/**
* Gets the list of applicants for the courses belonging to this course set.
*
* @param String $set_id course set ID
* @param String $csv export users to file
*/
public function applications_list_action($set_id, $csv = null)
{
if (Request::isXhr()) {
$this->response->add_header('X-Title', _('Liste der Anmeldungen'));
}
$courseset = new CourseSet($set_id);
$applicants = AdmissionPriority::getPriorities($set_id);
$users = User::findMany(array_keys($applicants), 'ORDER BY Nachname');
$courses = SimpleCollection::createFromArray(Course::findMany($courseset->getCourses()));
$captions = array(_("Nachname"), _("Vorname"), _("Nutzername"), _("Veranstaltung"), _("Nummer"), _("Priorität"));
$data = array();
foreach ($users as $user) {
$row = array();
$app_courses = $applicants[$user->id];
asort($app_courses);
foreach ($app_courses as $course_id => $prio) {
$row = array();
$row[] = $user->nachname;
$row[] = $user->vorname;
$row[] = $user->username;
$row[] = $courses->findOneBy('id', $course_id)->name;
$row[] = $courses->findOneBy('id', $course_id)->veranstaltungsnummer;
$row[] = $prio;
if ($csv) {
$row[] = $user->email;
}
$data[] = $row;
}
}
if ($csv) {
$tmpname = md5(uniqid('tmp'));
$captions[] = _("Email");
if (array_to_csv($data, $GLOBALS['TMP_PATH'] . '/' . $tmpname, $captions)) {
$this->redirect(GetDownloadLink($tmpname, 'Anmeldungen_' . $courseset->getName() . '.csv', 4, 'force'));
return;
}
}
$this->captions = $captions;
$this->data = $data;
$this->set_id = $courseset->getId();
}
示例3: execute
public function execute($last_result, $parameters = array())
{
$verbose = $parameters['verbose'];
$sets = DbManager::get()->fetchFirst("SELECT DISTINCT cr.set_id FROM courseset_rule cr INNER JOIN coursesets USING(set_id)\n WHERE type = 'ParticipantRestrictedAdmission' AND algorithm_run = 0");
if (count($sets)) {
if ($verbose) {
echo date('r') . ' - Starting seat distribution ' . chr(10);
$old_logger = Log::get()->getHandler();
$old_log_level = Log::get()->getLogLevel();
@mkdir($GLOBALS['TMP_PATH'] . '/seat_distribution_logs');
$logfile = $GLOBALS['TMP_PATH'] . '/seat_distribution_logs/' . date('Y-m-d-H-i') . '_seat_distribution.log';
if (is_dir($GLOBALS['TMP_PATH'] . '/seat_distribution_logs')) {
Log::get()->setHandler($logfile);
Log::get()->setLogLevel(Log::DEBUG);
echo 'logging to ' . $logfile . chr(10);
} else {
echo 'could not create directory ' . $GLOBALS['TMP_PATH'] . '/seat_distribution_logs' . chr(10);
}
}
foreach ($sets as $set_id) {
$courseset = new CourseSet($set_id);
if ($courseset->isSeatDistributionEnabled() && !$courseset->hasAlgorithmRun() && $courseset->getSeatDistributionTime() < time()) {
if ($verbose) {
echo ++$i . ' ' . $courseset->getId() . ' : ' . $courseset->getName() . chr(10);
$applicants = AdmissionPriority::getPriorities($set_id);
$courses = SimpleCollection::createFromArray(Course::findMany($courseset->getCourses()))->toGroupedArray('seminar_id', words('name veranstaltungsnummer'));
$captions = array(_("Nachname"), _("Vorname"), _("Nutzername"), _('Nutzer-ID'), _('Veranstaltung-ID'), _("Veranstaltung"), _("Nummer"), _("Priorität"));
$data = array();
$users = User::findEachMany(function ($user) use($courses, $applicants, &$data) {
$app_courses = $applicants[$user->id];
asort($app_courses);
foreach ($app_courses as $course_id => $prio) {
$row = array();
$row[] = $user->nachname;
$row[] = $user->vorname;
$row[] = $user->username;
$row[] = $user->id;
$row[] = $course_id;
$row[] = $courses[$course_id]['name'];
$row[] = $courses[$course_id]['veranstaltungsnummer'];
$row[] = $prio;
$data[] = $row;
}
}, array_keys($applicants), 'ORDER BY Nachname');
$applicants_file = $GLOBALS['TMP_PATH'] . '/seat_distribution_logs/applicants_' . $set_id . '.csv';
if (array_to_csv($data, $applicants_file, $captions)) {
echo 'applicants written to ' . $applicants_file . chr(10);
}
}
$courseset->distributeSeats();
}
}
if ($verbose) {
Log::get()->setHandler($old_logger);
Log::get()->setLogLevel($old_log_level);
}
} else {
if ($verbose) {
echo date('r') . ' - Nothing to do' . chr(10);
}
}
}