示例#1
0
void Expectations::updateExp()
{
    if (expSelect_->currentIndex() == 0)
    {
        exp_ = new Expectation;
        return;
    }

    // Maj de l'exp courant
    Student* student = UTManager::instance().student();

    for (int i = 0; i < student->exp().size(); i++)
    {
        if (expSelect_->currentText() == student->exp().at(i)->name())
            exp_ = student->exp().at(i);
    }
}
示例#2
0
void Expectations::updateExpComboBox()
{
    expSelect_->clear();

    Student* student = UTManager::instance().student();
    if(!student)
        return;

    const QList<Expectation*> &exp = student->exp();
    for(int i = 0; i < exp.size(); i++)
    {
        expSelect_->addItem(exp.at(i)->name());
    }

    expSelect_->insertItem(0,"Nouvelle prévision");
    expSelect_->setCurrentIndex(0);

    createExpPanel();
}
void XmlDataPersistance::saveStudents()
{
    QFile file(studentsFilePath_);
    if(!file.open(QIODevice::ReadWrite|QIODevice::Truncate))
    {
        //throw UTProfilerException("Failed to open " + fileName + " in UVManager::save.");
        qDebug() << "Failed to open " << uvsFilePath_ << " in save";
        return;
    }

    QDomDocument dom;
    dom.setContent(&file);

    QDomElement students = dom.createElement("etudiants");
    dom.appendChild(students);

    // Students
    for(int i = 0; i < students_.size(); i++)
    {
        Student* student = students_.at(i);

        QDomElement studentElement = dom.createElement("etudiant");

        QDomElement login = dom.createElement("login");
        login.appendChild(dom.createTextNode(student->login()));
        studentElement.appendChild(login);

        QDomElement prenom = dom.createElement("prenom");
        prenom.appendChild(dom.createTextNode(student->firstName()));
        studentElement.appendChild(prenom);

        QDomElement nom = dom.createElement("nom");
        nom.appendChild(dom.createTextNode(student->lastName()));
        studentElement.appendChild(nom);

        // Degrees
        for (int i = 0; i < student->degrees().size(); i++)
        {
            QDomElement degree = dom.createElement("cursus");
            degree.appendChild(dom.createTextNode(student->degrees()[i]->title()));
            studentElement.appendChild(degree);
        }

        // Semesters
        for (int i = 0; i < student->semesters().size(); i++)
        {
            QDomElement semester = dom.createElement("semestre");

            QDomElement title = dom.createElement("titre");
            title.appendChild(dom.createTextNode(student->semesters()[i]->title()));
            semester.appendChild(title);

            // Uvs
            QMapIterator<QString, Grade> it(student->semesters()[i]->uvs());
            while (it.hasNext()) {
                it.next();

                QDomElement uv = dom.createElement("uv");

                QDomElement code = dom.createElement("code");
                code.appendChild(dom.createTextNode(it.key()));
                uv.appendChild(code);

                QDomElement grade = dom.createElement("note");
                grade.appendChild(dom.createTextNode(Uv::gradeToString(it.value())));
                uv.appendChild(grade);

                semester.appendChild(uv);
            }

            studentElement.appendChild(semester);
        }

        // Equivalences
        QMapIterator<QString,unsigned int> it(student->equivalences());
        while(it.hasNext())
        {
            it.next();
            QDomElement eqElem = dom.createElement("equivalence");
            eqElem.setAttribute("categorie",it.key());
            eqElem.appendChild(dom.createTextNode(QString::number(it.value())));
            studentElement.appendChild(eqElem);
        }

        // Previsions
        for (int i = 0; i < student->exp().size(); i++)
        {
            QDomElement exp = dom.createElement("prevision");

            QDomElement name = dom.createElement("nom");
            name.appendChild(dom.createTextNode(student->exp().at(i)->name()));
            exp.appendChild(name);

            for (int j = 0; j < student->exp().at(i)->degrees().size(); j++)
            {
                QDomElement degree = dom.createElement("cursus");
                degree.appendChild(dom.createTextNode(student->exp().at(i)->degrees().at(j)->title()));
                exp.appendChild(degree);
            }
            for (int j = 0; j < student->exp().at(i)->rejectedUvs().size(); j++)
            {
                QDomElement rejectedUv = dom.createElement("uvRejete");
                rejectedUv.appendChild(dom.createTextNode(student->exp().at(i)->rejectedUvs().at(j)->code()));
                exp.appendChild(rejectedUv);
            }

            for (int j = 0; j < student->exp().at(i)->requiredUvs().size(); j++)
            {
                QDomElement requiredUv = dom.createElement("uvRequise");
                requiredUv.appendChild(dom.createTextNode(student->exp().at(i)->requiredUvs().at(j)->code()));
                exp.appendChild(requiredUv);
            }

            for (int j = 0; j < student->exp().at(i)->semesters().size(); j++)
            {
                QDomElement semester = dom.createElement("semestre");

                QDomElement title = dom.createElement("titre");
                title.appendChild(dom.createTextNode(student->exp().at(i)->semesters().at(j)->title()));
                semester.appendChild(title);

                // Uvs
                QMapIterator<QString, Grade> it(student->exp().at(i)->semesters().at(j)->uvs());
                while (it.hasNext()) {
                    it.next();

                    QDomElement uv = dom.createElement("uv");
                    uv.appendChild(dom.createTextNode(it.key()));

                    semester.appendChild(uv);
                }

                exp.appendChild(semester);
            }

            studentElement.appendChild(exp);
        }

        students.appendChild(studentElement);
    }

    file.write(dom.toByteArray());
    file.close();
}