@@ -14,6 +14,8 @@ import Modal from "@material-ui/core/Modal"
1414import LoginStateContext from "../contexes/LoginStateContext"
1515import LoginControls from "../components/LoginControls"
1616import withSimpleErrorBoundary from "../util/withSimpleErrorBoundary"
17+ import { normalizeExerciseId } from "../util/strings"
18+ import Loading from "../components/Loading"
1719
1820const accentColor = "#FAAA38"
1921
@@ -174,7 +176,9 @@ class ProgrammingExercise extends React.Component {
174176 }
175177
176178 return (
177- < ProgrammingExerciseWrapper >
179+ < ProgrammingExerciseWrapper
180+ id = { normalizeExerciseId ( `programming-exercise-${ name } ` ) }
181+ >
178182 < Header >
179183 < StyledIcon icon = { icon } size = "1x" />
180184 < HeaderMuted > Tehtävä: </ HeaderMuted >
@@ -199,102 +203,111 @@ class ProgrammingExercise extends React.Component {
199203 ) }
200204 </ div >
201205
202- { this . context . loggedIn && this . state . exerciseDetails && (
203- < div >
204- { tokenThreshHold && (
205- < Fragment >
206- < StyledDivider />
207- < TokenContainer >
208- < p >
209- Joka kerta kun olet saanut < i > { tokenThreshHold } </ i > :ta
210- tehtävää tehtyä, saat kolikon. Kolikoilla voi ostaa
211- tehtävien vastauksia ja lunastaa itsesi mahdollisesta
212- jumista.{ " " }
213- { availableTokens > 0 ? (
214- < span >
215- { " " }
216- Käytössäsi on tällä hetkellä { availableTokens } { " " }
217- kolikkoa.
218- </ span >
219- ) : (
220- < span > Sinulla ei ole vielä yhtään kolikkoa.</ span >
206+ { this . context . loggedIn && (
207+ < Loading
208+ loading = { this . state . exerciseDetails === undefined }
209+ heightHint = "305px"
210+ >
211+ < div >
212+ { tokenThreshHold && (
213+ < Fragment >
214+ < StyledDivider />
215+ < TokenContainer >
216+ < p >
217+ Joka kerta kun olet saanut < i > { tokenThreshHold } </ i > :ta
218+ tehtävää tehtyä, saat kolikon. Kolikoilla voi ostaa
219+ tehtävien vastauksia ja lunastaa itsesi mahdollisesta
220+ jumista.{ " " }
221+ { availableTokens > 0 ? (
222+ < span >
223+ { " " }
224+ Käytössäsi on tällä hetkellä { availableTokens } { " " }
225+ kolikkoa.
226+ </ span >
227+ ) : (
228+ < span > Sinulla ei ole vielä yhtään kolikkoa.</ span >
229+ ) }
230+ </ p >
231+ < p >
232+ Pysyt katsomaan mallivastauksen ilman kolikkoja Test My
233+ Code -palvelusta sen jälkeen kun olet saanut tehtävän
234+ oikein.
235+ </ p >
236+
237+ { availableTokens > 0 && (
238+ < Button
239+ onClick = { this . onShowModelSolution }
240+ variant = "outlined"
241+ color = "secondary"
242+ >
243+ Katso mallivastaus (kuluttaa tokenin)
244+ </ Button >
221245 ) }
222- </ p >
223- < p >
224- Pysyt katsomaan mallivastauksen ilman kolikkoja Test My
225- Code -palvelusta sen jälkeen kun olet saanut tehtävän
226- oikein.
227- </ p >
228246
229- { availableTokens > 0 && (
230- < Button
231- onClick = { this . onShowModelSolution }
232- variant = "outlined"
233- color = "secondary"
234- >
235- Katso mallivastaus (kuluttaa tokenin)
247+ < Button variant = "outlined" onClick = { this . onUpdate } >
248+ Päivitä
236249 </ Button >
237- ) }
250+ </ TokenContainer >
238251
239- < Button variant = "outlined" onClick = { this . onUpdate } >
240- Päivitä
241- </ Button >
242- </ TokenContainer >
243-
244- < Modal
245- open = { this . state . modelSolutionModalOpen }
246- onClose = { this . onModelSolutionModalClose }
247- >
248- { this . state . modelSolution && (
249- < ModalContent >
250- < h1 > Mallivastaus </ h1 >
251- { this . state . modelSolution . solution . files . map (
252- fileEntry => {
253- console . log ( fileEntry )
254- return (
255- < Card >
256- < CardContent >
257- < h2 > { fileEntry . path } </ h2 >
258- < pre class = "language-java" >
259- { fileEntry . contents }
260- </ pre >
261- </ CardContent >
262- </ Card >
263- )
264- } ,
265- ) }
266- </ ModalContent >
267- ) }
268- </ Modal >
269- </ Fragment >
270- ) }
271- < p >
272- Palauta tehtävä palvelimelle tarkistettavaksi Netbeans
273- ohjelmointiympäristössä: { " " }
274- < OutboundLink
275- href = "https://materiaalit.github.io/tmc-asennus/netbeans/"
276- rel = "noopener noreferrer"
277- target = "_blank"
278- >
279- ohjeet tehtävien palauttamiseen
280- </ OutboundLink >
281- .
282- </ p >
283- < p >
284- Voit myöhemmin katsoa palautuksiasi Test My Code
285- palautusympäristössä { " " }
286- < OutboundLink
287- href = { `https://tmc.mooc.fi/exercises/ ${
288- this . state . exerciseDetails . id
289- } ?use_clients=1` }
290- rel = "noopener noreferrer"
291- target = "_blank"
292- >
293- täältä
294- </ OutboundLink >
295- .
296- </ p >
297- </ div >
252+ < Modal
253+ open = { this . state . modelSolutionModalOpen }
254+ onClose = { this . onModelSolutionModalClose }
255+ >
256+ { this . state . modelSolution && (
257+ < ModalContent >
258+ < h1 > Mallivastaus </ h1 >
259+ { this . state . modelSolution . solution . files . map (
260+ fileEntry => {
261+ console . log ( fileEntry )
262+ return (
263+ < Card >
264+ < CardContent >
265+ < h2 > { fileEntry . path } </ h2 >
266+ < pre class = "language-java" >
267+ { fileEntry . contents }
268+ </ pre >
269+ </ CardContent >
270+ </ Card >
271+ )
272+ } ,
273+ ) }
274+ </ ModalContent >
275+ ) }
276+ </ Modal >
277+ </ Fragment >
278+ ) }
279+ { this . state . exerciseDetails && (
280+ < Fragment >
281+ < p >
282+ Palauta tehtävä palvelimelle tarkistettavaksi Netbeans
283+ ohjelmointiympäristössä: { " " }
284+ < OutboundLink
285+ href = "https://materiaalit.github.io/tmc-asennus/netbeans/"
286+ rel = "noopener noreferrer"
287+ target = "_blank"
288+ >
289+ ohjeet tehtävien palauttamiseen
290+ </ OutboundLink >
291+ .
292+ </ p >
293+ < p >
294+ Voit myöhemmin katsoa palautuksiasi Test My Code
295+ palautusympäristössä { " " }
296+ < OutboundLink
297+ href = { `https://tmc.mooc.fi/exercises/ ${
298+ this . state . exerciseDetails . id
299+ } ?use_clients=1` }
300+ rel = "noopener noreferrer"
301+ target = "_blank"
302+ >
303+ täältä
304+ </ OutboundLink >
305+ .
306+ </ p >
307+ </ Fragment >
308+ ) }
309+ </ div >
310+ </ Loading >
298311 ) }
299312 </ Body >
300313 </ ProgrammingExerciseWrapper >
0 commit comments