proofs_helper.rb revision 4e0724b6358960a5e8394dbfd6e0c2d15a6061d5
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainenmodule ProofsHelper
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def url_prove_form
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen destination = resource.proof_obligation
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen destination = destination.ontology if destination.is_a?(OntologyVersion)
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen url_for([destination, :prove])
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen end
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen def klass
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen t("proofs.new.klass.#{resource.proof_obligation.class.to_s.underscore}")
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def proving_single_theorem?
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen resource.theorem?
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def theorems
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if resource.theorem?
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen [resource.proof_obligation]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen else
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen resource.proof_obligation.theorems
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def checked_axiom_selection_method
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen resource.axiom_selection_method || AxiomSelection::METHODS.first
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def sine_value(field, default_value)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen resource.specific_axiom_selection.try(field) || default_value
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def proof_timeout_label(seconds)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unit = proof_timeout_label_unit(seconds)
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen normalized_timeout = seconds / 1.send(unit)
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen label = t("proofs.new.timeout.#{unit}")
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen "#{normalized_timeout} #{label.pluralize(normalized_timeout)}"
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def proof_timeout_label_unit(seconds)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if seconds >= 1.day
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen :day
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen elsif seconds >= 1.hour
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen :hour
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen elsif seconds >= 1.minute
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen :minute
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen else
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen :second
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenend
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen