void AddIndvAssignmentDialog::addAssignment()
{
	QString assignName(boxOne->text());
	QString pointValue(boxTwo->text());
	QString earnedPoints(earnedPointsBox->text());

	std::string assignNameStr(assignName.toAscii());
	double pointValueDouble(pointValue.toDouble());
	double earnedPointsDouble(earnedPoints.toDouble());

	if(assignNameStr == "INVALID ASSIGNMENT")
	{
		QMessageBox *messageBox = new QMessageBox(this);
		messageBox->setText("You cannot name an assignment \"INVALID ASSIGNMENT\"");
		messageBox->exec();
		boxOne->clear();
		boxTwo->clear();
		return;
	}

	Assignment newAssignment(pointValueDouble, earnedPointsDouble, assignNameStr);

	messageWin->setWindowTitle("Confirmation");
	if(student->addAssignment(newAssignment))
	{
		messageWin->setText("Assignment added!");
		emit assignmentAdded();
	}
	else
	{
		messageWin->setText("Assignment was not added successfully.");
	}
	messageWin->exec();
	close();
}
void EditIndvAssignmentDialog::editAssignment()
{
	// Get the current values of each input box as a QString
	QString assignName(boxOne->text());
	QString pointValue(boxTwo->text());
	QString earnedPoints(earnedPointsBox->text());

	// Convert the QString values to useable data types
	std::string assignNameStr(assignName.toAscii());
	double pointValueDouble(pointValue.toDouble());
	double earnedPointsDouble(earnedPoints.toDouble());

	// Guard against the name "INVALID ASSIGNMENT" for assignments(it's reserved)
	if(assignNameStr == "INVALID ASSIGNMENT")
	{
		QMessageBox *messageBox = new QMessageBox(this);
		messageBox->setText("You cannot name an assignment \"INVALID ASSIGNMENT\"");
		messageBox->exec();
		boxOne->clear();
		boxTwo->clear();
		return;
	}

	// Make a copy of the new assignment as the old assignment for comparison
	Assignment newAssignment(pointValueDouble, earnedPointsDouble, assignNameStr);
	Assignment currentAssignment(student->getAssignment(assignmentName));

	// Set the text on the confirmation window
	confirmWin->setWindowTitle("Confirm Edit");
	confirmWin->setText("Are you sure you want to edit this assignment?");
	confirmWin->setStandardButtons(QMessageBox::Yes|QMessageBox::No);

	// If the user confirms the confirmation dialog
	if(confirmWin->exec() == QMessageBox::Yes)
	{
		// Edit the points earned/possible
		student->editAssignmentGrade(currentAssignment.getName(), pointValueDouble, earnedPointsDouble);
		// If the name has been changed
		if(assignNameStr != currentAssignment.getName())
		{
			// Get the assignment number to edit the assignment name
			int assignNum = student->getAssignmentNumber(currentAssignment.getName());
			student->editAssignmentName(assignNum, assignNameStr);
		}
		emit assignmentEdited();
	}
	else	// If the user selects no on the confirmation dialog
	{
		return;
	}
	close();
}
// The argument 'text' isn't actually used, it's only there so it takes the same
// number/type of arguments as textChanged from QLineEdit and can be used as a
// slot.
void AddAssignmentDialog::enableSubmitButton(const QString &text)
{
	QString assignmentName(boxOne->text());
	QString pointValue(boxTwo->text());
	if(!assignmentName.isEmpty() && !pointValue.isEmpty())
	{
		submitButton->setEnabled(true);
	}
	else
	{
		submitButton->setEnabled(false);
	}
}
Esempio n. 4
0
LocalPointValue::LocalPointValue(const Point &point)
{
    logMessage("LocalPointValue::LocalPointValue()");

    this->point = point;
    if (Util::scene()->sceneSolution()->isSolved() &&
            Util::scene()->problemInfo()->analysisType == AnalysisType_Transient)
        Util::scene()->problemInfo()->hermes()->updateTimeFunctions(Util::scene()->sceneSolution()->time());

    PointValue val = pointValue(Util::scene()->sceneSolution()->sln(), point);

    value = val.value;
    derivative = val.derivative;
    material = val.marker;
}
void EditIndvAssignmentDialog::enableSubmitButton(const QString &text)
{
	// Get the text currently in all three input boxes
	QString assignmentName(boxOne->text());
	QString pointValue(boxTwo->text());
	QString earnedPoints(earnedPointsBox->text());

	// Are any of the boxes empty?
	if(!assignmentName.isEmpty() && !pointValue.isEmpty() && !earnedPoints.isEmpty())
	{
		submitButton->setEnabled(true);		// If not empty, enable the submit button
	}
	else
	{
		submitButton->setEnabled(false);	// If empty, disable the submit button
	}
}