[O] Use CourseInfoRating in course-head

This commit is contained in:
Hykilpikonna
2020-04-27 02:23:55 -04:00
parent 311544b5aa
commit 509243f874
@@ -51,7 +51,7 @@
<div class="stars"> <div class="stars">
<span class="star clickable" v-for="star in [0,1,2,3,4]" @click="changeStars(index, star)"> <span class="star clickable" v-for="star in [0,1,2,3,4]" @click="changeStars(index, star)">
<i v-if="ratingData[index] > star" class="el-icon-star-on"/> <i v-if="rating.ratings[index] > star" class="el-icon-star-on"/>
<i v-else class="el-icon-star-off"/> <i v-else class="el-icon-star-off"/>
</span> </span>
</div> </div>
@@ -62,9 +62,9 @@
<div class="description">Any additional comments? (this is optional)</div> <div class="description">Any additional comments? (this is optional)</div>
<el-input type="textarea" placeholder="Comments... (Optional)" <el-input type="textarea" placeholder="Comments... (Optional)"
v-model="ratingComment" maxlength="4500" show-word-limit :autosize="{minRows: 2, maxRows: 4}"> v-model="rating.comment" maxlength="4500" show-word-limit :autosize="{minRows: 2, maxRows: 4}">
</el-input> </el-input>
<el-checkbox v-model="ratingAnonymous">Anonymous</el-checkbox> <el-checkbox v-model="rating.anonymous">Anonymous</el-checkbox>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@@ -90,6 +90,7 @@
@Prop({required: true}) clickable: boolean; @Prop({required: true}) clickable: boolean;
ratingDialog = false; ratingDialog = false;
ratingPosting = false;
ratingCriteria = [ ratingCriteria = [
{title: 'Enjoyable', desc: 'How enjoyable is the course?'}, {title: 'Enjoyable', desc: 'How enjoyable is the course?'},
{title: 'Knowledge', desc: 'How interesting is the content of the course? ' + {title: 'Knowledge', desc: 'How interesting is the content of the course? ' +
@@ -98,10 +99,7 @@
{title: 'Eloquence', desc: `Are the teacher's lectures easy to understand?`}, {title: 'Eloquence', desc: `Are the teacher's lectures easy to understand?`},
{title: 'Fairness', desc: `How fair is the teacher's grading? Is credit given in proportion to effort?`} {title: 'Fairness', desc: `How fair is the teacher's grading? Is credit given in proportion to effort?`}
]; ];
ratingData = [0,0,0,0,0]; rating = this.course.rating;
ratingComment = '';
ratingAnonymous = false;
ratingPosting = false;
/** /**
* Redirect to the course page * Redirect to the course page
@@ -128,7 +126,7 @@
*/ */
changeStars(index: number, star: number) changeStars(index: number, star: number)
{ {
this.ratingData[index] = star + 1; this.rating.ratings[index] = star + 1;
this.$forceUpdate(); this.$forceUpdate();
} }
@@ -139,12 +137,7 @@
{ {
this.ratingPosting = true; this.ratingPosting = true;
App.http.post('/course-info/rating/set', {rating: { App.http.post('/course-info/rating/set', {rating: this.rating}).then(response =>
id_ci: this.course.id_ci,
anonymous: this.ratingAnonymous,
ratings: this.ratingData,
comment: this.ratingComment}
}).then(response =>
{ {
if (response.success) if (response.success)
{ {