Skip to content

Commit a225c26

Browse files
committed
Merge branch 'master' into development
2 parents 6627ebe + ffec315 commit a225c26

File tree

19 files changed

+59
-52
lines changed

19 files changed

+59
-52
lines changed

app/models/hbcontent.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import DS from "ember-data";
2+
3+
export default DS.Model.extend({
4+
name: DS.attr(),
5+
details: DS.attr(),
6+
topSubmission: DS.belongsTo('submission'),
7+
"code-challenge": DS.belongsTo('code-challenge'),
8+
problem: DS.belongsTo('problem')
9+
})

app/models/problem.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
import DS from "ember-data";
2-
import { computed } from '@ember/object';
32

43
export default DS.Model.extend({
54
name: DS.attr(),
65
details: DS.attr(),
7-
submissions: DS.hasMany('submission'),
86
solutionStubs: DS.hasMany('solution-stub'),
9-
mostSuccessfullSubmission: computed('submissions', function(){
10-
const submissions = this.submissions;
11-
return submissions.reduce((acc, curr)=> acc.get("score")>= curr.get("score")? acc: curr, submissions.objectAt(0))
12-
}),
13-
hasLatestSubmissionPassed: computed('submissions', function(){
14-
const topSubmission = this.submissions.reduce((acc, val) => acc = acc.get('submit-at') > val.get('submit-at') ? acc: val, this.submissions.objectAt(0))
15-
16-
if(topSubmission.get('isErrored')){
17-
return false
18-
}else{
19-
const failedTestCaseCount = topSubmission.get('judge-result.data.testcases').reduce((acc, val)=> acc = val.result !== 'correct'? ++acc: acc, 0)
20-
return !failedTestCaseCount
21-
}
22-
}),
23-
"code-challenge": DS.belongsTo('code-challenge')
7+
248
})

app/pods/attempt/content/code-challenge/controller.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
3+
import { alias } from '@ember/object/computed';
34

45
export default class CodeChallenge extends Controller {
56
tabs = [
@@ -25,4 +26,7 @@ export default class CodeChallenge extends Controller {
2526
get relatedPendingDoubt () {
2627
return this.runAttempt.doubts.find(doubt => doubt.get('content.id') == this.content.get('id') && ['PENDING', 'ACKNOWLEDGED'].includes(doubt.get('status')))
2728
}
29+
30+
@alias('hbContent.problem')
31+
problem
2832
}

app/pods/attempt/content/code-challenge/route.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,31 @@ export default class CodeChallengeRoute extends Route {
1212
const runAttempt = this.modelFor('attempt')
1313
this.set("api.headers.hackJwt", this.get("currentUser.user.hackJwt"));
1414

15-
const problem = this.api.request(`code_challenges/${content.payload.get('id')}/problem`, {
15+
const hbContent = this.api.request(`code_challenges/${content.payload.get('id')}/content`, {
1616
data: {
1717
contest_id: runAttempt.get("run.contestId")
1818
}
1919
}).then(payload => {
2020
if (!payload) return {}
21-
22-
this.store.unloadAll('problem')
21+
this.store.unloadAll('hbcontent')
2322
this.store.pushPayload(payload)
24-
return this.store.peekRecord('problem', payload.data.id)
23+
return this.store.peekRecord('hbcontent', payload.data.id)
2524
}).catch(err => {
2625
console.log(err)
2726
return {}
2827
})
2928

3029
return hash({
3130
content,
32-
problem,
31+
hbContent,
3332
runAttempt
3433
})
3534
}
3635

3736
setupController(controller, model) {
3837
controller.set('content', model.content)
3938
controller.set('codeChallenge', model.content.payload)
40-
controller.set('problem', model.problem)
39+
controller.set('hbContent', model.hbContent)
4140
controller.set('runAttempt', model.runAttempt)
4241
}
4342
}

app/pods/attempt/content/code-challenge/template.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232

3333
Contest ID: {{runAttempt.run.contestId}} <br>
34-
Problem ID: {{codeChallenge.hbContentId}} <br>
34+
Content ID: {{codeChallenge.hbContentId}} <br>
3535
Run ID: {{runAttempt.run.id}} <br>
3636
Run Attempt ID: {{runAttempt.id}}
3737
</div>

app/pods/certificate/template.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<iframe src="https://docs.google.com/gview?url={{model.url}}&embedded=true" style="width:100%;min-height: 600px"
1+
<iframe src={{model.url}} style="width:100%;min-height: 600px"
22
frameborder="0">
33
</iframe>

app/pods/classroom/timeline/index/template.hbs

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<progress value="{{progressPercent}}" max="100" class="d-inline-block w-90 progress-orange"></progress>
4141

4242
{{!-- % * 0.9 to compensate for 90% width of progress bar --}}
43-
{{#if showGoodieRequest}}
43+
{{#if (and (is-after (unix runAttempt.run.start) '2019-11-29') showGoodieRequest)}}
4444
<div class="progress-lock" style="left: {{goodiesLockOffset}}%; bottom: -2px" id="goodies-lock">
4545
<div class="bg-light-grey br-25 card-sm font-normal p-2 progress-lock__bubble">Complete {{runAttempt.run.goodiesThreshold}}% to claim goodies</div>
4646
{{#if (gte progressPercent runAttempt.run.goodiesThreshold)}}
@@ -131,7 +131,9 @@
131131
<div class="border-card p-4">
132132
<ExtensionsWidget
133133
@onClose={{action (mut showExtensions) false}}
134-
@run={{runAttempt.run}} />
134+
@run={{runAttempt.run}}
135+
@expired={{runAttempt.isExpired}}
136+
/>
135137
</div>
136138
{{/if}}
137139

app/pods/classroom/timeline/route.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export default Route.extend({
3535
// try to enroll in preview
3636
try {
3737
await this.api.request(`runs/${params.runId}/enroll`)
38-
transition.retry()
38+
return this.transitionTo('classroom.timeline.index', params.courseId, params.runId)
39+
// transition.retry()
3940
} catch (err) {
4041
if (err.status == 400 && err.payload.err == "TRIAL_WITHOUT_MOBILE") {
4142
// trial creation denined because user has no mobile number

app/pods/components/code-challenge/code-challenge-code-editor/component.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class CodeEditor extends Component {
8686
])
8787

8888
setCodeStubs() {
89-
this.problem.solutionStubs.map(stub => {
89+
this.problem.get('solutionStubs').map(stub => {
9090
const languageSpec = this.languageSpecs.findBy('code', stub.language)
9191
if (languageSpec.source === '') {
9292
set(languageSpec, 'source', stub.body)
@@ -162,19 +162,19 @@ export default class CodeEditor extends Component {
162162
"method": "GET"
163163
}), submissionStatus => submissionStatus && submissionStatus['judge-result'] !== null);
164164

165-
this.get('api').request(`code_challenges/${this.codeChallenge.get('id')}/problems`,{
165+
this.get('api').request(`code_challenges/${this.codeChallenge.get('id')}/content`,{
166166
data: {
167167
contest_id: runAttempt.get("run.contestId")
168168
},
169169
}).then(async result=>{
170-
this.set("problemJsonApiPayload", result);
170+
// this.set("problemJsonApiPayload", result);
171171
const payload = JSON.parse(JSON.stringify(result))
172-
this.get('store').unloadAll('problem')
173-
later(async() => {
172+
// this.get('store').unloadAll('hbcontent') // kyu ?
173+
later(async () => {
174174
this.get('store').pushPayload(payload)
175-
const problem = await this.get('store').peekRecord('problem', result.data.id)
176-
if (await problem.get('hasLatestSubmissionPassed') && await problem.get('mostSuccessfullSubmission.score') == 100) {
177-
const progress = await this.get('content.progress')
175+
const hbContent = await this.get('store').peekRecord('hbcontent', result.data.id)
176+
if (await hbContent.get('topSubmission.score') == 100) {
177+
const progress = await this.content.get('progress')
178178
progress.set("status", 'DONE')
179179
return progress.save();
180180
}

app/pods/components/code-challenge/code-challenge-explanation/template.hbs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</p>
44
<div class="extra-bold">Input Format</div>
55
<p>
6-
{{markdown-to-html problem.details.input-format}}
6+
{{markdown-to-html problem.details.input_format}}
77
</p>
88
<div class="extra-bold">Constraints</div>
99
<div class="bg-dark-grey br-5 w-60 px-4 py-2 my-2">
@@ -13,15 +13,15 @@
1313
</div>
1414
<div class="extra-bold">Output Format</div>
1515
<p>
16-
{{markdown-to-html problem.details.output-format}}
16+
{{markdown-to-html problem.details.output_format}}
1717
</p>
1818
<div class="extra-bold">Sample Input</div>
1919
<div class="bg-dark-grey br-5 w-60 px-4 py-2 my-2">
20-
<pre>{{problem.details.sample-input}}</pre>
20+
<pre>{{problem.details.sample_input}}</pre>
2121
</div>
2222
<div class="extra-bold">Sample Output</div>
2323
<div class="bg-dark-grey br-5 w-60 px-4 py-2 my-2">
24-
<pre>{{problem.details.sample-output}}</pre>
24+
<pre>{{problem.details.sample_output}}</pre>
2525
</div>
2626
{{#if problem.details.explanation}}
2727
<div class="extra-bold">Explanation</div>

app/pods/components/extensions-widget/template.hbs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<div class="p-4">
22
<div class="row">
33
<div class="col-8 my-auto font-mds">
4-
<div class="bold">Your course has been expired!</div>
4+
<div class="bold">Your course
5+
{{if @expired 'has been expired!' 'will expire soon!'}}
6+
</div>
57
<div>Buy extension for this course</div>
68
</div>
79
<div class="col-4 t-align-r">

app/pods/components/locked-content/component.js

-4
This file was deleted.

app/pods/components/locked-content/template.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="row justify-content-center">
1111
<div class="mt-3">
1212
<a
13-
href="/courses/{{course.slug}}"
13+
href="/courses/{{@course.slug}}"
1414
target="_blank"
1515
class="button-solid button-orange">
1616
Buy Now

app/pods/components/my-courses-list/expired-courses/content/template.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<ExtensionsWidget
3333
@run={{run}}
3434
@onClose={{action (mut showExtensionsModal) false}}
35+
@expired={{runAttempt.isExpired}}
3536
/>
3637
</ModalDialog>
3738
{{/if}}

app/pods/components/tracks/tracks-doubts-form/component.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default class TracksDoubtsFormComponent extends Component {
77
alreadySent = false
88
name = null
99
mobile = null
10+
email = null
1011

1112
@service api
1213

@@ -18,6 +19,7 @@ export default class TracksDoubtsFormComponent extends Component {
1819
data: {
1920
name: this.name,
2021
mobile: this.mobile,
22+
email: this.email,
2123
course: 'Tracks',
2224
},
2325
meta: {

app/pods/components/tracks/tracks-doubts-form/template.hbs

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
</div>
1818
<div class="mt-4">
1919
{{input type="text" class="input-search bg-light-grey p-3 w-100" placeholder="Mobile number, For eg. 9999999999" value=mobile}}
20+
</div>
21+
<div class="mt-4">
22+
{{input type="text" class="input-search bg-light-grey p-3 w-100" placeholder="Email" value=email}}
2023
</div>
2124
{{#if error}}
2225
<p class="mt-4 mb-0 red">

app/pods/components/unstarted-content/controller.js

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="row justify-content-center">
22
<FaIcon @icon="lock" @size="3" />
33
</div>
4-
<div class="row justify-content-center">
5-
<h2 class="white">Your course will start on {{run.startString}}</h2>
4+
<div class="row justify-content-center my-3">
5+
<h2 class="white">Your course will start on {{moment-format (unix @run.start) "Do MMM, YYYY"}}</h2>
66
</div>

app/pods/dashboard/template.hbs

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
12
<div class="row">
3+
<div class="col-md-12">
4+
<promotion-banner class="">
5+
</promotion-banner>
6+
</div>
27
<div class="col-md-9 col-12">
38
{{#if lastAccessedRun}}
49
<h4 class="my-4">Continue Learning</h4>
@@ -153,3 +158,6 @@
153158
<CarouselCards />
154159
</div>
155160
</div>
161+
162+
163+
<script src="https://unpkg.com/@coding-blocks/[email protected]/dist/index.js" async></script>

0 commit comments

Comments
 (0)