+ 5

[ANSWERED] How do you add a supporting code to a lesson in Lesson Factory?

I wanted to post a lesson, but some parts require a code snippet as examples. I used the code tags, but when I pressed the 'Try it yourself' button, the code shown in playground was the same as snippet. But when I tried editing and saving, there was no change to the code, and it reverted back to the snippet form. Just like other lessons, I want to provide a working code when the user presses the link to the code playground, while only the snippet is to be displayed in the lesson. How do I achieve this?

17th Dec 2017, 3:52 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
8 Antworten
+ 11
@Kinshuk: As of now, we can only submit the full code and SoloLearn will remove headers etc., while reviewing our lessons.
17th Dec 2017, 4:51 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
Bookmarked
24th Feb 2018, 10:20 AM
Manual
Manual - avatar
+ 2
So you first convert the complete code for code playground, and then remove the bits you don't need? Ill try. Thank You!
17th Dec 2017, 4:06 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@Immortal I can't still get it to work. Ill show you what I wanted. I want to add this code : #include <algorithm> #include <iostream> #include <vector> int main() { std::vector<int> vec1; // Declare a vector for(int i=0;i<5;i++) vec1.push_back(5-i); // Assign it 5 elements. for(int i:vec1) std::cout<<i<<" "; std::cout<<std::endl; // Check the original contents. std::sort(vec1.begin(),vec1.end()); // Sort the vector. for(int i:vec1) std::cout<<i<<" "; // Check the vector contents. } Now, This code runs fine on Code Playground, but in the lesson, I don't need the headers and main. I just want this much : std::sort(vec1.begin(),vec1.end()); // Sort the vector, ascending order by default. While clicking the link below this snippet takes the user to the complete code, so that he may run and check what happens. I found that other users who created lessons could get something like this, so I wanted to do this too. But I can't get it to work. Please help me.
17th Dec 2017, 4:17 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@Immortal Yes, I get it, but I just don't want to waste chars just by posting unnecessary headers in snippets. Can't I get it to work like I want, and like the others have done so in their lessons?
17th Dec 2017, 4:21 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
https://www.sololearn.com/learn/261/?ref=app In this lesson, none of the codes have the headers with the snippets. Perhaps Sololearn removed them, or is it a feature only known to some?
17th Dec 2017, 4:27 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
Thank you sir, for confirming the details. Thanks for the help, @Immortal.
17th Dec 2017, 5:00 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
I could convert my snippet to a code, but I can't generate the complete code for it in Code Playground. As in other lessons, the codes given besides the lesson don't have headers, variable declarations, etc, and just the useful part.
17th Dec 2017, 3:57 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar